User:Void/quickLock.js

// //This tool adds two different ways to quickly block and lock a user account mw.addPortletLink(	'p-personal',	'#',	'QuickLock',	'p-quicklock',	'Quickly lock an account' );

$("p-quicklock").click(function{	var user = prompt("Enter a username:");	if( user !== mw.config.get("wgUserName") )		lock(user); });

if( mw.config.get("wgRelevantUser") && mw.config.get("wgRelevantUser") !== mw.config.get("wgUserName") ) { mw.addPortletLink(		'p-cactions',		'#',		'QuickLock',		'p-lockacc',		'Quickly lock ' + mw.config.get("wgRelevantUser")	); $("p-lockacc").click(function{		var user = mw.config.get("wgRelevantUser");		if(confirm("Lock account " + user + "?"))			lock(user);	}); }

function lock( username ) { $.ajax( {       url: mw.util.wikiScript( 'api' ),        type: 'POST',        dataType: 'json',        data: {            format: 'json',            action: 'block',            user: username,            expiry: "infinite",            nocreate: 1,            autoblock: 1,            noemail: 1,            reblock: 1,            reason: 'LTA',            token: mw.user.tokens.get( 'csrfToken' ),        }    } ).done(console.log( "Blocked user: " + username )    ).fail( function ( e, data ) {    	console.log( e.message );    	console.log( JSON.stringify( data ) );    }); $.getJSON(	//Get setglobalaccountstatus token   mw.util.wikiScript('api'),    {        format: 'json',        action: 'query',        meta: 'tokens',        type: 'setglobalaccountstatus'    }).done( function ( data ) {    	try {    		var Token = data.query.tokens.setglobalaccountstatustoken;    		//Lock account    		$.ajax( { url: mw.util.wikiScript( 'api' ), type: 'POST', dataType: 'json', data: { format: 'json', action: 'setglobalaccountstatus', user: username, locked: 'lock', reason: 'LTA', token: rightsToken, }	   	} ).done(console.log( "Locked account: " + username ) ).fail( function ( e, data ){ console.log( e.message ); console.log( JSON.stringify( data ) ); });   	}    	catch ( e ) {        	console.log( "Content request error: " + e.message );        	console.log( "Content request response: " + JSON.stringify( data ) );    	}	} ).fail( function  {	    console.log( "While getting the token, there was an AJAX error." );	} ); }

//