It says "$ is not defined", however, the code works perfectly.
I have been trying to develop an extension, I ran into some issues when linking Jquery's CDN in my file, so I just copied the compressed code of Jquery and created a new file and linked the jquery with my extension that way. In manifest, the popup.js (which gives me an error) is defined as:
"background": {
"scripts": ["popup.js"]
},
Here is html:
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta hhtp-equiv="X-UA-Compatible" content="ie=edge">
<title>Ad ბლოკერი</title>
<link rel="stylesheet" type="text/css" href="popup.css">
<script src="jqueryCode.js" type="text/javascript"></script>
<script src="Blacklist.js"></script>
<script src="popup.js"></script>
</head>
Here is Jquery:
/*$("#checkbox").prop('checked', true);
$("#onOroff").text("ON");
document.getElementById("MyElement").classList.remove('.pauseDiv');*/
$("#checkbox").prop('checked', true);
$("#onOroff").text("ON");
$(".slider").click(function() {
if( $("#checkbox").is(":checked") ){
$("#onOroff").text("OFF");
$(".slider").css({"background-color": "#C75052"});
} else {
$("#onOroff").text("ON");
$(".slider").css({"background-color": "#50c878"});
}
}); // Switches it from On and Off
});
For some odd reason, I get an error when I upload the unpacked files to chrome as an extension, yet, it works fine. full error:
Uncaught ReferenceError: $ is not defined Context _generated_background_page.html Stack Trace popup.js:1 (anonymous function)