4

I want to make chrome extension which opens all my favourite websites when I click on it.

Currently my manifest.json is:

{
  "manifest_version": 2,
  "name": "Soical_open",
  "description": "This extension opens all my favorite social sites once",
  "version": "1.0",
  "background": {
    "scripts": ["background.js"]
  }
}

and my background.js is:

var queue = ['www.fb.com', 'www.gmail.com' , 'www.quora.com'];
chrome.browserAction.onClicked.addListener(function(tab) {
  for (var i=0; i<queue[1].length; ++i)
    chrome.tabs.create({"url": queue[i], "active": false, "index":tab.index+i});
});

When I load this extension and click on it, nothing happens. What is that I am doing wrong? What am I missing?

Xan
  • 74,770
  • 16
  • 179
  • 206

1 Answers1

0

You did not create a Browser Action.

It's messy since Chrome introduced mandatory icons in toolbar for all extensions, but if you don't declare a "browser_action" section in the manifest, that dummy "button" doesn't fire any event. Clicking it just opens a context menu.

Just supply an icon and add a "browser_action" section to the manifest, and it will work (do not specify a popup, just the icon/title, otherwise onClicked will not fire).

Community
  • 1
  • 1
Xan
  • 74,770
  • 16
  • 179
  • 206
  • Maybe you can even get away with an empty `"browser_action"` section - but it must be present. – Xan May 10 '16 at 15:58