Skip to content

Commit fbe6e05

Browse files
committed
🚑 紧急修复GM沙盒问题
1 parent 259077b commit fbe6e05

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

build/scriptcat/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 2,
33
"name": "ScriptCat",
4-
"version": "0.9.2",
4+
"version": "0.9.3",
55
"description": "脚本猫,一个用户脚本的框架,可编写脚本每天帮你自动处理事务.",
66
"background": {
77
"page": "background.html"

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "scriptcat",
3-
"version": "0.9.2",
3+
"version": "0.9.3",
44
"description": "脚本猫,一个可以执行用户脚本的浏览器扩展,万物皆可脚本化,让你的浏览器可以做更多的事情!",
55
"scripts": {
66
"lint": "eslint --ext .js,.ts,.tsx tests/ src/",

src/apps/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const ExtVersion = '0.9.2';
1+
export const ExtVersion = '0.9.3';
22

33
export const Server = process.env.NODE_ENV == 'production' ? 'https://sc.icodef.com/' : 'http://localhost:8080/';
44

src/injected.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ browserMsg.listen('scripts', (msg) => {
8484
return;
8585
}
8686
if ((<{ [key: string]: () => void }><unknown>window)[script.flag]) {
87-
(<{ [key: string]: (context: ScriptContext) => void }><unknown>window)[script.flag].apply(context, [context]);
87+
(<{ [key: string]: (GM_Info:any, context: ScriptContext) => void }><unknown>window)[script.flag].apply(context, [GMInfo,context]);
8888
}
8989
Object.defineProperty(window, script.flag, {
9090
get: () => { return undefined; },

src/pkg/sandbox/compile.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FrontenApiValue, SandboxContext, ScriptContext } from '@App/apps/grant/frontend';
1+
import { FrontenApiValue, FrontendGrant, SandboxContext, ScriptContext } from '@App/apps/grant/frontend';
22
import { ScriptCache, Script } from '@App/model/do/script';
33

44
// 编译脚本代码字符串
@@ -14,11 +14,11 @@ export function compileScriptCode(script: ScriptCache): string {
1414
});
1515
code = require + code;
1616
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' +
1818
code +
1919
'\n//# sourceURL=' +
2020
chrome.runtime.getURL('/' + encodeURI(script.name) + '.user.js') +
21-
'\n})(GM_info, context)'
21+
'\n})(context)'
2222
);
2323
}
2424

@@ -53,7 +53,7 @@ export function createSandboxContext(script: ScriptCache): SandboxContext {
5353
return <SandboxContext>createContext(context, script);
5454
}
5555

56-
export function createContext(context: ScriptContext, script: Script): ScriptContext {
56+
export function createContext(context: ScriptContext, script: ScriptCache): ScriptContext {
5757
context['postRequest'] = context.postRequest;
5858
context['script'] = context.script;
5959
if (script.metadata['grant']) {
@@ -72,7 +72,7 @@ export function createContext(context: ScriptContext, script: Script): ScriptCon
7272
setDepend(context, apiVal);
7373
});
7474
}
75-
context['GM_info'] = context.GM_info();
75+
context['GM_info'] = FrontendGrant.GM_info(script);
7676

7777
// 去除原型链
7878
return Object.assign({}, context);

0 commit comments

Comments
 (0)