User:Lupin/fixnew.js

var fixnewVersion="Tue Sep 13 23:26:16 EDT 2005";

contribsBase='http://en.wikipedia.org/w/index.php?title=Special:Contributions&target='

var ipUserRegex=RegExp('(((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9]))');

function fixupIpText { var textNodes=getTextNodes; for (var i = 0; i < textNodes.length; i++) { var textNode=textNodes[i]; var t=textNode.nodeValue; var m=ipUserRegex.exec(t); if (m) { var ip=m[1]; var s=t.split(ipUserRegex); var n=s[0]; var a=document.createElement('A'); a.href= contribsBase + ip; a.appendChild(document.createTextNode(ip)); var newTextNode=document.createTextNode(s[5]); var element=textNode.parentNode; element.replaceChild(newTextNode, textNode); element.insertBefore(a,newTextNode); element.insertBefore(document.createTextNode(s[0]),a); } } };

function getTextNodes(element) { var ret=[]; if (!element) element = document.body; for (var c = 0; c < element.childNodes.length; c++) { if (element.childNodes[c].nodeType == 3) { ret.push(element.childNodes[c]); }   else ret=ret.concat(getTextNodes(element.childNodes[c])); } return ret; };