MediaWiki:GlobalEditcount/code.js

/** * Name:       Global edit count script * Author:     Noreplyz *             KockaAdmiralac (smaller modifications) * Description: Adds a global edit count to user's masthead. */

$(function {   if ($("#UserProfileMasthead").length === 0) {        return;    }    var i18n = {        en: "global edits"    }, lang = mw.config.get('wgUserLanguage'),    splitLang = lang.split('-')[0],    username = $("h1").text;    $.getJSON(mw.util.wikiScript('api'), { action: "query", list: "users", ususers: username, usprop: "editcount", format: "json" }, function(data) { if(data.error) { new BannerNotification("Error while fetching user edit count: " + data.error.code, 'error').show; } else if(typeof data.query.users[0].editcount !== 'undefined') { $(".tally").first.after(' ' +               mw.html.element("em", { id: "globaleditcount" }, data.query.users[0].editcount.toString.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")) +                mw.html.element("span", null, i18n[i18n[lang] ? lang : i18n[splitLang] ? splitLang : 'en']) +           ' '); }       $("#globaleditcount").click(function {            window.location.href = "/wiki/Special:Editcount/" + username;        }); }); });