-
Notifications
You must be signed in to change notification settings - Fork 310
添加GM_openInTab新可选功能 #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
添加GM_openInTab新可选功能 #178
Conversation
在background页面使用window.open代替chrome.tabs.create打开目标url 兼容onclose 使用方法:参数中主动加入useOpen: true 以启用 意义:chrome.tabs.create在http页面表现情况与https不同。这一可选功能能够绕开http页面限制,让用户在extension插件页面中将url打开 注:这是一个实验/不兼容其他管理器的功能
CodFrm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
另外关于这个的使用场景是什么呢?
建议再验证一下firefox的兼容性
| Cache.getInstance().set(`GM_openInTab:${tab.id}`, channel); | ||
| channel.send({ event: "oncreate", tabId: tab.id }); | ||
| }); | ||
| if (options.useOpen === true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可修改成if (options.useOpen)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个判断我觉得不要改,限定死为true才使用新window.open比较好
万一用户加进来奇奇怪怪的参数,可能会产生无法预料到的后果,不是true的话直接忽略,用老方法,老方法也会忽略这个参数的
|
另外,.d.ts标注一下,这是一个试验性质的功能吧 |
Codecov ReportPatch coverage:
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## main #178 +/- ##
==========================================
- Coverage 50.90% 50.82% -0.08%
==========================================
Files 64 64
Lines 3931 3941 +10
Branches 905 909 +4
==========================================
+ Hits 2001 2003 +2
- Misses 1930 1938 +8
☔ View full report in Codecov by Sentry. |
经测试无法兼容Firefox,Firefox似乎禁止在background页面使用window.open()会直接返回null 这个功能主要是提供了一个让(自定义协议或其他)url可以绕过http页面限制的手段 |
|
LGTM |
|
@CodFrm 是不是API改变了? 现在用 http 执行一般的 我是用 當然原生 |
看起来是的,这是mv2时候的pr了,感觉可以直接取消useOpen这个方式了,我测试可以直接通过 Firefox 我测试 |
很好。 |
改动内容
在background页面使用
window.open代替chrome.tabs.create打开目标url兼容
onclose使用方法
参数中主动加入
useOpen: true以启用功能意义
chrome.tabs.create在http页面表现情况与https不同。这一可选功能能够绕开
http页面限制,让用户在extension插件页面中将url打开附注
这是一个实验/不兼容其他管理器的功能
未测试火狐兼容性
部分应用
上图为


GM_openInTab(url),http页面运行脚本打开协议url每次强制弹出确认框下图为
GM_openInTab(url,{useOpen:true}),在http页面运行脚本打开协议url只会弹出第一次确认框,勾选后后续不会再弹出