User:D4g0thur/quickeditcount.js

/* Adds an edit count link to the actions tab of the Special:Contributions page modified from User:Ais523/editcount.js */

var qecwpajax; qecwpajax = { download:function(bundle) { var x = window.XMLHttpRequest ? new XMLHttpRequest : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false; if (x) { x.onreadystatechange = function { x.readyState == 4 && qecwpajax.downloadComplete(x, bundle); };      x.open("GET", bundle.url, true); x.send(null); }    return x;    }, downloadComplete:function(x, bundle) { x.status == 200 && ( bundle.onSuccess && bundle.onSuccess(x, bundle) || true ) || ( bundle.onFailure && bundle.onFailure(x, bundle) || alert(x.statusText) ); } };

function editcount { qecwpajax.download({url:mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/query.php?what=contribcounter&' + 'titles=User:' + encodeURIComponent(document.forms[0].target.value) + '&format=xml', onSuccess:showeditcount}); }

function showeditcount(xmlreq, data) { var ec = xmlreq.responseText.split(" ")[1].split(" ")[0]; document.getElementById('ca-editcount').innerHTML = ' edit count: ' + ec + ' '; }

addOnloadHook(function {  if(wgNamespaceNumber === -1 && wgTitle == 'Contributions')     mw.util.addPortletLink('p-cactions', 'javascript:editcount', 'edit count', 'ca-editcount', 'Edit count for ' + document.forms[0].target.value); });