User:KnightMiner/common.js

function localLoad( url ) { return mw.loader.load( '//minecraft.fandom.com/index.php?title=' + url + '&action=raw&ctype=text/javascript' ); }

/** Scripts **/

// User:KnightMiner/editSummaryPresets.js // Creates a dropdown menu on edit summaries with presets if (mw.config.get('wgAction') === 'edit' || mw.config.get('wgAction') === 'submit') { var customSummaries = [ 'Revert consecutive edits by {user} ([' + '[User talk:{user}|talk]])', {	label: 'Style guide', namespaces: [0], values: [ '[' + '[MCW:STYLE#Writing|Unsourced]], please provide a [' + '[Help:Official sources|valid source]]', '[' + '[MCW:STYLE#Writing|Tutorial information in non-tutorial article]]', '[' + '[MCW:STYLE#Writing|Mod info in vanilla article]]', '[' + '[MCW:UPTODATE|Outdated information]]', '[' + '[MCW:UPTODATE|History information outside of history section]]', '[' + '[MCW:FUTURE|Content not in a development version]]', '[' + '[MCW:STYLE#Grammar|This wiki uses US English]]', '[' + '[MCW:STYLE#Capitalization|Improper capitalization]]', '[' + '[MCW:IMAGES|Improper image]]', '[' + '[MCW:STYLE#Linking|Overlinking]]', '[' + '[MCW:FEATURES#Trivia|Comparative trivia]]', '[' + '[MCW:FEATURES#Trivia|Bugs are not trivia]]' ]		},		{  label: 'Wiki rules', values: [ '[' + '[MCW:RULES#1|Rule #1]]: Violates Minecraft ToU/brand guidelines', '[' + '[MCW:RULES#2|Rule #2]]: Spam', '[' + '[MCW:RULES#2|Rule #2]]: Vandalism', '[' + '[MCW:RULES#3|Rule #3]]: Harassment/insult/ad hominem', '[' + '[MCW:RULES#4|Rule #4]]: False info/hoax', '[' + '[MCW:RULES#4|Rule #4]]: Speculation', '[' + '[MCW:RULES#5|Rule #5]]: Advertising', '[' + '[MCW:RULES#6|Rule #6]]: Fan community', '[' + '[MCW:RULES#7|Rule #7]]: Plagiarism', '[' + '[MCW:RULES#8|Rule #8]]: [' + '[MCW:Wiki Rules/Video policy|Video policy]]' ]		},		{	label: 'Talk page guidelines', namespaces: [ 4, 'talk' ], values: [ '[' + '[MCW:TALK#General|Improper talk page usage]]', '[' + "[MCW:TALK#General|Don't edit other user's comments]]", '[' + "[MCW:TALK#General|Don't edit archives]]" ]		},		{	label: 'Talk page guidelines', namespaces: [ 'main' ], values: [ '[' + '[MCW:Projects/Rewrite for Style|Rewrite for Style]]', '[' + '[MCW:Projects/Rewrite for Style|Minor rewrite]]', '[' + '[MCW:Projects/Categorization|Categorize]]', '[' + '[MCW:Projects/Categorization|Change category]]', ]		},		{	label: 'Forums', values: [ '[' + '[forum:minecraft-discussion|Go to the forums]]', '[' + '[forum:minecraft-discussion/suggestions|Go to the suggestion forums]]', '[' + '[forum:mapping-and-modding/minecraft-mods|Go to the mod forums]]', '[' + '[forum:support|Go to the support forums]]' ]		}	];	localLoad('User:KnightMiner/editSummaryPresets.js'); }

/** General fixes **/

$( function { 'use strict'; // Add a subpages link to pages if ( mw.config.get( 'wgArticleId' ) !== 0 ) {	mw.util.addPortletLink ( 'p-tb', '/Special:PrefixIndex/' + mw.config.get( 'wgRelevantPageName' ) + '/', 'Subpages', 't-subpages', 'Subpages of the article' ); }

/** Mostly direct code from User:Majr/hydra.js **/ // Modify the editing toolbar if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) > -1 ) { // modify the text of the signature button $( '#wpTextbox1' ).on( 'wikiEditor-toolbar-buildSection-main', function( event, section ) {		var sig = section.groups.insert.tools.signature;		if (sig) {			sig.action.options = {				pre: ' ' + ' '			}		}	// Add characters to the symbols insert page	} ).on( 'wikiEditor-toolbar-buildSection-characters', function (event, section) {		section.pages.symbols.characters.push( '¦', '²{', '}²' );	} ); $.when( mw.loader.using( 'ext.wikiEditor' ), $.ready ).then( function {		setTimeout( function { // Modify the text added by the signature button. $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {				section: 'advanced',				group: 'format',				tools: {					code: {						label: 'Code formatting',						type: 'button',						icon: 'https://upload.wikimedia.org/wikipedia/commons/6/62/Toolbar_code.png',						action: {							type: 'encapsulate',							options: { pre: ' ' }						}					}				}			} ); } );	} ); }

// Add 0th section edit button to first infobox which is in the 0th section var $firstInfobox = $( '.notaninfobox' ).first; if ( !$firstInfobox.prevAll( 'h1, h2, h3, h4, h5, h6' ).length ) { mw.loader.using( 'mediawiki.util', function {		var $editSection = $( ' ' ).addClass( 'mw-editsection-like' ).css( { float: 'right', lineHeight: 'inherit' } ).append( ' [ ',			$( '' ).prop( 'href', mw.util.getUrl( null, { action: 'edit', section: 0 } ) ).text( 'edit' ), ' ] '		);		$firstInfobox.find( '.infobox-title' ).prepend( $editSection ).prepend( $( ' ' ).css( {				float: 'left',				width: $editSection.outerWidth( true ),				height: $editSection.outerHeight( true )			} ) );	} ); }

});

/** Testing stuff **/