[Greasemonkey] Removing a script

Stuart Langridge stuart.langridge at gmail.com
Thu Apr 14 17:49:33 EDT 2005

GM doesn't seem to allow me to remove a <script> tag from a page before that 
script is parsed. I've tried using the following userscript:

(function() {
var scr = document.getElementsByTagName('script');
for (var i=scr.length-1;i>=0;i--) {
if (scr[i].src.match(/.*\/IA_SCRIPTS\/InterAction\.js$/)) {
throw new Error("hello");

to remove a <script src="/IA_SCRIPTS/InterAction.js"> element, because that 
script contains an error (it's not an error in IE, sigh), but it doesn't 
work; the parse error in the external script appears in the JavaScript 
console _before_ the "hello" error is thrown by the userscript. Can I make 
the userscript run earlier, so that it removes the <script> element before 
it is parsed and the indicated script is loaded?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mozdev.org/pipermail/greasemonkey/attachments/20050414/d688565e/attachment-0001.htm

More information about the Greasemonkey mailing list