Yes, Adblock Plus is the best way, if applicable.
The GM code may not fire in time to stop all damage, but - for a giggle - the working version of your code will be something like this:
// ==UserScript== // @name turn_shit_off // @namespace http://www.google.com // @include http://www.xyz.com/* // ==/UserScript== var scripts = document.getElementsByTagName('script'); for (var J = scripts.length-1; J >=0; --J) { if (/foobar\.js/i.test (scripts[J].src) ) { console.log ("Killed", scripts[J].src); scripts[J].parentNode.removeChild (scripts[J]); } } /*--- Now you have to unload any unwanted event handlers and/or timers that were set before the above code could fire. This is highly page-specific and may not be possible if anonymous functions were used. */
You will see that it actually removes the elements of the script.
But alas, changing or deleting script elements alone will not have any effect most of the time. Except, perhaps, for delayed loading / starting code (things that start onload or that have defer or async attributes).
You will not have any effect until you explicitly oppose the handlers and timers that fake JS sets, which is highly page dependent and not always possible.
Run this code to see for yourself.
source share