User:AzaToth/whackaspammer.js

// If TwinkleConfig aint exist. if( typeof( TwinkleConfig ) == 'undefined' ) { TwinkleConfig = {}; }

/** TwinkleConfig.summaryAd (string) If ad should be added or not to summary, default TWINKLE */ if( typeof( TwinkleConfig.summaryAd ) == 'undefined' ) { TwinkleConfig.summaryAd = " using TW"; }

/** TwinkleConfig.deletionSummaryAd (string) If ad should be added or not to deletion summary, default TWINKLE */ if( typeof( TwinkleConfig.deletionSummaryAd ) == 'undefined' ) { TwinkleConfig.deletionSummaryAd = " using TW"; }

function whackaspammer { mw.util.addPortletLink( 'p-cactions', "javascript:whackaspammer.callback", "whackaspammer", "tw-csd", "Whack a spammer", ""); } addOnloadHook(whackaspammer);

whackaspammer.callback = function twinklesbatchdeleteCallback { var Window = new SimpleWindow( 800, 400 ); Window.setTitle( "Whack A Spammer!" ); var form = new QuickForm( whackaspammer.callback.evaluate );

form.append( {			type: 'textarea',			name: 'reason',			label: 'Reason: '		} ); form.append( { type:'submit' } ) var result = form.render; Window.setContent( result ); Window.display; } whackaspammer.callback.evaluate = function whackaspammerCallbackEvaluate(event) {

var reason = event.target.reason.value; Status.init( event.target ); var query = { 'action': 'query', 'prop': 'info', 'intoken': 'delete', 'titles': wgPageName };

var wikipedia_api = new Wikipedia.api( 'Grabbing delete token', query, function( self ) {			var xmlDoc = self.responseXML;			var token = xmlDoc.evaluate( '//page/@deletetoken', xmlDoc, null, XPathResult.STRING_TYPE, null ).stringValue;

var query = { 'action': 'delete', 'token': token, 'title': wgPageName, 'reason': "Speedy deleted per CSD G11, was unambiguous advertising or promotion" + reason + TwinkleConfig.deletionSummaryAd };			var wikipedia_api = new Wikipedia.api( 'deleting page', query, function( self ) {} ); wikipedia_api.post;

});	wikipedia_api.post;	var query = { 		'action': 'query',		'prop': 'info',		'intoken': 'block',		'titles': wgTitle	};

var wikipedia_api = new Wikipedia.api( 'Grabbing block token', query, function( self ) {			var xmlDoc = self.responseXML;			var token = xmlDoc.evaluate( '//page/@blocktoken', xmlDoc, null, XPathResult.STRING_TYPE, null ).stringValue;

var query = { 'action': 'block', 'token': token, 'autoblock': true, 'nocreate': true, 'allowusertalk': true, 'user': wgTitle, 'reason': "Spam / advertising-only account" + reason };			var wikipedia_api = new Wikipedia.api( 'blcoking user', query, function( self ) {} ); wikipedia_api.post;

});	wikipedia_api.post; }