简体   繁体   English

检测Chrome扩展程序后台页面控制台已打开

[英]Detect Chrome Extension background page console opened

Just like the title says, I'm wondering whether it's possible to detect when I click on "Background Page" for my test plugin on the "chrome://extensions/" page. 就像标题所说的那样,我想知道是否有可能在单击“ chrome:// extensions /”页面上的测试插件时单击“背景页面”。

Right now when I open the background page, the console is undocked. 现在,当我打开后台页面时,控制台已停靠。 I saw this post and found ways to make it work inside each content script. 我看到了这篇文章,并找到了使其在每个内容脚本中都能工作的方法。 But is there a way to make the plugin detect it's own console opening? 但是有没有办法让插件检测到自己的控制台打开?

This function from that post inside my background.js doesn't seem to detect anything. background.js中该帖子中的此功能似乎未检测到任何东西。

chrome.tabs.query({url:'chrome-devtools://*/*'}, function(tabs){
  if (tabs.length > 0){
    console.log('opened');
  }
});

Any advice would be highly appreciated. 任何建议将不胜感激。

Devtools windows are not visible to tabs / windows APIs anymore. Devtools窗口不再对tabs / windows API可见。

This has changed since the answer from '14 was posted - therefore this method no longer applies. 自从发布'14的答案以来,这种情况已经改变-因此该方法不再适用。

Unfortunately, I can't find a link to the Chromium issue that implemented that. 不幸的是,我找不到实现该功能的Chromium问题的链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM