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

Adding sharethis buttons to chrome extension popup.html

我正在尝试将 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.

这是我的会议:[​​=13=]

有没有人设法让这些按钮出现?

谢谢

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

unsafe-inline 没有效果,根据官方指南,

Up until Chrome 45, there was no mechanism for relaxing the restriction against executing inline JavaScript. In particular, setting a script policy that includes 'unsafe-inline' will have no effect.

对于 Chrome > 46,

inline scripts can be whitelisted by specifying the base64-encoded hash of the source code in the policy. This hash must be prefixed by the used hash algorithm (sha256, sha384 or sha512). See Hash usage for elements for an example.