Skip to content

(MV2) 增强 chrome.tabs.create 兼容性#640

Merged
CodFrm merged 1 commit intoscriptscat:release/mv2from
cyfung1031:mv2_fix_openTab
Aug 19, 2025
Merged

(MV2) 增强 chrome.tabs.create 兼容性#640
CodFrm merged 1 commit intoscriptscat:release/mv2from
cyfung1031:mv2_fix_openTab

Conversation

@cyfung1031
Copy link
Collaborator

部份瀏覽器不支持 openerTabId ,windowId 等options

@cyfung1031 cyfung1031 changed the title 增强 chrome.tabs.create 兼容性 (MV2) 增强 chrome.tabs.create 兼容性 Aug 18, 2025
@CodFrm
Copy link
Member

CodFrm commented Aug 19, 2025

部分浏览器是哪个浏览器?我记得之前不是另外的原因所以才导致填写了openerTabId打不开么 #586 (comment)

不过最近确实有用户与我反馈,窗口无法打开的问题

@cyfung1031
Copy link
Collaborator Author

cyfung1031 commented Aug 19, 2025

这个PR是之前有提交过
可是之后你加windowId时退回去
54c1da2


上回分解

对,上一次PR的,是因为没加 windowId 所以打不开
(不能只加 tabId 做openerTabId)

而最原始的 tabId 和 windowId 都没有的保证能打开。


今回

可参考这个
greasemonkey/greasemonkey@7444f22

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/Tab#browser_compatibility

tabId 和 windowId 都是原本就有的
openerTabId 是后来API新增的参数
因此有部份未有支持
如果不支持 openerTabId (旧规格API),应该会出错 (错误的物件参数)
因此这个PR重提,用try catch
先试新API规格,加 openerTabId 和windowId
如果不行的话,要把openerTabId删掉,那麼windowId一同删掉 (跟旧版一样,保证没问题)

  • 這API本來的設計不預期需要 openerTabId, 只是一個很簡單的打開Tab. 所以反而加了一大堆參數會出問題?

另外,MV3裡有一些地方也指定了chrome.tabs.create的 openerTabId 跟 windowId
但没有指定index. 不懂怎麼改,所以PR #639 没有提相关修改。
confirmWindow
CAT_fileStorage

openerTabId跟windowId的指定,不是要决定在哪打开吗?
为什麼不用指定Index?
如果也要指定index, 直接用这个 openInCurrentTab 就行了

@CodFrm
Copy link
Member

CodFrm commented Aug 19, 2025

不添加openerTabId的话,又回到了 zen #548 的问题,而且每次关闭窗口(例如弹出来的权限确认窗口)都会回退到最后一个窗口,而不是打开的窗口,这样用户体验不是很好

指定index是想让两个tab连续在一起,我觉得mv3那边的也可以使用这个openInCurrentTab,之前没有指定大概是没注意吧,我去处理一下

@CodFrm CodFrm merged commit eb4d1ab into scriptscat:release/mv2 Aug 19, 2025
2 checks passed
@cyfung1031 cyfung1031 deleted the mv2_fix_openTab branch October 4, 2025 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants