Skip to content

Commit bf00c61

Browse files
committed
fix(remove-redirect): 修复 rewriteWindowOpen 拦截失效
1 parent adb9f59 commit bf00c61

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

.changeset/curvy-geckos-help.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'remove-redirect': patch
3+
---
4+
5+
修复 `rewriteWindowOpen` 拦截失效

packages/remove-redirect/metablock.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
"exclude": ["*://localhost:*/*", "*://127.0.0.1:*/*", "*://0.0.0.0*", "*://192.168.*"],
1717
"require": [],
1818
"connect": ["baidu.com", "*"],
19-
"grant": ["GM.xmlHttpRequest", "GM_xmlhttpRequest"]
19+
"grant": ["unsafeWindow", "GM.xmlHttpRequest", "GM_xmlhttpRequest"]
2020
}

packages/remove-redirect/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ function handleRewriteWindowOpen({
9191
queryName = 'target',
9292
}: Site.RewriteWindowOpen) {
9393
// 保存原始的 window.open 方法
94-
const originalWindowOpen = window.open
94+
const originalWindowOpen = unsafeWindow.open
9595

96-
window.open = function (url?: string | URL, target?: string, features?: string) {
96+
unsafeWindow.open = function (url?: string | URL, target?: string, features?: string) {
9797
// 仅 url 为字符串时进行重写拦截
9898
if (isString(url)) {
9999
/* 验证器模块 */

0 commit comments

Comments
 (0)