我想托管我的javascript文件,而不是用扩展名打包它。我已阅读有关使用内容安全策略将交叉域列入白名单的信息。这就是我所拥有的,但它会抛出错误
"Could not load javascript '' for content script."
的manifest.json
{
"name": "My Chrome App",
"version": "1.0",
"manifest_version": 2,
"content_scripts": [{
"matches": ["<all_urls>"],
"js": ["https://example.com/platform/myjs.js"],
"run_at": "document_end"
}],
"background": {
"scripts":["background.js"]
},
"description": "My app description goes here", //on hover
"icons": {
"128": "icon.png"
},
"browser_action": {
"default_title": "My Chrome App",
"default_popup": "popup.html"
},
"permissions": [
"http://*/*", "https://*/*","tabs"
],
"content_security_policy": "script-src 'self' https://example.com; object-src 'self'"
}
我想要做的不可能吗?或者有解决方法吗?自从CSP几年前更新以来,我找不到这个问题的最新答案。
更新:正如@PredatorIWD所建议的那样,我查看了this answer,但是当我检查后台页面的视图时,我收到以下错误:
Unchecked runtime.lastError while running tabs.executeScript: Cannot access a chrome:// URL
我很困惑为什么直到我发现this answer解决了我的问题。