本地主机的Chrome扩展权限在manifest.js中不起作用

时间:2018-11-07 08:08:19

标签: google-chrome google-chrome-extension localhost

我正在尝试在manifest.json中获得本地主机权限,因此可以使用chrome.tabs.executeScript,但是它不起作用。我已经尝试了几乎所有您能想到的。这是一个示例:

{
    "manifest_version": 2,
    "name": "extName",
    "version": "1",
    "description": "extDesc",
    "content_scripts": [
        {
            "matches": [
                "http://localhost:3000/*",
                "http://127.0.0.1/*",
                "http://*/*",
                "https://*/*"
            ],
            "css": [
                "style.css"
            ],
            "js": [
                "contentScript.js"
            ]
        }
    ],
    "background": {
        "scripts": [
          "background.js"
        ]
    },
    "permissions": [
        "activeTab",
        "tabs"
    ]
}

但是无论我尝试什么,我都会不断得到

Error during tabs.executeScript: Cannot access contents of url .... 
Extension manifest must request permission to access this host. 

实际上,我认为这也没有在localhost

上发生

这是我的background.js:

chrome.runtime.onMessage.addListener(
    function(message, callback) {
      if (message == "runContentScript"){
        chrome.tabs.executeScript(null, {
            code: 'console.log(window.angular)'
          });
      }
   });

0 个答案:

没有答案