match
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:
@ -10,6 +10,10 @@ export default class ContentRuntime {
|
||||
) {}
|
||||
|
||||
start(scripts: ScriptRunResouce[]) {
|
||||
console.log("onMessage");
|
||||
this.msg.onMessage((msg, sendResponse) => {
|
||||
console.log("content onMessage", msg);
|
||||
});
|
||||
// 由content到background
|
||||
// 转发gmApi消息
|
||||
// this.contentMessage.setHandler("gmApi", (action, data) => {
|
||||
|
@ -29,8 +29,18 @@ export function compileScript(code: string): ScriptFunc {
|
||||
}
|
||||
|
||||
export function compileInjectScript(script: ScriptRunResouce): string {
|
||||
return `window['${script.flag}']=function(context,GM_info){\n${script.code}\n}`;
|
||||
}
|
||||
|
||||
// 编译注入脚本信息
|
||||
export function compileInjectScriptInfo(
|
||||
messageFlag: string,
|
||||
script: ScriptRunResouce,
|
||||
injectScriptInfoCode: string
|
||||
): string {
|
||||
return (
|
||||
`console.log(window,'` + script.flag + `');window['${script.flag}']=function(context,GM_info){\n${script.code}\n}`
|
||||
`(function (MessageFlag, ScriptFlag, ScriptUuid) {\n${injectScriptInfoCode}\n})` +
|
||||
`('${messageFlag}', '${script.flag}', '${script.uuid}');`
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user