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 roundRobin = mw.util.addPortletLink(   'p-cactions',    '#',    'roundRobin',    'pt-roundrobin',    'Swap the page titles of the current page and another.',    null );

$( roundRobin ).click( function {	var newTitle = prompt("What is the title of the other page?");	var curTitle = mw.config.get("wgPageName");	var moveReason = prompt("Why is this move being done?");	var goAhead = confirm( "Move " + curTitle + " to " + newTitle + ", with reason " + moveReason + "?" );	if (goAhead){		robinMove( newTitle, curTitle, moveReason );	} });

function robinMove ( newTitle, curTitle, moveReason ) { var robinReason = moveReason + "; moving page " + curTitle + " to existing page " + newTitle + " (see WP:SWAP)"; var useTitle = "Draft:Move/" + newTitle; $.ajax( {       url: mw.util.wikiScript( 'api' ),        type: 'POST',        dataType: 'json',        data: {            format: 'json',            action: 'move',            from: newTitle,            to: useTitle,            reason: robinReason,            movetalk: 1,            noredirect: 1,            token: mw.user.tokens.get( 'csrfToken' ),        }    } ); console.log( "Moved page " + newTitle + " to location " + useTitle ); $.ajax( {       url: mw.util.wikiScript( 'api' ),        type: 'POST',        dataType: 'json',        data: {            format: 'json',            action: 'move',            from: curTitle,            to: newTitle,            reason: robinReason,            movetalk: 1,            noredirect: 1,            token: mw.user.tokens.get( 'csrfToken' ),        }    } ); console.log( "Moved page " + curTitle + " to location " + newTitle ); $.ajax( {       url: mw.util.wikiScript( 'api' ),        type: 'POST',        dataType: 'json',        data: {            format: 'json',            action: 'move',            from: useTitle,            to: curTitle,            reason: robinReason,            movetalk: 1,            noredirect: 1,            token: mw.user.tokens.get( 'csrfToken' ),        }    } ); console.log( "Moved page " + useTitle + " to location " + curTitle ); alert("Page move completed, please be sure to update any relevant information."); }