我正在尝试在带有 brython 的 chrome 扩展中运行 python 脚本,但由于内容安全策略,我被卡住了。我能找到的唯一教程建议我设置一个这样的 html 文件:
<body onLoad="">
<iframe src="C:\\hello.py" id="frame" seamless="seamless" scrolling="no"></iframe>
</body>
但是控制台中总是会弹出一个错误说:
"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."
我的清单文件中有这一行:
"content_security_policy": "script-src 'self' 'unsafe-inline'; object-src 'self'",
但我认为它没有做任何事情,因为人们说“不安全内联”关键字已被弃用。
有没有办法在 javascript 文件中而不是在 html 中执行此操作,这是解决此问题的一种方法吗?我真的不确定我在这里做什么,所以有人可以指出我正确的方向吗?