javascript - Brython 错误“违反以下内容安全策略指令:“script-src 'self'”“
问题描述
我正在尝试制作一个使用 Brython 将 python 合并到 html 中的谷歌扩展。当我在浏览器中运行扩展程序时,它给了我这个错误作为回报:
拒绝加载脚本“https://cdn.jsdelivr.net/npm/brython@3.10.0/brython.min.js”,因为它违反了以下内容安全策略指令:“script-src 'self'”。请注意,'script-src-elem' 没有明确设置,因此 'script-src' 用作后备。
拒绝加载脚本“https://cdn.jsdelivr.net/npm/brython@3.10.0/brython_stdlib.js”,因为它违反了以下内容安全策略指令:“script-src 'self'”。请注意,'script-src-elem' 没有明确设置,因此 'script-src' 用作后备。
我不确定该怎么办。我尝试在互联网上查看其他答案,但无法真正找到有效或有意义的解决方案。
我将在下面附上我的扩展程序的相关代码。(如果您好奇,本教程之后会遵循扩展名:https ://developer.chrome.com/docs/extensions/mv3/getstarted/ 。它所做的只是改变网页的背景。但我测试 Brython 在一个更大的项目中的能力,该项目将包含文字处理、网络抓取和 sci-kit 学习。
清单.json
"name": "Getting Started Example 2",
"description": "Build an Extension!",
"version": "1.0",
"manifest_version": 3,
"background": {
"service_worker": "background.js"
},
"options_page": "options.html",
"permissions": ["storage", "activeTab", "scripting", "pageCapture"],
"action": {
"default_popup": "popup.html",
"default_icon": {
"16": "/images/get_started16.png",
"32": "/images/get_started32.png",
"48": "/images/get_started48.png",
"128": "/images/get_started128.png"
}
},
"icons": {
"16": "/images/get_started16.png",
"32": "/images/get_started32.png",
"48": "/images/get_started48.png",
"128": "/images/get_started128.png"
}
}
选项.html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="button.css">
<script type="text/javascript"
src="https://cdn.jsdelivr.net/npm/brython@3.10.0/brython.min.js">
</script>
<script type="text/javascript"
src="https://cdn.jsdelivr.net/npm/brython@3.10.0/brython_stdlib.js">
</script>
</head>
<body onload="brython()">
<div id="buttonDiv">
</div>
<div>
<p>Choose a different background color!</p>
</div>
</body>
<script src="options.js"></script>
</html>
我通常做后端编码而不是前端的东西,如果答案很简单,很抱歉。如果您需要我澄清任何事情,请告诉我。任何帮助将不胜感激!
解决方案
推荐阅读
- applescript - applescript 按进程 ID 退出应用程序
- powershell - Powershell弹出用户名列表
- c++ - constexpr 参数化函数指针
- css - 换行后将弹性框内容居中
- c# - 如何在 WPF 中使用带有动态视图的选项卡控件创建动态选项卡
- spring - 优先考虑 SFTP 远程目录
- go - 如何在 go-micro 中设置 broker.SubscriberOptions
- python - 基于单元格内容的 Jupyter 笔记本中 matplotlib 内联图的行为
- node.js - 在nodejs中为mongo查询之外的变量赋值
- model - 根据 RFC3264 在 sip 中提供/应答模型