1
- import { FrontenApiValue , SandboxContext , ScriptContext } from '@App/apps/grant/frontend' ;
1
+ import { FrontenApiValue , FrontendGrant , SandboxContext , ScriptContext } from '@App/apps/grant/frontend' ;
2
2
import { ScriptCache , Script } from '@App/model/do/script' ;
3
3
4
4
// 编译脚本代码字符串
@@ -14,11 +14,11 @@ export function compileScriptCode(script: ScriptCache): string {
14
14
} ) ;
15
15
code = require + code ;
16
16
return (
17
- 'with (context) return ((GM_info , context, fapply, CDATA, uneval, define, module, exports)=>{\n' +
17
+ 'with (context) return ((context, fapply, CDATA, uneval, define, module, exports)=>{\n' +
18
18
code +
19
19
'\n//# sourceURL=' +
20
20
chrome . runtime . getURL ( '/' + encodeURI ( script . name ) + '.user.js' ) +
21
- '\n})(GM_info, context)'
21
+ '\n})(context)'
22
22
) ;
23
23
}
24
24
@@ -53,7 +53,7 @@ export function createSandboxContext(script: ScriptCache): SandboxContext {
53
53
return < SandboxContext > createContext ( context , script ) ;
54
54
}
55
55
56
- export function createContext ( context : ScriptContext , script : Script ) : ScriptContext {
56
+ export function createContext ( context : ScriptContext , script : ScriptCache ) : ScriptContext {
57
57
context [ 'postRequest' ] = context . postRequest ;
58
58
context [ 'script' ] = context . script ;
59
59
if ( script . metadata [ 'grant' ] ) {
@@ -72,7 +72,7 @@ export function createContext(context: ScriptContext, script: Script): ScriptCon
72
72
setDepend ( context , apiVal ) ;
73
73
} ) ;
74
74
}
75
- context [ 'GM_info' ] = context . GM_info ( ) ;
75
+ context [ 'GM_info' ] = FrontendGrant . GM_info ( script ) ;
76
76
77
77
// 去除原型链
78
78
return Object . assign ( { } , context ) ;
0 commit comments