我出于学习目的编码的第一个Edge扩展不起作用,因为它会生成以下错误: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. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the 'unsafe-hashes' keyword is present.
与:."脚本-SRC ' self '' wasm-inline-intentional-rules ' http://localhost:* http://127.0.0.1:*".
该扩展应该打开一个包含法律的网站.URL由一些文本、法律代码和段落组成,这些文本通过文本字段输入.
尽管输入字段会在单击扩展图标时显示,并且我可以输入文本并单击提交按钮,但什么也没有发生.
该项目由以下文件组成:
manifest.json
{
"name": "JurSearch",
"version": "0.0.0.1",
"author": "FN",
"manifest_version": 3,
"description": "An extension to search the German laws.",
"icons": {
"16": "icons/fernglas.png"
},
"action": {
"default_popup": "popup/popup.html"
},
"permissions": [
"contextMenus",
"tabs",
"storage",
"activeTab"
],
"background": {
"service_worker": "js/background.js",
"type": "module"
}
}
popup.html
<html lang="de">
<head>
<meta charset="UTF-8" />
<title>Search</title>
</head>
<body>
<div>
<form id="form" onsubmit="return false;">
<label for="Gesetz">Legal Code:</label>
<input type="text" id="Gesetz" name="Gesetz"/><br><br>
<label for="Norm">§/Art.:</label>
<input type="text" id="Norm" name="Norm"><br><br>
<input type="submit" value="Submit" onclick="OpenSite();"/>
</form>
</div>
</body>
</html>
background.js
function OpenSite() {
let Gesetz = document.getElementById("Gesetz").value;
let Norm = document.getElementById("Norm").value;
let Web = "https://dejure.org/gesetze/";
let Site = Web.concat(Gesetz, "/", Norm, ".html");
window.open(Site, "_blank");
}
我不知道如何修复它,而且是编码新手,所以我非常感谢您的帮助.
谢谢你