User:KnightMiner/hydra.js

function localLoad( url ) { return mw.loader.load( '//minecraft.gamepedia.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'); }

// User:Majr/docTabs.js // Adds Doc + Doc discussion tabs to template and module pages and // changes Template/Module + Discussion tabs to always link to the original template/module + discussion page if ( 	$.inArray( mw.config.get( 'wgNamespaceNumber' ), [ 10, 11, 274, 275, 828, 829 ] ) > -1 ||	$.inArray( mw.config.get( 'wgNamespaceNumber' ), [ 2, 3 ] ) > -1 &&	mw.config.get( 'wgTitle' ).replace( /\/doc$/, '' ).search( /\.(js|css)$/ ) > -1 ) { localLoad( 'User:Majr/docTabs.js' ); }

// User:Majr/Prism.js // Adds JavaScript, CSS and Lua syntax highlighting, see file for license // Requires a theme from http://prismjs.com to be added to usercss localLoad( 'User:Majr/Prism.js' );

// User:Majr/codeLinks.js localLoad( 'User:Majr/codeLinks.js' );

// User:Majr/renderConsoleOutput.js // Allows the output wikitext of the lua console to be rendered if ( $( '#mw-scribunto-console' ).length ) { localLoad( 'User:Majr/renderConsoleOutput.js' ); }

/** General fixes **/

$( function { 'use strict'; // Replaces the Special:Achievements tab with the Special:MyPage/Sandbox tab $('#pt-achievements a').attr({ href: '/User:' + mw.config.get( 'wgUserName' ) + '/Sandbox' }).text('Sandbox');

// Makes one of the user links my profile, and the other the userwiki $('.netbar-box.right li.user a').attr({ href: '/UserProfile:' + mw.config.get( 'wgUserName' ) }).text( 'Profile' );

// 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 **/