How to get to script content sandbox in Chrome JS console

If I open the JavaScript console in the Chrome developer tools to debug my content content scripts, I don't get the content script context. For example, jQuery is not available, and I cannot access my global variables unless I go to the debugger and set a breakpoint.

Did I miss something? It would be great to check my global variables from the JS console or call jQuery.

+5
source share
2 answers

At the moment, it is not possible to perform evaluations in the context of the contents of the script, except for the described method of installing the breakpoint / inserting debugger statement and suspension inside the script. I registered a bug , you can add yourself to the list of SS to track its progress.

+2
source

You can achieve this indirectly by calling the debugger in an isolated world of content script:

  • Select the tab whose content scripts you want to check.
  • Open dev tools for this tab
  • Open an inspector for your main extension page (or any other extension page) in a popup window
  • Run chrome.tabs.executeScript(undefined, {'code': 'debugger'})

debugger script, , .

+1

All Articles