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

trn*_*rnj 3 google-chrome google-chrome-extension google-chrome-devtools google-chrome-app

在基于 Chrome 的浏览器的最新版本中,出于某种原因(可能不是错误,它是一个功能),在 debug mode is detached 后,Chrome 会留下以下通知:

“程序开始调试这个浏览器”

截屏

基本上,我运行这段代码

let debugee = {tabId: sender.tab.id};
chrome.debugger.attach(debugee, '1.2', ()=>{});
chrome.debugger.detach(debugee);
Run Code Online (Sandbox Code Playgroud)

并看上图。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>
Run Code Online (Sandbox Code Playgroud)

我正在寻找有关如何从 chrome 扩展程序自动清除或禁用此消息的建议。

wOx*_*xOm 5

TL;DR 没有这样的方法。

Chrome 中的新行为是对安全问题进行笨拙修复的结果:恶意扩展程序可以通过 chrome.debugger API 迅速造成大量损害,如果工作在短时间内执行,则没有人会知道发生了什么100 毫秒。

由于涉及安全问题,旧行为不会恢复,但他们同意 UI 至少应反映当前调试器状态,请参阅https://crbug.com/1096262。他们目前的计划是如果扩展程序已分离并更新按钮/字符串以与状态同步,则在可见时间 >=5 秒后自动关闭信息栏。

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