Repository navigation
实现 @run-in / 分离隐身模式 - #384
Merged
Merged
Conversation
@run-in api 显式声明脚本注入标签类型 - `normal-tabs` 注入正常标签 - `incognito-tabs` 注入隐身标签 缺省时、同时声明时,既注入正常标签又隐身标签 具体用法见新增示例 新增 `CacheStorage.prototype.clear` 清除所有缓存 同步更新`GM_info` `manifest.json`显示声明`"incognito": "split"`分离浏览器隐身模式时扩展进程及上下文 `package.json`新增`dev-noMap`方法 - 无`SourceMap`的`development`模式 (已知带`SourceMap`的`dev`模式会造成扩展的`service_work.js`无法完成注册,可能是浏览器限制或bug)
CodFrm
reviewed
May 9, 2025
| "scripts": ["src/service_worker.js"] | ||
| "service_worker": "src/service_worker.js" | ||
| }, | ||
| "incognito": "split", |
Member
There was a problem hiding this comment.
Contributor
Author
There was a problem hiding this comment.
"incognito": "split"能够隔离正常模式和隐身模式扩展上下文
不添加"incognito"字段,扩展正常模式和隐身模式共用同一个service_worker等上下文,正常模式下的操作能实时影响隐身模式,即使在隐身模式中,扩展也无法直接知道自己在隐身模式中(可能可以通过chrome.tab的运行环境等特殊方法间接判断)
在"incognito": "split"隔离上下文的情况下,带SourceMap的dev模式加载扩展,进入隐身模式service_worker会无法完成注册,产生报错
Service worker registration failed. Status code: 10
Failed to access storage.
我这边100%复现,排查方法service_worker.ts:
pack打包扩展后,隐身模式下service_worker正常注册无报错- 将
main();入口注释、function main()不注释,仍然报错 - 注释整个
function main(),不报错
推测是带SourceMap打包后service_worker文件过大,导致注册失败,不清楚是隐身模式的限制还是浏览器BUG
Member
会有这个问题吗?一直没遇到唉 |
CodFrm
reviewed
May 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@run-inapi用于显式声明脚本注入标签类型
normal-tabs注入正常标签incognito-tabs注入隐身标签缺省时、同时声明时,既注入正常标签又隐身标签
具体用法见新增示例
TODO
@run-in特性https://www.tampermonkey.net/documentation.php?ext=iikm&version=5.3.3#meta:run_in
同步更新
GM_info新增
CacheStorage.prototype.clear方法 清除所有缓存manifest.json显示声明"incognito": "split"分离浏览器隐身模式时扩展进程及上下文注:目前隐身模式的
chrome.storage操作会影响正常模式TODO
package.json新增dev-noMap方法SourceMap的development模式(已知带
SourceMap的dev模式会造成扩展的service_work.js无法完成注册,可能是浏览器限制或bug)