scriptcat-mv3/src/service_worker.ts
2024-11-01 17:01:53 +08:00

22 lines
531 B
TypeScript

chrome.runtime.onConnect.addListener((port) => {
console.log("service worker connected", port);
});
async function setupOffscreenDocument() {
// 创建运行后台脚本的沙盒环境
await chrome.offscreen.createDocument({
url: "src/offscreen.html",
reasons: [chrome.offscreen.Reason.CLIPBOARD],
justification: "offscreen page",
});
// Send message to offscreen document
chrome.runtime.sendMessage({
type: "init",
target: "offscreen",
data: { init: "1" },
});
}
setupOffscreenDocument();