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.