Axeia Posted June 3, 2009 Share Posted June 3, 2009 Working on a greasemonkey script and I'm trying to remove the onclick from a button that's created via javascript. Greasemonkey seems to fire before the script loaded, preventing me from manipulating the button. How do I 'wait' for an external javascript to have been loaded so I can let greasemonkey do what it needs to do? Quote Link to comment Share on other sites More sharing options...
bibby Posted June 3, 2009 Share Posted June 3, 2009 greasemonkey loads last, so you can count on your loaded javascripts to be there. GM handles events a little different, as you're dealing with wrappers rather than the elements themselves. One trick that I've found is to use setTimeout to execute the function that do your business; the scope there should be the real window. setTimeout(function(){ document.getElementById('foo').onclick=function(){} }, 20); If your GM script tried to do something "illegal", it stops silently. I like to console.log (firebug) every few lines to be sure that the whole script is executed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.