User:Splarka/sysopdectector.js

/* Sysop decrier/detector (rights group displayer), version [0.2.1] Originally from http://en.wikipedia.org/wiki/User:Splarka/sysopdectector.js Notes: * Fixed …

/* Sysop decrier/detector (rights group displayer), version [0.2.1]
Originally from http://en.wikipedia.org/wiki/User:Splarka/sysopdectector.js

Notes:
* Fixed this up to use the new API fun stuffs.
* Shows all groups now
* nstab-user isn't available in all skins, all skins have at least one h1 or h2 I believe.
* heading given class="detected-userrights-heading" and text in span class="detected-userrights"

Options:
* Now supports an option system.
* By setting a datalet true it shows in the header instead of the title.
* Note, all are assumed false if omitted. All but 'groups' are assumed false if undefined.
var showUserGroupSettings = {
	'IP':true,
	'unregistered':true,
	'registered':true,
	'groups': true,
	'editcount':true,
	'regdate':true,
	'blocked':true
};
*/

function showUserGroups() {
	var url = mw.config.get( 'wgServer' )
		+ mw.config.get( 'wgScriptPath' )
		+ '/api.php?action=query&format=json&callback=showUserGroupsCB\
&maxage=3600&smaxage=3600&usprop=blockinfo|groups|editcount|registration\
&list=users&ususers='
		+ encodeURIComponent( mw.config.get( 'wgTitle' ) );
	mw.loader.load( url );
}

function showUserGroupsCB( obj ) {
	var show = window.showUserGroupSettings || false;
	var user = obj.query && obj.query.users;
	if ( !user || !user[0] ) {
		return;
	}
	user = user[0];
	var someHeading = document.getElementsByTagName( 'h1' )[0] || document.getElementsByTagName( 'h2' )[0];
	if ( !someHeading ) {
		return;
	}

	var span = document.createElement( 'span' );
	var title = 'User:' + user.name + ' ';
	var text = ' ';

	if ( user.invalid === '' ) {
		if ( show && show.IP ) {
			text += '[IP] ';
		} else {
			title += '[invalid or IP username] ';
		}
	} else if ( user.missing === '' ) {
		if ( show && show.unregistered ) {
			text += '[doesn\'t exist] ';
		} else {
			title += '[not a registered name] ';
		}
	} else {
		if ( show && show.registered ) {
			text += '[exists] ';
		} else {
			title += '[username registered] ';
		}
		if ( user.groups ) {
			if ( show && show.groups || !show ) {
				text += '[' + user.groups + '] ';
			} else {
				title += '[' + user.groups + '] ';
			}
		}
		if ( user.editcount ) {
			if ( show && show.editcount ) {
				text += '[' + user.editcount + ' edits] ';
			} else {
				title += '[' + user.editcount + ' edits] ';
			}
		}
		if ( user.registration ) {
			if ( show && show.regdate ) {
				text += '[created: ' + user.registration.split( 'T' )[0] + '] ';
			} else {
				title += '[created: ' + user.registration + '] ';
			}
		}
		if ( user.blockedby ) {
			if ( show && show.blocked ) {
				text += '[blocked] ';
			} else {
				text += '[currently blocked] ';
			}
		}
	}

	span.setAttribute( 'class', 'detected-userrights' );
	span.appendChild( document.createTextNode( text ) );
	someHeading.appendChild( span );
	someHeading.setAttribute( 'title', title );
	someHeading.className += ' detected-userrights-heading';
}

if ( ( mw.config.get( 'wgNamespaceNumber' ) === 2 || mw.config.get( 'wgNamespaceNumber' ) === 3 ) &&
	mw.config.get( 'wgTitle' ).indexOf( '/' ) === -1 &&
	( mw.config.get( 'wgAction' ) !== 'edit' || mw.config.get( 'wgAction' ) !== 'submit' ) ) {
		$( showUserGroups );
}

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.