MediaWiki:Gadget-globalblockoptions.js

function QuickGlobalBlock( settings ) { var globalBlockForm = document.forms[ 0 ]; var inputs = globalBlockForm.getElementsByTagName( 'input' ); for ( i = 0; i < inputs.length; i++ ) { var input = inputs[ i ], setting = settings[ input.name ];

if ( input.type == 'checkbox' ) { input.checked = setting || false; } else { input.value = setting || null; }	}	globalBlockForm.submit; }

function addGlobalBlockOptions { var options = { 'vandal: 31h (AO)': { 'wpExpiry-other': '31 hours', 'wpReason-other': 'recent vandalism', wpAnonOnly: true },		'vandal: 1w': { 'wpExpiry-other': '1 week', 'wpReason-other': 'recent vandalism', wpAnonOnly: true },		'vandal: 1m': { 'wpExpiry-other': '1 month', 'wpReason-other': 'chronic vandalism', wpAnonOnly: true },		'xwiki: 3mo': { 'wpExpiry-other': '3 months', 'wpReason-other': 'cross-wiki abuse' },		'op': { 'wpExpiry-other': '1 year', 'wpReason-other': 'Open proxy', wpAlsoLocal: true },		'vandal: 31h (hard)': { 'wpExpiry-other': '31 hours', 'wpReason-other': 'vandalism' }	};

$.each( options, function( k, obj ) {		var node = mw.util.addPortletLink( 'p-cactions', '#', k );		$( node ).on( 'click', function( e ) { e.preventDefault; QuickGlobalBlock( obj ); } );	} ); }

if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'GlobalBlock' ) { $.when(		mw.loader.using( 'mediawiki.util' ),		$.ready	).then( addGlobalBlockOptions ); }