I faced a problem where I wanted to add an onclick handler that would run prior to an already defined onclick handler in a page, as my handler was changing the lots of page state intended for the original handler to see.
node.addEventListener( event, handler, false );
would install my own callback after the already existing handler, which wouldn't do much good here.The kludge I came up with was adjusting the present node to wait for a decisecond before executing, so my greasemonkey injected hook would have ample time to do its business before it would run the original code:
var code = node.getAttribute( 'onclick' );Really ugly, but it does work. I'd love to hear of better solutions for this.
if( code )
node.setAttribute( 'onclick', 'setTimeout("' +code+ '", 100)' );