User:Sreejithk2000/live-edit-counter.js

///////////////// Get user details

$(document).ready(function {	if(wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk")      GetUserDetails;   });

function GetUserDetails {       // Avoid subpages if(wgTitle.indexOf("/") > -1 || wgTitle.indexOf("\\") > -1 ) return; // apiURL = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/api.php", var apiURL = "http://en.wikipedia.org/w/api.php";

var query = { action: 'query', list: 'users', ususers: wgTitle, usprop: 'editcount|groups', format: 'json' };

$.ajax({        url: apiURL,         cache: false,         dataType: 'json',         data: query,         type: 'GET',         success: function (result, status, x) {            if (!result) alert("Receive empty API response:\n" + x.responseText);

if (result.error) alert("API request failed (" + result.error.code + "): " + result.error.info);

var groups = String(result.query.users[0].groups); groups = groups.replace("*,",""); $('#firstHeading').append(" " +               " (" +  result.query.users[0].editcount + " edits. Rights: [" + groups + "])" +                " "); },        error: function (x, status, error) { alert("API request returned status " + x.status + " " + status + ". Error code is " + error); }     });

}

///////////////// End of get user details