调试
Some checks failed
build / Build (push) Failing after 6s
test / Run tests (push) Failing after 8s
Some checks failed
build / Build (push) Failing after 6s
test / Run tests (push) Failing after 8s
This commit is contained in:
parent
20124be0e4
commit
11c08f1b4c
@ -148,6 +148,7 @@ export class RuntimeService {
|
|||||||
matches: ["<all_urls>"],
|
matches: ["<all_urls>"],
|
||||||
allFrames: true,
|
allFrames: true,
|
||||||
runAt: "document_start",
|
runAt: "document_start",
|
||||||
|
world: "ISOLATED",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -188,9 +189,19 @@ export class RuntimeService {
|
|||||||
registerScript.runAt = getRunAt(script.metadata["run-at"]);
|
registerScript.runAt = getRunAt(script.metadata["run-at"]);
|
||||||
}
|
}
|
||||||
chrome.userScripts.register([registerScript], () => {
|
chrome.userScripts.register([registerScript], () => {
|
||||||
|
// 标记为已注册
|
||||||
Cache.getInstance().set("registryScript:" + script.uuid, true);
|
Cache.getInstance().set("registryScript:" + script.uuid, true);
|
||||||
});
|
});
|
||||||
// 标记为已注册
|
console.log(registerScript);
|
||||||
|
// 把脚本uuid注册到content页面
|
||||||
|
chrome.userScripts.register([
|
||||||
|
{
|
||||||
|
id: "content-" + scriptRes.uuid,
|
||||||
|
js: [{ code: "window.a=1;console.log('window.a',window,window.b)" }],
|
||||||
|
matches: dealMatches(matches),
|
||||||
|
runAt: "document_start",
|
||||||
|
},
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
unregistryPageScript(script: Script) {
|
unregistryPageScript(script: Script) {
|
||||||
|
@ -23,3 +23,7 @@ client.pageLoad().then((data) => {
|
|||||||
const runtime = new ContentRuntime(send, msg);
|
const runtime = new ContentRuntime(send, msg);
|
||||||
runtime.start(data.scripts);
|
runtime.start(data.scripts);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
chrome.storage.local.get((data) => {
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
|
@ -29,7 +29,9 @@ export function compileScript(code: string): ScriptFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function compileInjectScript(script: ScriptRunResouce): string {
|
export function compileInjectScript(script: ScriptRunResouce): string {
|
||||||
return `window['${script.flag}']=function(context,GM_info){\n${script.code}\n}`;
|
return (
|
||||||
|
`console.log(window,'` + script.flag + `');window['${script.flag}']=function(context,GM_info){\n${script.code}\n}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置api依赖
|
// 设置api依赖
|
||||||
|
Loading…
x
Reference in New Issue
Block a user