Chrome扩展-调试模式后清除信息栏标签



在最近版本的基于Chrome的浏览器中,由于某种原因(可能不是bug,这是一个功能(,在调试模式被分离后,Chrome会留下以下通知:

"程序开始调试这个浏览器";

屏幕截图

基本上,我运行这个代码

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扩展自动清除或禁用此消息的建议。

TL;DR没有这样的方法。

Chrome中的新行为是对安全问题进行笨拙修复的结果:恶意扩展可以通过Chrome.debug API快速造成大量破坏,即使工作在100毫秒内完成,也没有人会知道发生了什么。

由于涉及安全问题,旧的行为不会被恢复,但他们一致认为UI至少应该反映当前调试器的状态,请参阅https://crbug.com/1096262.他们目前的计划是在>5s,如果扩展已分离并更新按钮/字符串以与状态同步。

解决方法是使用--silent-debugger-extension-api命令行开关运行chrome。这是一个危险的切换,但从某种意义上说,您必须小心,不要立即或在更新时安装使用debugger权限的恶意扩展。

最新更新