All pastes #460864 Raw Edit

Something

public javascript v1 · immutable
#460864 ·published 2007-04-27 10:17 UTC
rendered paste body
/* vi:set et ts=4 sw=4 softtabstop=4: */info=console.info;var DOMPrototype = true;function startExtendDOM() {     if(typeof(Node) == "undefined") {        Node = { prototype: {} };        DOMPrototype = false;    }}function extendElement(n) {    for(k in Node.prototype)        n[k] = Node.prototype[k];    var oldCloneNode = n.cloneNode;    n.cloneNode = function(x) { return extendElement(oldCloneNode(x)); };    return n;}function endExtendDOM() {    if(!DOMPrototype) {        window.onload = function() {            elems = document.getElementsByTagName("*");            for(var i = 0; i < elems.length; i++)                extendElement(elems[i]);            var oldCreateElement = document.createElement;            document.createElement = function(x) { return extendElement(oldCreateElement(x)); };        };    }}/**************/ startExtendDOM();Node.prototype.foo = function() {   console.info(this.tagName);}/**************/ endExtendDOM();oldload = window.onload; window.onload = function() {  if(oldload) oldload();  h1 = document.getElementsByTagName("h1")[0];  h2 = document.createElement('h2');  h2b = h2.cloneNode(false);  h1.foo();  h2.foo();  h2b.foo();}