User:Psl631/global.js

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

/** Scripts **/

/* add pulldown menu to choose edit summary */

/* global mediaWiki, ve */

( function ( $, mw ) { // Wrap with anonymous function	var $summaryBox = $( '#wpSummary' ),		minorSummaries = [			'Spelling/grammar correction',			'Fixing style/layout errors',			'Reverting vandalism or test edit',			'Reverting unexplained content removal',			'Copyedit (minor)'		],		articleSummaries = [			'Expanding article',			'Adding/improving reference(s)',			'Adding/removing category/ies',			'Adding/removing external link(s)',			'Adding/removing wikilink(s)',			'Removing unsourced content',			'Removing linkspam per WP:EL',			'Clean up',			'Copyedit (major)'		],		nonArticleSummaries = [			'Reply',			'Comment',			'Suggestion',			'Undid vandalism',			'Added content'		],		talkPageSummaries = [			'WikiProject tagging',			'WikiProject assessment'		];

function addOptionsToDropdown( dropdown, optionTexts ) { dropdown.menu.addItems( optionTexts.map( function ( optionText ) { return new OO.ui.MenuOptionWidget( { label: optionText } ); } ) );	}

function onSummarySelect( option ) { // Save the original value of the edit summary field var editsummOriginalSummary = $summaryBox.val, canned = option.getLabel, newSummary = editsummOriginalSummary;

// Append old edit summary with space, if exists, // and last character != space if ( newSummary.length !== 0 && newSummary.charAt( newSummary.length - 1 ) !== ' ' ) { newSummary += ' '; }		newSummary += canned; $summaryBox.val( newSummary ).trigger( 'change' ); }

function insertSummaryOptions( $insertBeforeThis, dropdownWidth ) { // For convenience, add a dropdown box with some canned edit // summaries to the form. var namespace = mw.config.get( 'wgNamespaceNumber' ), dropdown = new OO.ui.DropdownWidget( {				label: 'Common edit summaries'			} ), minorDropdown = new OO.ui.DropdownWidget( {				label: 'Common minor edit summaries'			} );

dropdown.$element.css( 'width', dropdownWidth ); dropdown.menu.on( 'select', onSummarySelect );

minorDropdown.$element.css( 'width', dropdownWidth ); minorDropdown.menu.on( 'select', onSummarySelect );

addOptionsToDropdown( minorDropdown, minorSummaries );

if ( namespace === 0 ) { addOptionsToDropdown( dropdown, articleSummaries ); } else { addOptionsToDropdown( dropdown, nonArticleSummaries ); if ( namespace % 2 !== 0 && namespace !== 3 ) { addOptionsToDropdown( dropdown, talkPageSummaries ); }		}

$insertBeforeThis.before( dropdown.$element ); $insertBeforeThis.before( minorDropdown.$element ); }	// VisualEditor mw.hook( 've.saveDialog.stateChanged' ).add( function {		var target, $saveOptions;		// .ve-init-mw-viewPageTarget-saveDialog-checkboxes		if ( $( 'body' ).data( 'wppresent' ) ) { return; }		$( 'body' ).data( 'wppresent', 'true' );

target = ve.init.target; $saveOptions = target.saveDialog.$saveOptions; $summaryBox = target.saveDialog.editSummaryInput.$input; if ( !$saveOptions.length ) { return; }		insertSummaryOptions( $saveOptions ); } );	// WikiEditor	$.when( mw.loader.using( 'oojs-ui-core' ), $.ready ).then( function { var $editCheckboxes = $( '.editCheckboxes' );

// If we failed to find the editCheckboxes class if ( !$editCheckboxes.length ) { return; }		insertSummaryOptions( $editCheckboxes, '48%' ); } ); }( jQuery, mediaWiki ) ); // End wrap with anonymous function

// 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, 828, 829 ] ) > -1 ||	$.inArray( mw.config.get( 'wgNamespaceNumber' ), [ 2, 3 ] ) > -1 &&	mw.config.get( 'wgTitle' ).replace( /\/doc$/, '' ).search( /\.(js|css)$/ ) > -1 ) { mw.loader.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 mw.loader.localLoad( 'User:Majr/Prism.js' );

// User:Majr/inputCounter.js // Adds a character counter to input fields mw.loader.localLoad( 'User:Majr/inputCounter.js' );

// User:Majr/codeLinks.js mw.loader.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 ) { mw.loader.localLoad( 'User:Majr/renderConsoleOutput.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 ) { mw.loader.using( 'ext.wikiEditor.toolbar', function {

// Modify the text added by the signature button. var $button = $( '#wikiEditor-section-main > .group-insert > a[rel="signature"]' ); if ( $button.length ) { var action = $button.data( 'action' ); action.options.pre = ' ' + ' '; $button.data( 'action', action ); }

// Add an option to insert ' } }				}			}		// Add an option to insert template braces } ).wikiEditor( 'addToToolbar', { section: 'advanced', group: 'insert', tools: { sign: { label: 'Template', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/4/43/Button-template.png', action: { type: 'replace', options: { pre: '' } }				}			}		// Add characters to the symbols insert page } ).on( 'wikiEditor-toolbar-buildSection-characters', function (event, section) { section.pages.symbols.characters.push( '¦', '²{', '}²' ); } );	} ); }

// 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 ) { $firstInfobox.children( '.infobox-title' ).css( 'padding-left', 50 ).prepend(		$( ' ' ).addClass( 'mw-editsection' ).css( { float: 'right', lineHeight: 'inherit' } ).append( '[',			$( '' ).prop( 'href', '/' + mw.config.get( 'wgPageName' ) + '?action=edit&section=0' ).text( 'edit' ), ']'		)	); }

} );

