User:CharlotteWebb/editcount.js

addOnloadHook(function { a = 'Edit count';  if((wgNamespaceNumber == 2 || wgNamespaceNumber == 3)) {    document.getElementById("p-cactions").getElementsByTagName("ul")[0].innerHTML +=    '\n' + a + '';    tc = document.getElementById("t-contributions");    if(tc) tc.innerHTML += '\n' + a;    }  if(wgCanonicalSpecialPageName == "Contributions"){    cs = document.getElementById("contentSub");    cs.innerHTML = cs.innerHTML.replace(/(\))\s*$/, " | " + a + ")");    }  if(wgAction != "editcount")  return;  document.getElementsByTagName("h1")[0].innerHTML = document.title =    "Edit count of User:" + wgTitle;  (bc = document.getElementById("bodyContent")).innerHTML = "(loading...)";  var d = new Object, m = new Object, ns = new Object; d.ec = 0; d.o = null; d.q = 'action=query&list=usercontribs&ucprop=title&uclimit=500&ucuser=' + wgTitle; var scr = function(q, h){ x = new XMLHttpRequest; x.onreadystatechange = function { if (x.readyState == 4) h(new DOMParser.parseFromString(x.responseText,"text/xml")); }   x.open("GET", wgServer + "/w/api.php?" + q + "&rawcontinue=&format=xml", true); x.send(""); } var nsh = function(nf){ n = nf.getElementsByTagName("ns"); for(i = 0; i < n.length; i++){ m[id = n[i].getAttribute("id")] = 0; ns[id] = n[i].getAttribute("canonical"); }   ns["0"] = "[main]"; var ech = function(ef) { r = ef.getElementsByTagName("item"); for(i = 0; i < r.length; i++) m[r[i].getAttribute("ns")]++; d.ob = 'total edits: ' + (d.ec += r.length) + ' (and counting...)' + ' \n ');     np = ef.getElementsByTagName("query-continue");      if(!np.length) document.getElementById("ecstatus").innerHTML = "(Done!)";      else {        d.o = np[0].childNodes[0].getAttribute("ucstart");        scr(d.q + (d.o?"&ucstart="+d.o:""), ech);        }      }    scr(d.q + (d.o ? "&ucstart=" + d.o : ""), ech);    }  scr("action=query&meta=siteinfo&siprop=namespaces", nsh);  });