Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 338
Abhisek Chaudhuri Avatar asked Mar 24 '18 21:03

Abhisek Chaudhuri


1 Answers

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

like image 143
ethan.roday Avatar answered Sep 19 '22 14:09

ethan.roday