Chrome 扩展清单 v3 和内联脚本

Chrome extension manifest v3 and inline scripts

构建 chrome 扩展。我需要在页面内添加脚本以重新声明预定义函数(例如 fetch())。 要加载的脚本是扩展文件的一部分。我之前所做的只是通过页面包含的标签加载脚本。现在,当我尝试时,我得到了这个:

Refused to execute inline script 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.

试图将其添加到清单中

"content_security_policy": {
  "extension_pages": "script-src 'self' 'sha256-...",
  "sandbox": "none"
}

出现错误:

Insecure CSP value "'sha256-...'" in directive 'script-src'.

和“nonce-”或“unsafe-inline”一样,它们都被命名为不安全的,我无法用这样的策略加载清单。 那么我现在应该如何处理 manifest v3?

嗯。为什么我没有得到自己?是的,我可以将这些脚本作为文件添加,而不是它们的内联内容。感谢帮助 wOxxOm

content_security_policy 的“sha-..”“nonce-..”和“unsafe-inline”解决方法在清单 3

中不再有效