User:Zocky/Query.js

String.prototype.parseJSON = function { try { return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test( this.replace(/"(\\.|[^"\\])*"/g, ''))) &&     eval('(' + this + ')');  } catch (e) {    return false;  } };

function queryRequest(cb,what) { var x = window.XMLHttpRequest ? new XMLHttpRequest : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false; if (queryRequest.arguments.length>1 && x)  { var i=2; var url="/w/query.php?format=json&what="+what; while (i < queryRequest.arguments.length) { url=url+"&"+queryRequest.arguments[i] + "=" + queryRequest.arguments[i+1]; i+=2; }   x.onreadystatechange=function { if (x.readyState==4) return x.status==200 ? cb(x.responseText.parseJSON) : cb(false); };   x.open("GET",url,true); x.setRequestHeader('Accept','text/*'); x.send(null); } else return cb(false); }

function a(o) { if (o==false){alert('failed')}else{alert(o.meta.user.name)} }

queryRequest(a,'userinfo'); queryRequest(a,'userinfo'); queryRequest(a,'userinfo');