在Google chrome扩展程序中,background.js的执行脚本未加载文件。
background.js
chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
chrome.tabs.executeScript(tabId, {
file: 'index.js'
});
});
manifest.json
{
"manifest_version": 2,
"permissions": [
"activeTab",
"declarativeContent",
"storage",
"tabs",
"file://*/*",
"https://*/*",
"http://*/*"
],
"background": {
"scripts": ["js/jquery.min.js", "js/background.js"],
"persistent": true
},
"content_security_policy": "script-src 'self' https://ssl.google-analytics.com; object-src 'self'"
}
错误是
- 未经检查的runtime.lastError:无法访问chrome:// URL
- 未经检查的runtime.lastError:无法加载文件:“ index.js”。
- 未经检查的runtime.lastError:无法访问URL“ chrome-search://local-ntp/local-ntp.html”的内容。扩展清单必须 请求访问此主机的权限。