I’m trying to make a simple Chrome extension that replaces all images with another one (img.jpg
).
Main folder
- clrimgs.js
- img.jpg
- manifest.json
- window.html
window.html
:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ClrImgs</title>
<script type="text/javascript" src="clrimgs.js"></script>
</head>
<body>
<button onclick="clrimgs()"></button>
</body>
</html>
clrimgs.js
:
function clrimgs(){
images = document.getElementsByTagName("img")
for(image in images){
image.src = "img.jpg";
}
}
manifest.json
:
{
"manifest_version": 3,
"name": "ClrImgs",
"description": "Description",
"version": "1.0",
"minimum_chrome_version": "46",
"content_security_policy": {
"extension_pages": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"sandbox": "..."
},
"action": {
"default_icon": "img.jpg",
"default_popup": "window.html"
}
}
When I try to reload the extension, I get this error:
‘content_security_policy.extension_pages’: Insecure CSP value
“‘unsafe-eval'” in directive ‘script-src’. Could not load manifest.
Is there any way to use MV3 and still use such code? If yes, what am I doing wrong? I have tried doing numerous things, but I keep getting an error or the other.