Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/**
 * Script that adds several global sysop delete and block reasons to action=delete and Special:Block forms
 * 
 * Reasons provided by Mathonius and Trijnstel
 * Rewritten by [[User:Hoo man]]
 *
 * <nowiki>
 */

/* global mw, $ */

$( document ).ready( function() {
	'use strict';

	if ( mw.config.get( 'wgAction' ) !== 'delete' && mw.config.get( 'wgCanonicalSpecialPageName' ) !== 'Block' ) {
		return;
	}

	// Creates the html for a <optgroup> containing the given reasons
	function constructOptgroup( reasons ) {
		var html = '<optgroup label="Global sysop reasons">';

		for ( var i = 0; i<reasons.length; i++ ) {
			html += mw.html.element( 'option', { 'value' : reasons[i] }, reasons[i] );
		}
		html += '</optgroup>';

		return html;
	}

	// Reasons for both delete and block
	var additionalReasons = [
		"Spam ([[m:GS|global sysop]] action)",
		"Vandalism ([[m:GS|global sysop]] action)",
	];
	// Reasons for delete only
	var additionalDelete = 
		additionalReasons.concat( [
			"No useful content ([[m:GS|global sysop]] action)",
			"Test page ([[m:GS|global sysop]] action)",
			"Not written in this project's language ([[m:GS|global sysop]] action)",
			"Requested by the author ([[m:GS|global sysop]] action)",
			"Outside the project's scope ([[m:GS|global sysop]] action)"
		] );
	// Reasons for blocks only
	var additionalBlock =
		additionalReasons.concat( [
			"Intimidating behaviour/harassment ([[m:GS|global sysop]] action)",
			"Cross-wiki issues ([[m:GS|global sysop]] action)",
			"[[w:Open proxy|Open proxy]] ([[m:No open proxies|more info]]) ([[m:GS|global sysop]] action)",
		] );

	if ( mw.config.get( 'wgAction' ) === 'delete' ) {
		// Append reasons to action=delete
		$( '#wpDeleteReasonList' ).append( constructOptgroup( additionalDelete ) );
	} else {
		// Special:Block
		$( '#mw-input-wpReason' ).append( constructOptgroup( additionalBlock ) );
		// Unselect the block reason and put it into the "Other:" field
		$( 'form input[type=submit]' ).click( function() {
			var blockReason =  '',
				$reasonSelect = $( '#mw-input-wpReason' ),
				$reasonOther = $( '#mw-input-wpReason-other' );

			if ( $reasonSelect.val() === 'other' ) {
				return;
			}

			blockReason = $reasonSelect.val();
			if ( blockReason && $reasonOther.val() ) {
				blockReason += ': ';
			}
			blockReason += $reasonOther.val();

			$reasonOther.val( blockReason );
			$reasonSelect.val( 'other' );
		} );
	}
} );

/* </nowiki> */