a
Some checks failed
build / Build (push) Failing after 9s
test / Run tests (push) Failing after 11s

This commit is contained in:
王一之 2025-02-12 22:27:43 +08:00
parent 3c238bcdc8
commit 9b9513fea5
3 changed files with 4 additions and 25 deletions

View File

@ -22,29 +22,7 @@ export default class ServiceWorkerManager {
// 准备好环境 // 准备好环境
this.mq.emit("preparationOffscreen", {}); this.mq.emit("preparationOffscreen", {});
const ctx = await chrome.runtime.getContexts({ // sendMessageToOffscreen("preparationOffscreen", {});
contextTypes: [chrome.runtime.ContextType.OFFSCREEN_DOCUMENT],
documentUrls: [chrome.runtime.getURL("src/offscreen.html")],
});
console.log("ctx", ctx, chrome.runtime.getURL("src/offscreen.html"));
chrome.scripting.executeScript({
target: {
documentIds: [ctx[0]!.documentId!],
tabId: -1,
},
func: (message) => {
// 在页面上下文中执行的代码
console.log("tesss");
window.postMessage(
{
type: "sendMessage",
daat: message,
},
"*"
);
},
args: [{ action: "test", data: "test" }],
});
}); });
const resource = new ResourceService(group.group("resource"), this.mq); const resource = new ResourceService(group.group("resource"), this.mq);

2
src/types/main.d.ts vendored
View File

@ -5,7 +5,7 @@ declare module "*.yaml";
declare const sandbox: Window; declare const sandbox: Window;
declare const clients: Clients; declare const self: ServiceWorkerGlobalScope;
declare namespace GMSend { declare namespace GMSend {
interface XHRDetails { interface XHRDetails {

View File

@ -3,7 +3,8 @@
"target": "ES2020", "target": "ES2020",
"lib": [ "lib": [
"DOM", "DOM",
"ES2020" "ES2020",
"WebWorker"
], ],
"module": "ESNext", "module": "ESNext",
"jsx": "react-jsx", "jsx": "react-jsx",