User:Void/testing.js: Difference between revisions
Content deleted Content added
m combine |
upd current progress |
||
(40 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
// <nowiki> |
|||
/* |
|||
if( mw.config.get('wgPageName') === 'TestWiki:Request_permissions' ) { |
|||
* Simple script designed to delete all pages added to a simple browser prompt. Currently un-tested, use at your own risk! |
|||
var headings = $('.mw-headline'), i = 0; |
|||
* You are responsible for any and all actions you take using this tool. PLEASE be careful. |
|||
for( ; i < headings.length; i++) { |
|||
*/ |
|||
if(/Status: (Open|Done)/.test(headings[i].innerText)) { |
|||
headings[i].nextSibling.lastChild.id = 'edit-' + i; |
|||
//Add link |
|||
$('#edit-' + i).before('| <a id="resp-click-' + i + '">respond</a>'); |
|||
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 reasonFor = 'Mass deleting: ' + 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 ); |
|||
} |
} |
||
for( ; i >= 0; i--) { |
|||
} ); |
|||
attach('#resp-click-' + i, i); |
|||
//Delete the pages |
|||
function massDelete ( pagesArray ) { |
|||
var pagesNum = pagesArray.length; |
|||
for ( var i = 0 ; i <= pagesNum ; ++i ) |
|||
{ |
|||
$.ajax( { |
|||
url: mw.util.wikiScript( 'api' ), |
|||
type: 'POST', |
|||
dataType: 'json', |
|||
data: { |
|||
format: 'json', |
|||
action: 'delete', |
|||
title: pagesArray[i], |
|||
reason: reasonFor, |
|||
token: mw.user.tokens.get( 'csrfToken' ), |
|||
} |
|||
} ); |
|||
} |
} |
||
alert('Everything has been deleted, please see the deletion log to review the deletions.'); |
|||
} |
} |
||
function makeResponse(num) { |
|||
console.log(num); |
|||
} |
|||
function attach(id, num) { |
|||
$(id).click(function(){makeResponse(num)}); |
|||
} |
|||
// </nowiki> |
Latest revision as of 23:11, 11 September 2017
// <nowiki>
if( mw.config.get('wgPageName') === 'TestWiki:Request_permissions' ) {
var headings = $('.mw-headline'), i = 0;
for( ; i < headings.length; i++) {
if(/Status: (Open|Done)/.test(headings[i].innerText)) {
headings[i].nextSibling.lastChild.id = 'edit-' + i;
$('#edit-' + i).before('| <a id="resp-click-' + i + '">respond</a>');
}
}
for( ; i >= 0; i--) {
attach('#resp-click-' + i, i);
}
}
function makeResponse(num) {
console.log(num);
}
function attach(id, num) {
$(id).click(function(){makeResponse(num)});
}
// </nowiki>