我试图在带有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中做到这一点,这是解决此问题的一种方法吗?我真的不确定我在这里做什么,所以有人可以指出正确的方向吗?