User:Void/testing.js: Difference between revisions
Content deleted Content added
m Void moved page User:Void/massDelete.js to User:Void/testing.js without leaving a redirect: Might as well create a single testing ground for scripts |
hmm? |
||
Line 20: | Line 20: | ||
var reason = prompt( 'Why are all these pages being deleted?' ); |
var reason = prompt( 'Why are all these pages being deleted?' ); |
||
var pagesArray = pages.split('|'); //Converts pages to an array for later |
var pagesArray = pages.split('|'); //Converts pages to an array for later |
||
⚫ | |||
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. |
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 ) { |
if ( goAhead ) { |
||
Line 29: | Line 28: | ||
//Delete the pages |
//Delete the pages |
||
function massDelete ( pagesArray ) { |
function massDelete ( pagesArray ) { |
||
⚫ | |||
alert( pagesArray ); |
|||
for ( var i = 0 ; i !== pagesNum ; ++i ) |
for ( var i = 0 ; i !== pagesNum ; ++i ) |
||
{ |
{ |
Revision as of 19:22, 25 October 2016
/*
* 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 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 ) {
var pagesNum = pagesArray.length;
alert( 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' ),
}
} );
}
alert('Everything has been deleted, please see the deletion log to review the deletions.');
}