diff --git a/build/scriptcat/manifest.json b/build/scriptcat/manifest.json index 3a649a25..a01e06d0 100644 --- a/build/scriptcat/manifest.json +++ b/build/scriptcat/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "ScriptCat", - "version": "0.7.3", + "version": "0.7.4", "description": "脚本猫,一个用户脚本的框架,可编写脚本每天帮你自动处理事务.", "background": { "page": "background.html" diff --git a/package.json b/package.json index 4224c4b6..72668f58 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "scriptcat", - "version": "0.7.3", + "version": "0.7.4", "description": "脚本猫,一个可以执行用户脚本的浏览器扩展,万物皆可脚本化,让你的浏览器可以做更多的事情!", "scripts": { "test": "jest", diff --git a/src/apps/config.ts b/src/apps/config.ts index c2b249d4..94745b7b 100644 --- a/src/apps/config.ts +++ b/src/apps/config.ts @@ -1,4 +1,4 @@ -export const ExtVersion = "0.7.3"; +export const ExtVersion = "0.7.4"; export const Server = process.env.NODE_ENV == "production" ? "https://sc.icodef.com/" : "http://localhost:8080/"; diff --git a/src/apps/grant/frontend.ts b/src/apps/grant/frontend.ts index 97405335..28e43cd6 100644 --- a/src/apps/grant/frontend.ts +++ b/src/apps/grant/frontend.ts @@ -343,7 +343,7 @@ export class FrontendGrant implements ScriptContext { @FrontendGrant.GMFunction({ depend: ['GM_setValue'] }) public GM_deleteValue(name: string): void { - GM_setValue(name, undefined); + this.GM_setValue(name, undefined); } @FrontendGrant.GMFunction() diff --git a/src/pkg/sandbox/sandbox.ts b/src/pkg/sandbox/sandbox.ts index 23ff9e94..0b8bd2da 100644 --- a/src/pkg/sandbox/sandbox.ts +++ b/src/pkg/sandbox/sandbox.ts @@ -42,7 +42,7 @@ for (const key in descs) { export function buildThis(global: any, context: any) { let special = Object.assign({}, writables); // 后台脚本要不要考虑不能使用eval? - let _this: any = {}; + let _this: any = { eval: global.eval }; let proxy: any = new Proxy(context, { defineProperty(_, name, desc) { return Object.defineProperty(context, name, desc); @@ -113,6 +113,5 @@ export function buildThis(global: any, context: any) { return ret; } }); - _this.eval = global.eval.bind(proxy); return proxy; } \ No newline at end of file diff --git a/tests/sandbox.user.js b/tests/sandbox.user.js new file mode 100644 index 00000000..502bc761 --- /dev/null +++ b/tests/sandbox.user.js @@ -0,0 +1,48 @@ +// ==UserScript== +// @name 油猴兼容测试 +// @namespace http://tampermonkey.net/ +// @version 0.1 +// @description try to take over the world! +// @author You +// @match https://bbs.tampermonkey.net.cn/ +// @icon https://www.google.com/s2/favicons?domain=tampermonkey.net.cn +// @resource icon https://bbs.tampermonkey.net.cn/favicon.ico +// @resource html https://bbs.tampermonkey.net.cn/ +// @resource xml https://bbs.tampermonkey.net.cn/sitemap.xml +// @grant GM_getResourceText +// @grant GM_getResourceURL +// ==/UserScript== + +console.log(window.scrollX, window.scrollY); + +console.log(addEventListener); + +let uia = (function () { + console.log('123'); + return { + tip: () => { + console.log('aqwe'); + } + } +})() + +uia.tip(); + +function evalTest() { + console.log('okk'); +} + +setTimeout(() => { + console.log('okk2', window.scrollX, window.scrollY); + window.scrollY = 633; + console.log('okk2', window.scrollX, window.scrollY); +}, 1000) + +let f = eval('()=>{evalTest()}'); +f(); +console.log(this); +eval('console.log(this)'); + +window.onload = () => { + console.log('onload'); +} \ No newline at end of file