Console Log for Chrome DevTools API

I am extending Google Chrome using the "chrome.devtools.panels.create" API, which means that I now have some kind of logic in my browser that I need to debug.

Anyway, to see the Console / Debug tab of my DevTools add-ons?

+6
source share
2 answers

If you need just console.log , you can wrap it. It actually works for any other function, not just console.log , but here is an example for wrapping console.log :

 console._log = console.log; console.log = function(){ // you can do whatever you want with arguments, output to div, alert / etc. return console._log.apply(console,arguments); }; 
+2
source

You need to define a script in a checked window:

chrome.devtools.inspectedWindow.eval('console.log("test")')

+2
source

Source: https://habr.com/ru/post/918486/


All Articles