【发布时间】:2019-06-14 18:24:15
【问题描述】:
我正在尝试从修改您的新标签页的扩展程序中执行此 js 代码。
<script>
function myFunction() {
document.getElementById("qnote-text").innerHTML = "⭕ ";
}
</script>
但我在 chrome 控制台上总是遇到同样的错误:
Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src 'self'. Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution.
它必须是内联的。
【问题讨论】:
-
错误消息告诉你你需要做什么——提供扩展源的哈希。 developer.chrome.com/extensions/…
标签: google-chrome google-chrome-extension content-security-policy