In order to block some JavaScript that I don't want to execute when I load a page, I would like to have a Greasemonkey script that deletes everything between two HTML comment tags. For example:
<!-- sub script -->
Lines containing script elements to be removed
<!-- end sub script -->
I have previously tried removing the script elements using a sample script that was suggested to me, but it isn't working as expected. That script was this:
var script = document.querySelectorAll('script[src*="example.com"]');
for (var i = 0, len = script.length; i < len; i++) {
script[i].parentNode.removeChild(scriptscript[i]);
}
Simply put, it doesn't remove the script elements as I had hoped it would. I know that the comment elements are consistent between pages and if I could use those as the markers to begin and end a search and simply delete everything in between, I believe it would solve the problem.
Any guidance would be appreciated. To say I'm new to JavaScript would be an understatement, but I'm a quick learner.