【发布时间】:2018-07-02 22:08:00
【问题描述】:
我们开始: 我是 google 的 chrome 扩展开发的新手,所以请多多包涵。
我有一个扩展程序,它给了我以下错误:
拒绝框架“https://api.xxx.jp/”,因为它违反了以下内容安全策略指令:“frame-src 'self' https://staticxx.facebook.com https://twitter.com https://*.twimg.com https://5415703.fls.doubleclick.net https://player.vimeo.com @ 987654326@https://www.facebook.comhttps://ton.twitter.comhttps://syndication.twitter.comhttps://vine.co推特:https://www.youtube.comhttps://platform.twitter.comhttps://upload.twitter.comhttps://s-static.ak.facebook.comhttps://4337974.fls.doubleclick.nethttps://8122179.fls.doubleclick.net987654336https://8122179.fls.doubleclick.netp>
我的 manifest.json 文件具有以下关于内容安全策略的设置:
{
"content_security_policy": "script-src 'self' https://ssl.google-analytics.com; object-src 'self'",
"manifest_version": 2,
}
在我的 content.js 文件中,我通过 iframe 标记调用 api:
<iframe src="'+url+'" name="xxxExtensionsFrame" width="380" height="' + (heightBase - 5) + '" border="0" frameborder="0" scrolling="no"></iframe>
api的url总是https形式。
- 此扩展适用于大多数网站,但在某些网站(如 https://twitter.com/?lang=en)中,它会显示一个灰色弹出框,其中包含上述错误消息。
这是我的扩展工作示例:
<video class="image-viewer horizontal" poster="https://thumb.gyazo.com/thumb/642_w/_262d5667a035ff8505079ce6994d3c3f-gif.jpg" autoplay="" playsinline="" loop="" style="max-width: 642px; max-height: 100%;"><source src="https://i.gyazo.com/90701bdda37df8282699208efaa215a5.mp4" type="video/mp4"></video>
欢迎任何帮助。
【问题讨论】:
-
@noogui 不是重复的,我检查了所有其他解决方案,但没有一个解决框架/iframe 的问题。如果您知道如何解决,请提供具体答案。
标签: google-chrome google-chrome-extension content-security-policy manifest.json