Error: Content Security Policy: The page’s settings blocked the loading of a resource

Error: Content Security Policy: The page’s settings blocked the loading of a resource

我一直在尝试将我在 jQuery/HTML 中制作的一个简单程序移动到 Firefox WebExtension 以便于部署。我得到的错误是:

Content Security Policy: The page’s settings blocked the loading of a resource at https://code.jquery.com/jquery-1.12.4.js (“script-src moz-extension://ef8f1295-1912-4912-ab2e-121053b6781a”).

我确定我只是没有正确地执行 manifest.json 文件,但我一生都不知道在哪里:

{
  "description": "Makes tasks from different underwriters uniform",
  "manifest_version": 2,
  "name": "Task Creator",
  "version": ".5",
  "permissions": [
    "http://*/*", "tabs", "https://*/*"
  ],

  "icons": {
    "48": "icons/page-48.png"
  },
  "web_accessible_resources": [
    "style/popUpStyle.css",
    "script/popUpTask.js",
    "script/logicTaskFiller.js",
    "js/autosize.js",
    "style/https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css",
    "js/https://code.jquery.com/jquery-1.12.4.js",
    "js/https://code.jquery.com/ui/1.12.1/jquery-ui.js"
  ],

  "background": {
    "scripts": ["background.js"]
  },

  "browser_action": {
    "default_icon": "icons/page-32.png"
  }
}

By default, extensions cannot load scripts, or other object resources, from the Internet。您的扩展使用的所有 CSS 和 JavaScript 内容都应该是扩展包的一部分。

(此文档来自 Chrome,但完全相同的策略适用于 Firefox WebExtensions。)

可以稍微放宽这些限制,但通常应避免这种情况——如果用户无法访问 Internet,或者如果他们落后于网络,从远程服务器加载资源将使您的扩展程序无法正常工作限制性防火墙。此外,addons.mozilla.org will not accept addons which execute remotely hosted Javascript.