File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -41,15 +41,15 @@ export function compileScriptCode(scriptRes: ScriptRunResource, scriptCode?: str
4141
4242export function compileScriptCodeByResource ( resource : CompileScriptCodeResource ) : string {
4343 const sourceURL = `//# sourceURL=${ chrome . runtime . getURL ( `/${ encodeURI ( resource . name ) } .user.js` ) } ` ;
44- const requireCode = resource . require . map ( ( r ) => r . content ) . join ( "\n" ) ;
45- const preCode = [ requireCode ] . join ( "\n" ) ; // 不需要 async 封装
44+ const requireCode = resource . require . map ( ( r ) => r . content ) . join ( "\n; " ) ;
45+ const preCode = requireCode ; // 不需要 async 封装
4646 const code = [ resource . code , sourceURL ] . join ( "\n" ) ; // 需要 async 封装, 可top-level await
4747 // context 和 name 以unnamed arguments方式导入。避免代码能直接以变量名存取
4848 // this = context: globalThis
4949 // arguments = [named: Object, scriptName: string]
50- // 使用sandboxContext时,arguments[0]为undefined, this.$则为一次性Proxy变量,用於全域拦截context
50+ // 使用sandboxContext时,arguments[0]为undefined, this.$则为一次性Proxy变量,用于全域拦截context
5151 // 非沙盒环境时,先读取 arguments[0],因此不会读取页面环境的 this.$
52- // 在UserScripts API中,由於执行不是在物件导向裡呼叫 ,使用arrow function的话会把this改变。须使用 .call(this) [ 或 .bind(this)() ]
52+ // 在UserScripts API中,由于执行不是在物件导向里呼叫 ,使用arrow function的话会把this改变。须使用 .call(this) [ 或 .bind(this)() ]
5353 return `try {
5454 with(arguments[0]||this.$){
5555${ preCode }
You can’t perform that action at this time.
0 commit comments