Chrome Extension - Console Log not firing

Posted by coffeemonitor on Stack Overflow See other posts from Stack Overflow or by coffeemonitor
Published on 2013-06-25T04:09:49Z Indexed on 2013/06/25 4:21 UTC
Read the original article Hit count: 169

I'm starting to learn to make my own Chrome Extensions, and starting small. At the moment, I'm switching from using the alert() function to console.log() for a cleaner development environment.

For some reason, console.log() is not displaying in my chrome console logs. However, the alert() function is working just fine.

Can someone review my code below and perhaps tell me why console.log() isn't firing as expected?

manifest.json

{
  "manifest_version": 2,
  "name": "Sandbox",
  "version": "0.2",
  "description": "My Chrome Extension Playground",
  "icons":  { 
        "16": "imgs/16x16.png", 
        "24": "imgs/24x24.png", 
        "32": "imgs/32x32.png", 
        "48": "imgs/48x48.png" 
        },

  "background": { 
         "scripts": ["js/background.js"]
        },


  "browser_action": {
        "default_title": "My Fun Sandbox Environment",
            "default_icon": "imgs/16x16.png"
        },

  "permissions": [
        "background",
        "storage",
        "tabs", 
        "http://*/*",
        "https://*/*"
        ] 
}

js/background.js

function click(e) {
  alert("this alert certainly shows");  
  console.log("But this does not");
}

// Fire a function, when icon is clicked
chrome.browserAction.onClicked.addListener(click);

As you can see, I kept it very simple. Just the manifest.json and a background.js file with an event listener, if the icon in the toolbar is clicked.

As I mentioned, the alert() is popping up nicely, while the console.log() appears to be ignored.

© Stack Overflow or respective owner

Related posts about google-chrome-extension

Related posts about console.log