将sharethis按钮添加到chrome扩展popup.html

Adding sharethis buttons to chrome extension popup.html

本文关键字:扩展 popup html chrome sharethis 按钮 添加      更新时间:2023-09-26

我试图将sharethis按钮添加到popup.html中,出现以下错误:

Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' https://*.sharethis.com". Either the 'unsafe-inline' keyword, a hash ('sha256-9kQ6Bjy+HAjxIkWKadVLttYAH2WuOVEKCHY7pnlgMz0='), or a nonce ('nonce-...') is required to enable inline execution.

这是我的conf:"content_security_policy": "script-src 'self' 'unsafe-eval' https://*.sharethis.com; object-src 'self'"

有人设法让那些按钮出现了吗?

感谢

unsafe-eval用于放松eval函数,如setTimeout(String)setInterval(String)new Function(String)

根据官方指南,unsafe-inline不会有任何影响

直到Chrome45,还没有任何机制可以放松对执行内联JavaScript的限制。特别是,设置包含"不安全内联"的脚本策略将无效

对于铬>46,

通过在策略中指定源代码的base64编码哈希,可以将内联脚本列入白名单。此哈希必须以使用的哈希算法(sha256、sha384或sha512)为前缀。有关示例,请参阅元素的哈希用法。