I'm trying to get my extension to automatically change all content with "views" into "Views hidden" and something similar for "watching" (live streams), but when I run the extension it seems to do nothing. I'm thinking it might have something to do with me not knowing the permissions required or some other thing, but I can't seem to figure it out. This is my first time using javascript.
manifest.json
{"manifest_version": 2,
"name": "SimplyWatch",
"description": "Simply watch YouTube videos without any views, comments, or ratings data displayed for an experience unbiased by others' opinions.",
"version": "1.0",
"author": "Diamivore",
"browser_action": {
"default_icon": "tab-icon.png",
"default_title": "SimplyWatch",
"default_popup": "popup.html"
},
"permissions": ["activeTab", "tabs"],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content.js"]
}
]
}
content.js
const text = document.querySelectorAll('h1, h2, h3, h4, h5, p, li, td, caption, a, span')
document.addEventListener("DOMContentLoaded", function(){
for (let i=0; i < text.length; i++) {
if (text[i].innerHTML.includes('views')) {
text[i].innerHTML = "Views hidden"
} else if (text[i].innerHTML.includes('watching')) {
text[i].innerHTML = "Watchers hidden"
}
}
});
Any help?