import type { PlasmoMessaging } from "@plasmohq/messaging"; const handler: PlasmoMessaging.MessageHandler = async (req, res) => { const { token, siteUrl } = await chrome.storage.local.get(["token", "siteUrl"]); if (!token || !siteUrl) { throw new Error("未指定 Token 或站点地址"); } // 更新追番进度 if (req.body.action === "updateBangumiProgress") { const { values } = req.body; const updateRequest = await fetch(`${siteUrl}/api/bangumi/update`, { method: "POST", body: JSON.stringify(values), headers: { "paul-token-code": token, }, }).then((res) => res.json()); res.send(updateRequest); } } export default handler;