Currently, I am in the process of creating a basic Chrome extension with the purpose of removing specific DOM elements from a particular website.
In my manifest.json
file:
{
"name": "example",
"version": "1.0",
"description": "example description",
"content_scripts": [
{
"matches": ["http://*/*"],
"js": ["myscript.js"]
}
],
"permissions": [
"tabs",
"http://*/*"
]
}
In my myscript.js
file:
window.onload = start;
function start()
{
var ads = document.getElementById("left_ads");
ads.parentNode.removeChild(ads);
alert("example message");
}
Currently, my script successfully removes the div id="left_ads"
when I initially load a target page. However, if I navigate to another page with a similar div id="left_ads"
, the script fails to take effect. I suspect that I may need to utilize a different event other than window.onload()
. Can anyone suggest an alternative event that I should use?