I’m trying to develop a Chrome extension that would automatically block every YouTube video from being displayed by overwriting the html content of the page.
The only exceptions would be specific YouTube urls that I would have whitelisted. These urls are stored and retrieved using chrome local storage.
The script works just fine when I first try to load a YouTube video, either blocking it or displaying it if it is indeed whitelisted.
However, when I whitelist a blocked url, reload the page and browse YouTube, the next videos wont be blocked, even though they should be.
When I encounter this phenomenon, reloading the page correctly applies the whitelist.
My current content_script is as such :
"content_scripts": [
{
"js": ["scripts/blocker.js"],
"matches": [
"https://www.youtube.com/watch?v=*",
"https://www.youtube.com/shorts/*"
]
}
]