1

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.

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.

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

Any advice would be highly appreciated.

Community
  • 1
  • 1
denikov
  • 877
  • 2
  • 17
  • 35
  • Why are you needing to detect this event? As the developer, you know when you're clicking on the link. For your users, "go to `chrome://extensions/`, turn on 'developer mode', and click 'background page'" is a horrible user interface. – Teepeemm Mar 06 '16 at 20:51
  • @Teepeemm I suspect it's the inverse, basically prevent inspection by the user. I don't think the fact that a debugger is attached is detectable. – Xan Mar 07 '16 at 00:40
  • @Teepeemm Xan is correct, it is to prevent inspection by the user. I think I found the solution, although it is probably terrible for performance. In the post I linked, there is a solution by "zswang". I inserted that code into the background page of my plugin and it detects the open console...but I can't imagine running an interval at 1sec constantly is very efficient. – denikov Mar 07 '16 at 01:06

1 Answers1

0

Devtools windows are not visible to tabs/windows APIs anymore.

This has changed since the answer from '14 was posted - therefore this method no longer applies.

Unfortunately, I can't find a link to the Chromium issue that implemented that.

Xan
  • 74,770
  • 16
  • 179
  • 206