0

I'm new to developing chrome extensions, and wanted to start with some simple code. I've tried to change the badge text when the user clicks the icon. However, this doesn't seem to work. Can anyone suggest what am I doing wrong here?

manifest.json

  {
  "name": "Hello World",
  "description": "Just displays hello world",
  "version": "1.2",
  "manifest_version": 2,
  "background": 
    {
        "scripts": ["background.js"],
        "persistent": false
    },
  "browser_action":
    {
        "name": "Click to display",
        "default_popup": "popup.html"

    }

 }

background.js

function updatebadge()
{
chrome.browserAction.setBadgeText({text: "Hello!"});    
};

chrome.browserAction.onClicked.addListener(updatebadge);

popup.html

<body>
    Hello, World!
</body>
Darshit Patel
  • 121
  • 1
  • 1
  • 12

1 Answers1

4

According to the chrome.browserAction

onClicked

Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup.

So you can remove your popup, or use a work-around...

chrome.browserAction.onClicked.addListener() with popup

Community
  • 1
  • 1
Liyang Chen
  • 112
  • 7