I want to run some javascript code on every youtube page. But with this code it only runs if I re-upload the page. And if I just click link on youtube that goes to another youtube link, it does not work. What needs to be changed?
manifest.json
{
"manifest_version" : 2,
"name": "Remove ads",
"version": "0.1.0",
"description": "Remove ads and suggestions on youtube",
"content_scripts": [{
"matches": ["https://www.youtube.com/*"],
"js": ["content.js"]
}],
"web_accessible_resources": ["script.js"]
}
content.js
var s = document.createElement('script');
s.src = chrome.extension.getURL('script.js');
s.onload = function() {
this.remove();
};
(document.head || document.documentElement).appendChild(s);
script.js
alert("hello");