It's definitely "supported". It is your web page, you do whatever you want to with it.
I already did this to track analytics events without modifying a library but by sneaking into events.
Use the proxy pattern:
(function(proxied) {
window.alert = function() {
// do something here
return proxied.apply(this, arguments);
};
})(window.alert);
You can also bypass the call to the original function if you want (proxied)
More info here: JQuery Types #Proxy Pattern
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…