MediaWiki:Gadget-usurper-count.js

$(document).ready( function($) {	var $users, names;

if (	mw.config.get( 'wgPageName' ) !== 'Wikiversity:Changing_username' ||		$.inArray( 'sysop', mw.config.get( 'wgUserGroups', ['*'] ) ) === -1 ) { return; }

$users = $('.usurper').find('.user');

if ( !$users.length ) { return; }

names = $.map( $users, function( elm ) { return $.trim( $( elm ).text ); } ).join('|');

$.getJSON( mw.util.wikiScript( 'api' ), {		action: 'query',		list: 'users',		ususers: names,		usprop: 'editcount',		format: 'json'	}, function( obj ) {		var i, l, count, list, name;

if ( !obj.query || !obj.query.users ) { return; }

list = obj.query.users;

for ( i = 0, l = list.length; i < l; ++i ) { count = list[i].editcount || 0; name = list[i].name;

if ( count === 0 ) { continue; }

$users .filter( function { return $.trim( $( this ).text ) === name } ) .after( $(' ', { style:'color:#00CC00; font-weight:bold;', html: '+' + count } ) )				.after( ' ' ); }	}); });