2013年3月1日 星期五

chrome bowserAction

chrome.browserAction.onClicked.addListener(function(tabs.Tab tab) {...});

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

假如browser action有開啟popup.html,此事件就不會被觸發!!

所以假設我一定要有popup.html,
我就不能用chrome.browserAction.onClicked的方式注入content script
而要在manifest.json定義


{
  "name": "My extension",
  ...
  "content_scripts": [
    {
      "matches": ["http://www.google.com/*"],
      "css": ["mystyles.css"],
      "js": ["jquery.js", "myscript.js"]
    }
  ],
  ...
}


Ref:
1. http://developer.chrome.com/extensions/browserAction.html
2. http://studio.zeuik.com/?p=850#sthash.cWrFaEEC.25PMSXkS.dpbs

沒有留言:

張貼留言