1

manifest.json 中的代码:

{
  "name": "Test",
  "version": "1.0",
  "manifest_version": 2,
  "description": "Test",
  "browser_action": {
      "default_icon": "icon.png",
      "default_popup": "popup.html"
  },
  "permissions": [
      "notifications",
      "https://www.roblox.com"
  ],
  "background": { "scripts": ["background.js"] },
  "content_security_policy": "script-src https://www.roblox.com 'self' ; object-src 'self'",
  "web_accessible_resources": [
    "icon.png"
  ]
}

background.js 中的代码:

var iframe = document.createElement("iframe")
iframe.src = "http://www.roblox.com/User.aspx?ID=1"

document.body.appendChild(iframe)

我不断收到此错误:

Unsafe JavaScript attempt to access frame with URL chrome-extension://dbekkpdpdheclekbpajgigjdlpleolgd/_generated_background_page.html from frame with URL http://www.roblox.com/User.aspx?ID=1. The frame requesting access has a protocol of 'http', the frame being accessed has a protocol of 'chrome-extension'. Protocols must match.

有没有什么办法解决这一问题?

4

1 回答 1

1

您的代码中的问题是您的http://www.roblox.com/*来源不安全。Chrome 错误消息的白名单仅安全资源部分指的是这个。您必须使用https://www.roblox.com/*并声明

"content_security_policy": "script-src https://roblox.com 'self' ; object-src 'self'"

在清单文件中。我观察到您的域正在通过

http://www.roblox.com/Ads/IFrameAdContent.aspx?v=2&slot=Roblox_User_Top_728x90&format=banner&v=2

httpURL,未列入白名单。

进一步阅读的参考资料

于 2013-01-12T13:13:24.073 回答