相关疑难解决方法(0)

Chrome扩展中的"拒绝加载脚本"错误

关于SO有很多问题与此类似,但没有一个问题解决了我的目的.
我正在创造一个像chrome扩展的'pinterest'.它在网页上注入脚本,收集图像,然后将其发布到某个地方.一切都很完美,但是当我在pinterest本身运行时,它给了我这个错误:

拒绝加载脚本" https://domain_name.com/my_script.js ",因为它违反了以下内容安全策略指令:"default- src'self'https:// .pinterest.com https:// .pinimg. com*.pinterest.com*.pinimg.com*.google.com connect.facebook.net .google-analytics.com https:// .googleapis.com .gstatic.com https:// .facebook.com*.facebook .com www.googleadservices.com googleads.g.doubleclick.net platform.twitter.com*.tiles.mapbox.com*.online-metrix.net*.bnc.lt bnc.lt*.yozio.com'unsafe-inline ''不安全评估'".请注意,'script-src'未明确设置,因此'default-src'用作后备.


我知道这有很多事情Content Script Policy(我不太了解它)但是,我按照这个这个链接给了我足够的信息,什么是CSP以及如何使用它.
我已经完成了所需的一切(我认为),但它仍然无效.这是我的manifest.json

{
  "manifest_version": 2,

  "name": "Image Posting",
  "description": "This extension enables you to post images",
  "version": "1.0",

  "browser_action": {
    "name": "Image Posting"
  },
  "homepage_url": "https://www.domain_name.com/",
  "background":{
      "scripts":["background.js"]
  },
  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["jquery.js", "content.js"]
    }
  ],
  "icons": {
     "128": "icon_128.png",
     "16": "icon_16.png",
     "48": "icon_48.png"
  }, …
Run Code Online (Sandbox Code Playgroud)

google-chrome javascript-injection google-chrome-extension content-security-policy

3
推荐指数
2
解决办法
3017
查看次数