User:Void/testing.js

/* * Simple script designed to delete all pages added to a simple browser prompt. Currently un-tested, use at your own risk! * You are responsible for any and all actions you take using this tool. PLEASE be careful. */

//Add link var deleteLink = mw.util.addPortletLink(   'p-personal',    '#',    'Mass delete',    'pt-massdelete',    'Mass delete pages',    null,    '#pt-adminlinks' );

//Activate on link click $( deleteLink ).click( function {	var pages = prompt( 'What pages to delete?\nSeparate titles with "|"' );	var reason = prompt( 'Why are all these pages being deleted?' );	var pagesArray = pages.split('|');											//Converts pages to an array for later	var pagesNum = pagesArray.length;	var goAhead = confirm( 'Go ahead and delete: ' + pagesArray );				//Yes, I realize that this method of displaying this list is messy; no, I won't fix it.	if ( goAhead ) {		massDelete( pagesArray );	} } );

//Delete the pages function massDelete ( pagesArray ) { for ( var i = 0 ; i !== pagesNum ; ++i ) {		$.ajax( {           url: mw.util.wikiScript( 'api' ),            type: 'POST',            dataType: 'json',            data: {                format: 'json',                action: 'delete',                title: pageArray[i],                reason: "Mass deleting: " + reason,                token: mw.user.tokens.get( 'csrfToken' ),	//This token may not be correct            }        } ); }	alert('Everything has been deleted, please see the deletion log to review the deletions.'); }