User:Psl85/common.js

mw.loader.load( '//minecraft.gamepedia.com/index.php?title=User:Majr/goToTop.js&action=raw&ctype=text/javascript' ); $( function {	'use strict';	var restrictions = mw.config.get( 'wgRestrictionEdit' );	if ( restrictions ) {		if ( restrictions.indexOf( 'sysop' ) !== -1 ) {			$( '.mw-indicators' ).prepend( '' );		} else if ( restrictions.indexOf( 'autoconfirmed' ) !== -1 ) {			$( '.mw-indicators' ).prepend( '' );		}	} } );

if ( mw.config.get( 'wgRelevantUserName' ) ) { $( function {		'use strict';		var title = 'This user or IP address is blocked from editing';		( new mw.Api ).get( { action: 'query', format: 'json', list: 'blocks', formatversion: 2, bkusers: mw.config.get( 'wgRelevantUserName' ) } ).done( function( data ) { if ( data.query.blocks.length ) { $( '.mw-indicators' ).prepend(					'' +						'' +					''				); }		} );	} ); }

/** * @source mediawiki.org/wiki/Snippets/Open_external_links_in_new_window * @version 4 */ mw.hook('wikipage.content').add(function($content) {       $content.find('a.external').each(function  { // Can't use wgServer because it can be protocol relative // Use this.href property instead of this.getAttribute('href') because the propery // is converted to a full URL (including protocol) if (this.href.indexOf(location.protocol + '//' + location.hostname) !== 0) { this.target = '_blank'; }       }); });

mw.loader.load( '//commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-HotCat.js&action=raw&ctype=text/javascript' );

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Endo999/GoogleTrans.js&action=raw&ctype=text/javascript');

mw.loader.load('//en.wikipedia.org/w/index.php?title=Mediawiki:Gadget-popups.js&action=raw&ctype=text/javascript');

/** * charinsert loader */

if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 || mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Upload' ) { mw.loader.load( 'ext.gadget.charinsert-core' ); }

$( function {    var tab, tablink;

tab = document.getElementById('ca-addsection'); if ( !tab ) { return; }

tablink = tab.getElementsByTagName('a')[0]; if ( !tablink ) { return; }

tablink.firstChild.nodeValue = '+'; if ( mw.config.get( 'skin' ) === 'monobook' ) { tablink.style.paddingLeft = ".4em"; tablink.style.paddingRight = ".4em"; } });

// This only shows alerts for things after this handler is installed of course. // Because this is a gadget, error reporting can thus be inconsistent. var originalErrorHandler = window.onerror || null; // Column and error args are optional window.onerror = function ( message, url, line, colomn, error ) { var $msg = $( ' ' ); if ( url ) { $( ' ' )			.text( url + ' at line ' + line + ': ' ) .appendTo( $msg ); }	$( ' ' )		.text( message ) .appendTo( $msg );

mw.notify( $msg, {		autoHide: true,		autoHideSeconds: 10,		tag: null,		title: 'JavaScript Error',		type: 'error'	} ); if (originalErrorHandler) { return originalErrorHandler.apply(this, arguments); } }; // unbind on leaving the page $( window ) .on( 'unload', function {		window.onerror = originalErrorHandler;	} ); $( function {	'use strict';	var v = mw.config.get;	var username = v.wgRelevantUserName;	var text = 'This user is ';	var autopatrolled = 'autopatrolled.';	var grasp = 'a GRASP member.';	var bot = 'a bot (with a bot flag).';	var sysop = 'a sysop.';	var bureaucrat = 'a bureaucrat.';	var checkuser = 'a checkuser.';	var oversight = 'an oversighter.';	var globalrollbacker = 'a global rollbacker.';	var globalbot = 'a global bot (with global bot status).';	var globalsysop = 'a global sysop.';	var wikiguardian = 'a wiki guardian.';	var height = 20;	var dfw = 200;	var dfh = 200;	var classes = 'mw-indicator gadget-groupindicator';	var id = 'mw-indicator-group-';	var indicators = $( '#content' ).children( '.mw-indicators' );	var local;	var global;	if ( username ) {		indicators.prepend( '  ' );		local = $( '.gadget-groupindicator-local' );		global = $( '.gadget-groupindicator-global' );		$.getJSON( '/w/api.php?action=query&list=users&usprop=groups&ususers=' + username + '&format=json', function ( data ) { var q = data.query; var groups; if ( q ) { groups = q.users[ 0 ].groups; if ( groups ) { if ( groups.indexOf( 'autopatrolled' ) !== -1 ) { local.append( '' ); }						if ( groups.indexOf( 'grasp' ) !== -1 ) { local.append( '' ); }						if ( groups.indexOf( 'bot' ) !== -1 ) { local.append( '' ); }						if ( groups.indexOf( 'sysop' ) !== -1 ) { local.append( '</a>' ); }						if ( groups.indexOf( 'bureaucrat' ) !== -1 ) { local.append( '<img src="//upload.wikimedia.org/wikipedia/commons/9/95/Wikipedia_bureaucrat.svg" height="' + height + '" title="' + text + bureaucrat + '"></a>' ); }						if ( groups.indexOf( 'checkuser' ) !== -1 ) { local.append( '<img src="//upload.wikimedia.org/wikipedia/commons/b/b5/Wikipedia_Checkuser.svg" height="' + height + '" title="' + text + checkuser + '"></a>' ); }						if ( groups.indexOf( 'oversight' ) !== -1 ) { local.append( '<img src="//upload.wikimedia.org/wikipedia/commons/0/06/Oversight_logo.png" height="' + height + '" title="' + text + oversight + '"></a>' ); }					}				}			}		);		$.getJSON( '/w/api.php?action=query&meta=globaluserinfo&guiprop=groups&guiuser=' + username + '&format=json', function ( data ) { var q = data.query; var groups; if ( q ) { groups = q.globaluserinfo.groups; if ( groups ) { if ( groups.indexOf( 'global-rollbacker' ) !== -1 ) { global.append( '<img src="//upload.wikimedia.org/wikipedia/commons/a/a1/Meta-Wiki_Global_rollback-2000px.png" height="' + height + '" title="' + text + globalrollbacker + '"></a>' ); }						if ( groups.indexOf( 'global-bot' ) !== -1 ) { local.append( '<img src="//upload.wikimedia.org/wikipedia/commons/0/05/Robot_icon.svg" height="' + height + '" title="' + text + globalbot + '"></a>' ); }						if ( groups.indexOf( 'global-sysop' ) !== -1 ) { global.append( '<img src="//upload.wikimedia.org/wikipedia/commons/5/57/Meta-Wiki_Global_sysop-2000px.png" height="' + height + '" title="' + text + globalsysop + '"></a>' ); }						if ( groups.indexOf( 'wikiguardian' ) !== -1 ) { global.append( '<img src="//upload.wikimedia.org/wikipedia/commons/8/81/Wikimedia-logo.svg" height="' + height + '" title="' + text + steward + '"></a>' ); }					}				}			}		);	} } );