Я хочу добавить немного javascript-кода во всплывающее окно с расширением chrome.Я использую следующий код:
<!DOCTYPE html>
<html>
<head>
<style>
button {
height: 30px;
width: 30px;
outline: none;
}
</style>
<script type="text/javascript" src="popup.js"></script>
</head>
<body>
<button id="ShowButton"></button>
</body>
</html>
Файл popup.js находится в той же папке, что и HTML-файл.
Я получаю эту ошибку:
Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem: chrome-extension-resource:". Either the 'unsafe-inline' keyword, a hash ('sha256-n39xN31cyZtiXqcqzIa0nbASOdc/O6Jshi15mzpw5oA='), or a nonce ('nonce-...') is required to enable inline execution.
Это мой контент popup.js:
chrome.tabs.query({'active': true, 'lastFocusedWindow': true}, function (tabs) {
var url = tabs[0].url;
document.getElementById("ShowButton").value= url;
});
Это manifest.json:
{
"manifest_version": 2,
"name": "eRelatorio",
"description": "Extensão para fazer o relatorio de jogo na plataforma S**ore!",
"version": "1.0",
"author": "GoodReferee",
"browser_action": {
"default_title": "Have a good day",
"default_popup": "popup.html"
},
"icons": { "128": "icon.png" },
"chrome_url_overrides" : {
"newtab": "newtab.html"
},
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"permissions": ["activeTab","tabs"],
"permissions": [
"https://www.google.com/"
]
}
Это изображение ошибки: