User:Nx/Scripts/Editcount.js

// Original script: QuickEditCounter script by pl:User:ChP94 // Updated version by User:Nx // Released under the GNU Public License (GPL) // var qec_ajax; var qec_username; var qec_niceuname;

//Function from QuickEdit 2 by ASM function qec_initAjax {  try {     if (window.XMLHttpRequest) {        qec_ajax = new XMLHttpRequest; qec_ajax.overrideMimeType('text/xml'); }

else if (window.ActiveXObject) qec_ajax = new ActiveXObject('Microsoft.XMLHTTP');

else throw 'Ajax support missing'; }

catch (e) {     return false; }

if (!qec_ajax) {     alert('Error creating ajax object'); return false; }

return true; }

function qec_onload { if(wgNamespaceNumber!=2&&wgNamespaceNumber!=3) return;

qec_initAjax; qec_username = wgPageName; qec_niceuname = wgTitle.replace(/\/.*$/, ''); qec_username = qec_username.substring(qec_username.indexOf(':') + 1); qec_username = qec_username.replace(/\/.*$/, ''); qec_username = encodeURIComponent(qec_username);

qec_ajax.onreadystatechange = qec_processResponse; qec_ajax.open('GET', wgServer+wgScriptPath+'/api.php' + '?action=query&list=allusers&format=xml&auprop=editcount&aulimit=1&aufrom=' + qec_username, true); qec_ajax.send(null); }

function qec_processResponse { if (qec_ajax.readyState != 4 || qec_ajax.status != 200) return;

var xml = qec_ajax.responseXML; var conts = document.getElementsByTagName("h1"); for(i=0;i0) { count = xml.getElementsByTagName("u")[0].getAttribute("editcount"); name = xml.getElementsByTagName("u")[0].getAttribute("name"); //api.php returns the next username if this user does not exist // if (encodeURIComponent(name.replace(/ /,'_')) != qec_username) return; if (name != qec_niceuname) return; if (typeof(count) == "undefined") count = 0; elem = document.createElement("span"); elem.style.fontSize = "8pt"; elem.style.marginLeft = "10px"; elem.style.lineHeight = "1em"; elem.innerHTML="This user has a total of "+count+" edits. "; cont.appendChild(elem); } }

addOnloadHook(qec_onload); //