fix: 重构 vscode-extension 用 VS Code browser API + CDP 直接注入,替代 IBE 修复集成浏览器无法翻译 - #766
Open
PtJade-Ceramic wants to merge 1 commit into
Open
fix: 重构 vscode-extension 用 VS Code browser API + CDP 直接注入,替代 IBE 修复集成浏览器无法翻译#766PtJade-Ceramic wants to merge 1 commit into
PtJade-Ceramic wants to merge 1 commit into
Conversation
Closed
Owner
|
请先尝试将 |
PtJade-Ceramic
marked this pull request as draft
August 2, 2026 04:18
PtJade-Ceramic
force-pushed
the
fix-ibe-document-start
branch
from
August 2, 2026 07:51
ad594ce to
c3fc493
Compare
Contributor
Author
|
发现:GitHub 的 CSP 阻止 IBE 执行脚本(硬阻塞) 在 VS Code 集成浏览器 + IBE 下实测,脚本注入时被 github.com 的 CSP 拦截:
这属于 IBE 注入机制与 GitHub 安全策略的根本冲突(且 IBE 已停止维护、源码仓库已删除)。 意图:改为使用 VS Code 自身的
|
PtJade-Ceramic
force-pushed
the
fix-ibe-document-start
branch
from
August 2, 2026 10:29
76e34f2 to
1e42943
Compare
Owner
|
browser API 概率不支持相关 |
PtJade-Ceramic
force-pushed
the
fix-ibe-document-start
branch
from
August 2, 2026 14:45
d8bade8 to
750a833
Compare
PtJade-Ceramic
marked this pull request as ready for review
August 2, 2026 14:46
Contributor
Author
- 用 VS Code browser API + CDP 直接注入中文化脚本,替代 IBE(规避 CSP eval 限制) - 修正 BrowserCDPSession 接口调用(sendMessage/onDidReceiveMessage/close),双保险注入修复集成浏览器无法翻译 - 删除旧的 IBE 适配脚本 main(vscode).user.js,扩展归属改为上游 maboloshi - 启动参数变更(--enable-proposed-api maboloshi.github-chinese)且不再依赖 IBE,主版本升至 2.0.0 - 更新文档与版本号至 2.0.0
PtJade-Ceramic
force-pushed
the
fix-ibe-document-start
branch
from
August 2, 2026 15:30
750a833 to
0043ff5
Compare
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.

Fixes #765
背景
VS Code 集成浏览器(Integrated Browser Extensions, IBE)注入用户脚本时依赖
new Function(eval)执行脚本,而 github.com 的 CSP(script-src github.githubassets.com,不含unsafe-eval)会拦截 eval,导致页面完全未翻译(EvalError)。因此无论document-start还是document-end,IBE 都无法在 github.com 上运行任何用户脚本。变更
本 PR 不再依赖 IBE,改为使用 VS Code 自己的 proposed
browserAPI(vscode.window.browserTabs+startCDPSession())向集成浏览器直接注入:boylett.integrated-browser-extensions的依赖,删除两个 IBE wrapper 脚本(main(vscode).user.js、vscode-extension/main(vscode).user.js)browserAPI(enabledApiProposals: ["browser"]),需以--enable-proposed-api maboloshi.github-chinese启动locals.js+main.user.js,规避页面 CORS 限制Page.addScriptToEvaluateOnNewDocument注册到新文档,之后导航/刷新自动生效Runtime.evaluate对当前已加载文档立即执行一次,无需刷新即可翻译当前页面addStyle/getValue/setValue/xmlhttpRequest等)与 document-end 语义(等DOMContentLoaded后执行),main.user.js无需任何 GM 相关改动github-chinese.refresh/github-chinese.status命令--enable-proposed-api maboloshi.github-chinese)验证
GM_addStyle可用、<html lang="zh-CN">、导航与正文均为中文)