firefox - How to override an event in Javascript whatever the library previously used to bind it? -
i'm trying greasemonkey extension firefox in order override javascript events on websites visit.
for instance, want display message when blur event has been bound window element, whatever page visit.
i thought pretty easy. harder make working on every case, because depending on library website uses, javascript events seems stored in different places.
here test have made in greasemonkey user script :
window.onload = function(event) { // handle pure js if (window.onblur) { console.log('there blur event on window element of page'); } // handle jquery if (window.jquery) { var jexpando = window[window.jquery.expando]; if (jexpando.events.blur) { console.log('there blur jquery event on window element of page'); } } }
this works on every page uses pure javascript or jquery, i'm not able catch blur events listeners of other libraries such mootools, prototype...
thus, pretty bad code, considering have handle existing javascript libraries myself , have no idea how that.
is there way event listeners bind on specific javascript object (whatever library used attached them) can override of them?
most libraries use addeventlistener, you'll want override function of own. sure keep reference original addeventlistener method events can still added.
i have example greasemonkey script here: http://userscripts.org/scripts/show/174829
it listen events , tell ones added. obviously, can modify make 'blur' events not register.
Comments
Post a Comment