User:HoodedMan/monobook.js

// -----------------------------------------------------------------------------

// XMLHttpRequest support

// -----------------------------------------------------------------------------

if (document.implementation.createDocument) {

var xmlparser = new DOMParser();

}

function XMLParse(string) {

if (document.implementation.createDocument) {

return xmlparser.parseFromString(string, "text/xml");

} else if (window.ActiveXObject) {

var xmldoc = new ActiveXObject("Microsoft.XMLDOM");

xmldoc.async = "false";

ret = xmldoc.loadXML(string);

if (!ret)

return null;

return xmldoc.documentElement;

}

return null;

}

var xmlhttp;

function HTTPClient() {

var http;

if(window.XMLHttpRequest) {

http = new XMLHttpRequest();

} else if (window.ActiveXObject) {

try {

http = new ActiveXObject("Msxml2.XMLHTTP");

} catch (e) {

try {

http = new ActiveXObject("Microsoft.XMLHTTP");

} catch (E) {

http = false;

}

}

}

return http;

}

function ipWhois()

{

var pagetitleRe=/[^:]*:\/\/en\.wikipedia\.org\/(wiki\/|w\/index\.php\?title=)([^&?]*)/;

var pageTitle = pagetitleRe.exec(decodeURI(location.href))[2].split('_').join(' ');

var ipTalkRe=/User talk:(\d\d?\d?\.\d\d?\d?\.\d\d?\d?)/;

if (ipTalkRe.exec(pageTitle))

{

var ip = ipTalkRe.exec(pageTitle);

xmlhttp = HTTPClient();

if (!xmlhttp)

{

return;

}

echo "http://ws.arin.net/cgi-bin/whois.pl?queryinput=" + ip;

xmlhttp.open("GET", "http://ws.arin.net/cgi-bin/whois.pl?queryinput=" + ip, true);

xmlhttp.onreadystatechange = ipWhois2;

xmlhttp.send(null);

alert("Pie1.");

}

}

function ipWhois2()

{

alert("Pie2.");

if (xmlhttp.readyState != 4)

{

return;

}

doc = XMLParse(xmlhttp.responseText);

}

if (window.addEventListener) window.addEventListener("load", ipWhois, false);

else if (window.attachEvent) window.attachEvent("onload", ipWhois);