diff --git a/example/usersubscribe.js b/example/usersubscribe.user.sub.js similarity index 100% rename from example/usersubscribe.js rename to example/usersubscribe.user.sub.js diff --git a/src/runtime/content/utils.test.ts b/src/runtime/content/utils.test.ts index e43b1fa8..507b8bd4 100644 --- a/src/runtime/content/utils.test.ts +++ b/src/runtime/content/utils.test.ts @@ -55,12 +55,16 @@ describe("兼容问题", () => { }); }); -// 允许往global写入Symbol属性,影响内容: https://bbs.tampermonkey.net.cn/thread-5509-1-1.html describe("Symbol", () => { const _this = proxyContext({}, {}); + // 允许往global写入Symbol属性,影响内容: https://bbs.tampermonkey.net.cn/thread-5509-1-1.html it("Symbol", () => { const s = Symbol("test"); _this[s] = "ok"; expect(_this[s]).toEqual("ok"); }); + // toString.call(window)返回的是'[object Object]'而不是'[object Window]',影响内容: https://github.com/scriptscat/scriptcat/issues/260 + it("Window", () => { + expect(toString.call(_this)).toEqual("[object Window]"); + }); }); diff --git a/src/runtime/content/utils.ts b/src/runtime/content/utils.ts index 99397073..0b3d2781 100644 --- a/src/runtime/content/utils.ts +++ b/src/runtime/content/utils.ts @@ -229,6 +229,8 @@ export function proxyContext( } } else if (name === Symbol.unscopables) { return unscopables; + } else if (name === Symbol.toStringTag) { + return name; } } return undefined; @@ -317,6 +319,7 @@ export function proxyContext( } }, }); + proxy[Symbol.toStringTag] = "Window"; return proxy; }