0

Possible Duplicate:
Where to read console messages from background.js in a Chrome extension?

I am trying to write my first Google Chrome extension. All I am trying to do is is create an extension that writes a string, via console.log(), to the console when the extension's browser action icon is clicked.

Here is my manifest.json:

{
  "name": "My Extension",
  "description": "My Extension",
  "version": "1.0",
  "permissions": ["tabs"],
  "background": {
    "scripts": ["test.js"]
  },
  "browser_action": {
    "default_title": "My Extension",
    "default_icon": "icon.png"
  },
  "manifest_version": 2
}

And here is test.js:

chrome.browserAction.onClicked.addListener(function(tab) { console.log('testing'); });

I have the console open in Chrome but when I click my extension's icon nothing is displayed in the console. I've tried reloading the extension but it hasn't helped.

I am abviously doing something wrong.

Any advice would be much appreciated. LT

Community
  • 1
  • 1
RobertJoseph
  • 7,968
  • 12
  • 68
  • 113

1 Answers1

4

Your script runs in the background page, so the message will be displayed in the background page's console.

  • Open the Extensions page.
  • Make sure that Developer mode is checked.
  • Under My Extension, click _generated_background_page.html to inspect it.
  • Click on the Console tab.
Romanito
  • 717
  • 5
  • 6
  • It now lives somewhere different: On the Extensions page > Inspect views > service worker – Robin Feb 07 '23 at 21:27