I am using Chrome browser Version 52.0.2743.116 (64-bit) on Mac OSX 10.11.6.
I have a chrome extension with a background.js where I have a console.log statement for debugging purposes. However, I am unable to see the output in the Chrome browser console. Alert works fine but console.log outputs nothing.
alert("CSS code: "+css);
console.log("CSS code:"+css);
I have checked to make sure "All" messages are selected, the context is set to "top", etc. When the page loads, I see other console.log messages (not from my extension), the alert window pop up but nothing printed to the console.
How do I see console.log output?
EDIT: Adding the function code where the alert
and console.log
statements appear.
function doSomething(tab) {
var tabUrl = tab.url;
if (tabUrl && tabUrl.indexOf("my-site.com") != -1) {
var css = "";
if (hideAds == true) {
css += ".adsBanner {display: none !important;} .promo {display: none !important;} ";
}
alert("CSS code: "+css);
console.log("CSS code:"+css);
chrome.tabs.insertCSS(tab.id, {
code: css
});
}
}
EDIT 2: In response to the comment that this is a duplicate of this question, I want to print console.log
statements from the background file, I don't have a popup.html file. The other question has solutions to execute console.log
on the background page called from the popup page.
Steps to Open the Console Log in Google Chrome By default, the Inspect will open the "Elements" tab in the Developer Tools. Click on the "Console" tab which is to the right of "Elements". Now you can see the Console and any output that has been written to the Console log.
Click the Console tab. Press Control + [ or Command + [ (Mac) until the Console is in focus. Open the Command Menu, start typing Console , select the Show Console Panel command, and then press Enter .
This has been previously answered here. It seems the background.js has its own console window that needs to be watched (launched from the extension's inpsect view link under chrome://extensions).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With