User:Psl85/common.js

mw.loader.load( '//minecraft.gamepedia.com/index.php?title=User:Majr/goToTop.js&action=raw&ctype=text/javascript' );

function getImageThumbnailURL(name, version, store, size) { var encodedName = encodeURIComponent(name.replace(/ /g, "_")); return "https://minecraft.gamepedia.com/media/minecraft.gamepedia.com/thumb/" + store + "/"		+ encodedName + "/"		+ size + "px-" + encodedName + "?version=" + version; }

function mimicIndicator(id, link, imgName, imgVersion, imgStore, title) { var encodedLink = encodeURIComponent(link.replace(/ /g, "_")); return $(" ") .attr("id", "mw-indicator-" + id) .addClass("mw-indicator") .append($("")			.attr({ "href": "/" + encodedLink, "title": title }).append($(" ") .attr({				"alt": title,				"src": getImageThumbnailURL(imgName, imgVersion, imgStore, 25),				"srcset": getImageThumbnailURL(imgName, imgVersion, imgStore, 38)					+ " 1.5x, "					+ getImageThumbnailURL(imgName, imgVersion, imgStore, 50)					+ " 2x",				"width": "25",				"height": "25"				}) )		); }

$(function {	var protectionLevel = mw.config.get("wgRestrictionEdit")[0];	if (protectionLevel === "autoconfirmed") {		mimicIndicator( "protection-semi", "Minecraft Wiki:Autoconfirmed users", "Semi-protected page lock.png", "9967a44951b07711a04093d7048aa663", "9/9b", "This page is semi-protected so that only registered users can edit it." ).appendTo($(".mw-indicators"));	} else if (protectionLevel === "directoreditprotected") {		mimicIndicator( "protection-director", "Minecraft Wiki:Directors", "Director-protected page lock.png", "017cec521e6ee47f81964c702128ca86", "8/85",			"This page is directors-only protected so that only directors can edit it." ).appendTo($(".mw-indicators"));	} else if (protectionLevel === "sysop") {		mimicIndicator( "protection-full", "Minecraft Wiki:Administrators", "Fully-protected page lock.png", "66270912f04127c6e8988323bfa3c17b", "4/49",			"This page is fully protected so that only administrators can edit it." ).appendTo($(".mw-indicators"));	} });

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(					'' +						'' +					''				); }		} );	} ); }

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=Mediawiki:Gadget-popups.js&action=raw&ctype=text/javascript');

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

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

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

mw.loader.load('//en.wikipedia.org/w/index.php?title=Mediawiki:Gadget-extlinks.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>' ); }					}				}			}		);	} } );

/* Vandal Warner, version [0.2.0]

Created and maintained by User:Huji, modified by User:Hoo man Based on Whackamole, a script written by User:Pilotguy */

var WarnVandalList, WarnVandalSig; var WarnVandalItems = []; var WarnVandalCustomItems = [];

WarnVandalItems.push( ['uw-test', 1, 'Test edit', 'Testedit'] ); WarnVandalItems.push( ['uw-vandalism', 1, 'Vandalism', 'Vandalism'] ); WarnVandalItems.push( ['uw-delete', 1, 'Removing of contents', 'remove'] ); WarnVandalItems.push( ['uw-wrong', 1, 'Wrong info', 'wrong1'] ); WarnVandalItems.push( ['user warning1', 1, 'Vandalism notice', 'uw1'] ); WarnVandalItems.push( ['user warning2', 1, 'Vandalism caution', 'uw2'] ); WarnVandalItems.push( ['user warning3', 1, 'Vandalism warning', 'uw3'] ); WarnVandalItems.push( ['user warning4', 1, 'Final vandalism warning', 'uw4'] ); WarnVandalItems.push( ['blocked', 2, 'Blocked', 'Blocked'] ); WarnVandalItems.push( ['Welcome', 0, 'Welcome to Minecraft Wiki', 'Welcome 1'] ); WarnVandalItems.push( ['Welcome-anon', 0, 'Welcome to Minecraft Wiki (Anon)', 'Welcome 2'] ); WarnVandalItems.push( ['Welcome-vanda', 0, 'Welcome to Minecraft Wiki', 'Welcome vandal'] );

function WarnVandal (message, param, summary) { var tbox = document.getElementById('wpTextbox1'); var a = "" + (window.getSelection ? window.getSelection    : document.getSelection ? document.getSelection        : document.selection.createRange.text); if (param != "") { a = prompt ("Article name?\n(Empty+OK for a generic message.)\n(Cancel now aborts.)", a); if (a == null) return; if (a != null && a != "") { message = message.replace(/\|/,"|"+a); summary += " in " + a + ""; } else { message = param; }  }   if (WarnVandalSig == undefined) { WarnVandalSig = " " + "\n"; }  document.getElementById('wpTextbox1').value += message + WarnVandalSig; document.getElementById('wpSummary').value = summary; document.getElementById('wpMinoredit').checked=false; document.getElementById('wpWatchthis').checked=false; document.getElementById('wpTextbox1').focus; if (document.getElementById('wpTextbox1').scrollTop || true) { document.getElementById('wpTextbox1').scrollTop = document.getElementById('wpTextbox1').scrollHeight; } } window.WarnVandal_addlilink=function(tabs, url, name, id, title, key){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); WarnVandalList.appendChild(li); if(id) { if(key && title) ta[id] = [key, title]; else if(key)    ta[id] = [key]; else if(title)  ta[id] = ['', title]; }  return li; } window.WarnVandal_addToolboxLink=function(url, name, id){ var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; WarnVandal_addlilink(tb, url, name, id); } $(document).ready( function {  if ((mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit') && mw.config.get('wgCanonicalNamespace') === 'User_talk') {    var link_div = document.createElement('div');	if(mw.config.get('skin') === 'vector') {		link_div.className = 'body';	}else{	    link_div.className = 'pBody';	}	WarnVandalList = document.createElement('ul');    link_div.appendChild(WarnVandalList);    var div = document.createElement('div');    div.setAttribute('id', 'p-vandalwarner');    var heading = document.createElement('h5');    heading.appendChild(document.createTextNode('Vandal Warner'));    div.appendChild(heading);    div.appendChild(link_div);

if (WarnVandalCustomItems.length > 0){ for (i=0; i<WarnVandalCustomItems.length; i++) { itm = WarnVandalCustomItems[i]; WarnVandal_addToolboxLink('javascript:WarnVandal ("{'+'{subst:'+itm[0]+'|}}", ' + (itm[1] ? '"{'+'{subst:'+itm[0]+'}}"' : '""') + ', ' + '"'+itm[2]+'"); void(0);', itm[3], ''); }   } else { for (i=0; i<WarnVandalItems.length; i++) { itm = WarnVandalItems[i]; WarnVandal_addToolboxLink('javascript:WarnVandal ("{'+'{subst:'+itm[0]+'|}}", ' + (itm[1] ? '"{'+'{subst:'+itm[0]+'}}"' : '""') + ', ' + '"'+itm[2]+'"); void(0);', itm[3], ''); }   }	if(mw.config.get('skin') === 'vector') { document.getElementById('mw-panel').insertBefore(div, document.getElementById('p-tb')); div.className = 'portal'; }else{ div.className = 'portlet'; var side_col = document.getElementById('column-one'); var node = document.getElementById('p-tb'); side_col.insertBefore(div, node); } } });