内部データを用いた取得テスト

This commit is contained in:
2026-04-08 01:07:10 +09:00
commit a05af1a208
15 changed files with 1098 additions and 0 deletions
+27
View File
@@ -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.");