executeScript不在chrome扩展中执行

时间:2014-07-09 14:50:30

标签: javascript jquery google-chrome google-chrome-extension

在我的Google Chrome扩展程序中,“executeScript”事件对我不起作用 这是代码:

chrome.tabs.onUpdated.addListener(function(tabId,tab){
    alert("!");
    chrome.tabs.executeScript(tabId, {code: "alert('hello');"} );
  }
);

问题很少,首先是警报(“!”)在标签刷新时被触发2次。
第二个问题是“executeScript”没有做任何事情。

1 个答案:

答案 0 :(得分:0)

问题解决了!
而不是给予扩展此权限:

  "permissions": [
    "tabs"
  ],

我需要给它这样的权限:

  "permissions": [
    "tabs", "http://*/*", "https://*/*"
  ],
相关问题