Jump to content

User:Paranomia/editcount.js

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// scraped from VoA's code
function get_editcount_json(user)
{
document.getElementById('contentSub').innerHTML += '<br><strong>Grabbing edit count.' + '\n' + 'Please wait...</strong>';
gml_xmlhttp = sajax_init_object();
if (!gml_xmlhttp)
{
return;
}
var pageurl = '/w/api.php?action=query&list=users&ususers=' + escape(user) + '&usprop=editcount&format=json';
gml_xmlhttp.open("GET", pageurl, true);
gml_xmlhttp.onreadystatechange = alertcount;
gml_xmlhttp.send(null);
}
function alertcount()
{
if (gml_xmlhttp.readyState !== 4)
{
return;
}
json = gml_xmlhttp.responseText;
var obj = eval('('+json+')');
var editcount = '(username invalid)';
document.getElementById('contentSub').innerHTML += '<br><span style="color:blue;"><strong>' + obj.query.users[0].editcount + '</strong></span>';
}