内部データを用いた取得テスト
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import browser from "webextension-polyfill";
|
||||
import type { Message } from "../shared/messages";
|
||||
import { savePlaylist, getPlaylist } from "../shared/storage";
|
||||
|
||||
const LOG_PREFIX = "[yt-playlist-features:bg]";
|
||||
|
||||
browser.runtime.onMessage.addListener(
|
||||
async (message: unknown, _sender: browser.Runtime.MessageSender) => {
|
||||
const msg = message as Message;
|
||||
|
||||
if (msg.type === "PLAYLIST_EXTRACTED") {
|
||||
console.log(
|
||||
LOG_PREFIX,
|
||||
`Saving playlist: "${msg.data.metadata.title}" (${msg.data.extractedCount} videos)`,
|
||||
);
|
||||
await savePlaylist(msg.data);
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.type === "GET_PLAYLIST") {
|
||||
const data = await getPlaylist(msg.playlistId);
|
||||
return { type: "PLAYLIST_RESPONSE", data } satisfies Message;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
console.log(LOG_PREFIX, "Service worker started.");
|
||||
Reference in New Issue
Block a user