/** Testing stuff **/

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

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

mw.loader.load('//meta.miraheze.org/w/index.php?title=User:Void/links.js&action=raw&ctype=text/javascript');

mw.loader.load( '//meta.miraheze.org/w/index.php?action=raw&ctype=text/javascript&title=User:Void/centralAuthLink.js' );

mw.loader.load( '//meta.miraheze.org/w/index.php?action=raw&ctype=text/javascript&title=User:Zppix/cvtToolbox.js');

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

mw.loader.load( '//meta.miraheze.org/w/index.php?action=raw&ctype=text/javascript&title=User:MacFan4000/globalBlockLink.js' );

/* Counts all your edits and saves them to a page ( http://en.wikipedia.org/wiki/User:Kanegasi/editcounter ) */ if (mw.config.get('wgTitle') === mw.config.get('wgUserName') && mw.config.get('wgNamespaceNumber') === 2) { /* begin options */

/* end options */ mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Kanegasi/editcounter.js&action=raw&ctype=text/javascript'); }

/* User:Lupin/popups.js */ window.popupDelay=1; window.popupFixDabs=true; window.popupRedlinkRemoval=true; window.popupRevertSummaryPrompt=true; window.popupStructure='menus'; window.popupFixRedirs=true; window.popupFixDabs=true; window.popupAdminLinks=true;

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

mw.loader.load('//en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=User:Writ_Keeper/Scripts/massRollback.js');/*Go to Special:contributions to make it work*/

mw.loader.load('//en.wikipedia.org/wiki/User:Writ_Keeper/Scripts/massProtect.js');/*The same as above, it's acutally mass semi-protect.*/

mw.loader.load( '//meta.miraheze.org/w/index.php?action=raw&ctype=text/javascript&title=User:MacFan4000/globalBlockLink.js' );

mw.loader.load('//en.wikipedia.org/wiki/User:Joeytje50/JWB.js/load.js');/*Go to Project:AutoWikiBrowser/Script to make it work*/

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:BrandonXLF/Invert.js&action=raw&ctype=text/javascript'); //Adds a invert link