Abhisek Chaudhuri
Abhisek Chaudhuri

Reputation: 161

Make chrome extension available in all websites

I am trying to build a chrome extension. Want it to be always enabled.

I tried to do it in the following way:

chrome.declarativeContent.onPageChanged.removeRules(undefined, function(){
  chrome.declarativeContent.onPageChanged.addRules([{
    conditions: [new chrome.declarativeContent.PageStateMatcher({pageUrl: { urlContains: '*' },})],
    actions: [new chrome.declarativeContent.ShowPageAction()]
  }]);
});

But it doesn't seem to work correctly. How to get this done?

Upvotes: 6

Views: 1469

Answers (1)

ethan.roday
ethan.roday

Reputation: 2635

If you just want your icon to be visible all the time, the standard way to do that is through the browser_action field in your manifest.json file:

{
  "browser_action": {
     "default_icon": {
        "32": "images/icon32.png" // Chrome supports various icon sizes (in pixels)
      },
      "default_title": "Title", // The title that shows up when a user hovers on your icon
      "default_popup": "popup.html" // The URL of your popup page
  }
}

Presumably, it should be the same as whatever page_action entry you already have.

For more details, see: https://developer.chrome.com/extensions/browserAction

Upvotes: 8

Related Questions