/* rights group displayer, version [0.3]
Originally based on http://en.wikipedia.org/wiki/User:Splarka/sysopdectector.js
var showUserGroupSettings = {
'IP':true,
'unregistered':true,
'registered':true,
'groups': true,
'editcount':true,
'regdate':true,
'blocked':true
};
*/
if (
( wgNamespaceNumber === 2 || wgNamespaceNumber === 3 ) &&
wgTitle.indexOf( '/' ) === -1 &&
( wgAction !== 'edit' && wgAction !== 'submit' )
) {
$( function () {
var api = new mw.Api(), $someHeading = $( 'h1, h2' ).first();
if ( !$someHeading.length ) {
return;
}
api.get( {
maxage: 3600,
list: 'users',
usprop: 'blockinfo|groups|editcount|registration',
ususers: wgTitle
} ).done( function ( data ) {
var user = data.query.users[0], settings = window.showUserGroupSettings;
api.get( {
maxage: 3600,
meta: 'globaluserinfo',
guiuser: user.name,
guiprop: 'groups'
} ).done( function ( globalData ) {
var title = 'User:' + user.name + ' ', text = ' ';
if ( user.invalid === '' ) {
if ( settings && settings.IP ) text += '[IP] ';
else title += '[invalid or IP username] ';
} else if ( user.missing === '') {
if ( settings && settings.unregistered ) text += '[doesn\'t exist] ';
else title += '[not a registered name] ';
} else {
if ( settings && settings.registered ) text += '[exists] ';
else title += '[username registered] ';
if ( user.groups ) {
if ( settings && settings.groups || !settings ) text += '[' + user.groups + '] ';
else title += '[' + user.groups + '] ';
}
if ( globalData.query.globaluserinfo.groups ) {
if ( settings && settings.groups || !settings ) {
text += '[global: ' + globalData.query.globaluserinfo.groups + '] ';
} else {
title += '[global: ' + globalData.query.globaluserinfo.groups + '] ';
}
}
if ( user.editcount ) {
if ( settings && settings.editcount ) text += '[' + user.editcount + ' edits] ';
else title += '[' + user.editcount + ' edits] ';
}
if ( user.registration ) {
if ( settings && settings.regdate ) text += '[created: ' + user.registration.split( 'T' )[0] + '] ';
else title += '[created: ' + user.registration + '] ';
}
if ( user.blockedby ) {
if ( settings && settings.blocked ) text += '[blocked] ';
else text += '[currently blocked] ';
}
}
$someHeading
.attr( 'title', title ).addClass( 'detected-userrights-heading' )
.append( $( '<span>' ).text( text ).addClass( 'detected-userrights' ) );
} );
} );
} );
}