1

Google Chrome Extension. The console.log doesn't work in the addListener, however works fine outside addListener. I have reinstalled. I have tried this on Windows and MacOS.

chrome.runtime.onMessage.addListener(

 function(request, sender, sendResponse) {

    console.log("listen"); // this does not
    alert("got here"); // this works


 }
);
Mark Worsnop
  • 4,407
  • 15
  • 54
  • 79

1 Answers1

5

If the code is in your background this console.log doesn't appear in the log of the current page. Look like that is the case.

If that is the case:

Go to chrome://extensions/ look for your extension. Click on Inspect views: background.html (you can have another name depending of you manifest). You will see a developer tool with the a console.

Raúl Martín
  • 4,471
  • 3
  • 23
  • 42