diff --git a/src/runtime/background/utils.ts b/src/runtime/background/utils.ts index 149b7ec2..e8a3af13 100644 --- a/src/runtime/background/utils.ts +++ b/src/runtime/background/utils.ts @@ -388,7 +388,7 @@ export async function dealXhr( LoggerCore.getLogger(Logger.E(e)).error("GM XHR response error"); } try { - respond.responseText = xhr.responseText; + respond.responseText = xhr.responseText || undefined; } catch (e) { LoggerCore.getLogger(Logger.E(e)).error("GM XHR getResponseText error"); } diff --git a/src/runtime/content/exec_script.test.ts b/src/runtime/content/exec_script.test.ts index 3fd7feea..07067039 100644 --- a/src/runtime/content/exec_script.test.ts +++ b/src/runtime/content/exec_script.test.ts @@ -97,4 +97,12 @@ describe("sandbox", () => { const ret = sandboxExec.exec(); expect(ret).toEqual("ok3"); }); + + // 沉浸式翻译, 常量值被改变 + it("NodeFilter #214", () => { + scriptRes2.code = `return NodeFilter.FILTER_REJECT;`; + sandboxExec.scriptFunc = compileScript(compileScriptCode(scriptRes2)); + const ret = sandboxExec.exec(); + expect(ret).toEqual(2); + }); }); diff --git a/src/runtime/content/utils.test.ts b/src/runtime/content/utils.test.ts index 1b09e8a1..7c52f941 100644 --- a/src/runtime/content/utils.test.ts +++ b/src/runtime/content/utils.test.ts @@ -41,7 +41,6 @@ describe("proxy context", () => { }); describe("兼容问题", () => { - console.log("ok"); const _this = proxyContext({}, {}); // https://github.com/xcanwin/KeepChatGPT 环境隔离得不够干净导致的 it("Uncaught TypeError: Illegal invocation #189", () => { diff --git a/src/runtime/content/utils.ts b/src/runtime/content/utils.ts index a7f4790a..eade0a00 100644 --- a/src/runtime/content/utils.ts +++ b/src/runtime/content/utils.ts @@ -123,6 +123,7 @@ export const init = new Map(); // 需要用到全局的 export const unscopables: { [key: string]: boolean } = { + NodeFilter: true, RegExp: true, };