I'm trying to somehow override the constructor of HTMLElement (specifically HTMLDivElement), so that whenever any are created by whatever means, I can run some custom logic.
Obviously this doesn't work:
HTMLDivElement.prototype.constructor = function()
{
alert('div created!');
}
Is there a way to pull this off? Even if there was a way to get some sort of event/trigger when new elements where created (ones not part of the page's source HTML), that would be helpful.
EDIT: Maybe there is something we could do with Mozilla's watch/unwatch methods to watch for a change?
I’m going to Hell for this:
document.createElement = (function (fn)
{
return function (tagName)
{
var elem = fn.call(document, tagName);
alert('just created a new ' + elem.tagName);
return elem;
};
})(document.createElement);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With