I have a social media homepage newsfeed blocker chrome extension. I want to roll out a new feature in my upcoming version where users can turn the feed of individual sites on or off in the settings menu. I have built a settings.html and a background.js file. Settings.html will be the settings page where users can turn the feeds on or off with checkboxes.
What I want the code to do: I want the home page newsfeed to hide if the user checks on the box, otherwise, I want the feed to show.
I suspect the code is not working because I need to make some changes to my manifest.json file.
The manifest file has the following (I removed private stuff with "//"
{
"manifest_version": 2,
"name": "//",
"version": "//",
"description": "//",
"author": "//",
"icons": {
"128": "//"
},
"content_scripts": [{
"html": ["settings.html"],
"js": ["jquery-3.6.0.min.js", "background.js"],
"css": ["tiktok.css", "linkedin.css", "youtube.css", "insta.css", "facebook.css", "twitter.css", "reddit.css", "settings.css"],
"matches": ["https://www.tiktok.com/*", "https://www.linkedin.com/*", "https://www.youtube.com/*", "https://www.instagram.com/*", "https://www.facebook.com/*", "https://twitter.com/*", "https://www.reddit.com/"]
}],
"background":
{
"scripts": ["jquery-3.6.0.min.js", "background.js"]
},
"browser_action": {
"default_title": "//",
"default_popup": "//"
}
}
The HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset = ”UTF-8”>
<script src="jquery-3.6.0.min.js"></script>
<script src = "background.js"></script>
<title>Settings</title>
</head>
<body class="settings">
<h1 class = "classa">Settings</h1>
<h2>Feed Blocking Preferences</h2>
<h4>Checkboxes to turn all or individual feeds on or off.</h4>
<input type="checkbox" class = "jiji" id="fbbox">//</input>
</body>
</html>
In the code below, the class "jiji" is for my input element (the checkbox) in the settings.html file. The class "tn0ko95a" is for the class that hides the homepage newsfeed on a social media website. This isn't my own class, I got this from doing 'inspect element' on the social media website.
This code works:
$(function () {
$(".tn0ko95a").hide();
});
But when I add more to this code, it does not work:
$(function () {
$(".jiji").click(function () {
if ($(this).is(":checked")) {
$(".tn0ko95a").hide();
} else {
$(".tn0ko95a").show();
}
});
});
So why is the last code not working?