So I am making a userscript for a website, which deletes ads. The website added a script which detects, if the ads have been taken out of the HTML. So to fix this again I want to delete the whole script, but it has no identifiers, so I have no clue how to go about it. Say I have this code:
<html>
<body>
<script>
if(hasAds) {
document.write("blah blah blah"); // Act as if this re-ads the ad onto the page
}
</script>
<div id="adsBottom">IMAGINE AD CODE HERE</div>
</body>
</html>
How could I access the script section and delete it?
id<script>is appended (i.e. if it's always added first or last in<head>) you can use its index to remove it from the DOM.document.getElementsByTagName("script")gives you an Array of scripts. Just iterate through it and locate the script using any heuristic. However, mind that deleting a script does not remove the code, functions, etc.. from the Javascript VM if it has already been loaded.