the click on chrome extension icon doesn't trigger chrome.browserAction.onClicked each time I clicked the icon

1,831 views
Skip to first unread message

Oussama He

unread,
Aug 13, 2018, 4:55:25 PM8/13/18
to Chromium-Extensions-Announce

I'm developing a chrome extension and I want to detect every time a user clicks the extension icon.
I used chrome.browserAction.onClicked.addListener(function(){console.log('icon clicked')}) but I get the message one time only, when I click second time, third time, ... I get nothing. I don't know where is the problem

Below a portions of code of the extension:

manifest.json

{
    "manifest_version": 2,
    "name": "My ext",
    "version": "0.1",
    "browser_action": {
      "default_title": "My ext"
    },
    "permissions": [
      "tabs", "<all_urls>"
    ],
    "background":
    {
        "scripts": ["background.js"]
    }   }

background.js

 chrome.browserAction.onClicked.addListener(function(tab) { 
   console.log("icon clicked")
   // do something
});

Devlin Cronin

unread,
Aug 14, 2018, 7:55:37 PM8/14/18
to Chromium-Extensions-Announce
This should work (the listener should be fired each time the icon is clicked).  Loading the snippet you have below, the console statement prints each time the icon is clicked (note that devtools will collapse identical log statements, but you can see the counter increment).  Are you able to reproduce this issue with the minimized extension you have below, or only with your full extension?
Reply all
Reply to author
Forward
0 new messages