Chrome 扩展程序 - 调试模式后清除信息栏标签
Posted
技术标签:
【中文标题】Chrome 扩展程序 - 调试模式后清除信息栏标签【英文标题】:Chrome Extension - Clear infobar label after debug mode 【发布时间】:2020-12-06 00:11:58 【问题描述】:在基于 Chrome 的浏览器的最新版本中,出于某种原因(可能不是错误,这是一项功能),在调试模式分离后,Chrome 会留下此通知:
“程序开始调试这个浏览器”
Screenshot
基本上,我运行这段代码
let debugee = tabId: sender.tab.id;
chrome.debugger.attach(debugee, '1.2', ()=>);
chrome.debugger.detach(debugee);
请看上图。 Chrome 删除了 detach
上的此通知,直到版本 80(左右)。
我找到了问题的描述: https://chromium.googlesource.com/chromium/src/+/HEAD/chrome/app/generated_resources.grd
<!-- DevTools attached infobar -->
<message name="IDS_DEV_TOOLS_INFOBAR_LABEL" desc="Label displayed in an infobar when external debugger is attached to the browser. The label does not disappear until the user dismisses it, even if the debugger is detached, and so should not imply that the debugger must still be debugging the browser, only that it was, and could still be.">
"<ph name="CLIENT_NAME">$1<ex>Extension Foo</ex></ph>" started debugging this browser
</message>
我正在寻找有关如何通过 chrome 扩展程序自动清除或禁用此消息的建议。
【问题讨论】:
【参考方案1】:TL;DR 没有这种方法。
Chrome 中的新行为是对安全问题的尴尬修复的结果:恶意扩展可以通过 chrome.debugger API 迅速造成大量破坏,即使在不到 100 毫秒。
由于涉及安全问题,旧行为将无法恢复,但他们同意 UI 至少应反映当前调试器状态,请参阅https://crbug.com/1096262。他们目前的计划是,如果扩展已分离,则在可见 >=5 秒后自动关闭信息栏,并更新按钮/字符串以与状态同步。
一种解决方法是使用--silent-debugger-extension-api
命令行开关运行chrome。这是一个危险的开关,但从某种意义上说,您必须小心不要立即或在更新时安装使用 debugger
权限的恶意扩展。
【讨论】:
以上是关于Chrome 扩展程序 - 调试模式后清除信息栏标签的主要内容,如果未能解决你的问题,请参考以下文章
安装chrome插件Advanced Rest Client来调试RESTFul