User:Void/quickLock.js

// //This tool allows one to quickly block and lock a user account mw.loader.using( ['mediawiki.api', 'mediawiki.util', 'oojs-ui'] ).then( function {	var link = mw.util.addPortletLink( 'p-personal', '#',		'QuickLock', 'p-quicklock', 'Quickly lock an account', null, '#pt-preferences' );

var api = new mw.Api;

var userBox = new OO.ui.TextInputWidget({		value: mw.config.get( 'wgRelevantUserName' ),	});

var summary = new OO.ui.TextInputWidget({		value: 'LTA'	});

var blockC = new OO.ui.CheckboxInputWidget;

function LockProc( config ) { LockProc.super.call( this, config ); }	OO.inheritClass( LockProc, OO.ui.ProcessDialog ); LockProc.static.name = 'LockProc'; LockProc.static.title = 'Quick Lock'; LockProc.static.actions = [ {			action: 'save', label: 'Proceed', flags: [ 'primary', 'progressive' ] },		{			label: 'Cancel', flags: 'safe' }	];

LockProc.prototype.initialize = function { LockProc.super.prototype.initialize.apply( this, arguments );

this.content = new OO.ui.FieldsetLayout( {			label: 'Lock account'		} ); this.content.addItems( [			new OO.ui.FieldLayout( userBox, { label: 'Username:', align: 'inline' } ),			new OO.ui.FieldLayout( summary, { label: 'Reason:', align: 'inline' } ),			new OO.ui.FieldLayout( blockC, { label: 'Block account locally', align: 'inline' } )		] );		this.content.$element.css( 'padding', '1em' );

this.$body.append( this.content.$element ); };

LockProc.prototype.getActionProcess = function( action ) { var dialog = this; if( action ) { return new OO.ui.Process( function {				if( action == 'save' ) {					api.postWithToken( 'setglobalaccountstatus', { format: 'json', action: 'setglobalaccountstatus', user: userBox.value, locked: 'lock', reason: summary.value } );

if( blockC.isSelected ) { api.postWithToken( 'csrf', {							format: 'json',							action: 'block',							user: userBox.value,							expiry: 'infinite',							nocreate: 1,							autoblock: 1,							noemail: 1,							reblock: 1,							reason: summary.value						} ); }				}

dialog.close({					action: action				}); } );		}		return LockProc.super.prototype.getActionProcess.call( this, action );	};

LockProc.prototype.getBodyHeight = function { return this.content.$element.outerHeight( true ); };

var windowManager = new OO.ui.WindowManager; var lockProc = new LockProc({		size: 'small'	}); windowManager.addWindows( [ lockProc ] );

$( link ).click( function {		windowManager.openWindow( lockProc );	} );

$( '#bodyContent' ).append( windowManager.$element ); } ); //