Firefox addon Firefox扩展-添加JSDeliver cdn
我希望在html页面中访问JSDeliver cdn(或任何其他cnd)。 根据我所做的研究,这是在内容脚本和内容安全策略中进行的,但无论我做了什么,我仍然会得到以下错误Firefox addon Firefox扩展-添加JSDeliver cdn,firefox-addon,firefox-addon-webextensions,Firefox Addon,Firefox Addon Webextensions,我希望在html页面中访问JSDeliver cdn(或任何其他cnd)。 根据我所做的研究,这是在内容脚本和内容安全策略中进行的,但无论我做了什么,我仍然会得到以下错误 Content Security Policy: The page’s settings blocked the loading of a resource at https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js (“script-src”
Content Security Policy: The page’s settings blocked the loading of a resource at https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js (“script-src”).
这是我的清单,希望有人能给我指出正确的方向
"background": {
"scripts": ["background.js"],
"page": "my-page.html"
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["https://code.jquery.com, https://*.cdn.jsdelivr.net/npm"]
}
],
"browser_action": {
"default_icon": "icons/page-32.png"
},
"content_security_policy": "script-src 'self' https://*.cdn.jsdelivr.net/npm; object-src 'self'",
"permissions": [
"tabs",
"storage"
]
}
“背景”:{
“脚本”:[“background.js”],
“页面”:“my page.html”
},
“内容脚本”:[
{
“匹配项”:[“”],
“js”:[”https://code.jquery.com,https://*.cdn.jsdeliver.net/npm“]
}
],
“浏览器操作”:{
“默认图标”:“icons/page-32.png”
},
“内容安全策略”:“脚本src'self'https://*.cdn.jsdeliver.net/npm;对象src'self'”,
“权限”:[
“标签”,
“存储”
]
}
No,1)content\u security\u policy
用于自己的扩展页,如my-page.html,而content\u scripts
用于网页,2)只能在js
键中指定扩展目录/包中的本地文件。还要注意引号:每个值都应该单独引用。如果要将脚本添加到my page.html
中,则只需像在任何其他html页面中一样使用
标记即可。但是,将外部脚本加载到特权扩展上下文中是一个坏主意,因为恶意代理等很容易重定向URL。不要那样做。将脚本下载到扩展目录并使用此本地版本。