User:Edward Chernenko/common.js

var api = new mw.Api, titles = [];

function findTempPages( apcontinue ) { var q = { action: 'query', list: 'allpages', apnamespace: 0, apprefix: 'Fd:', aplimit: 500 };	if ( apcontinue ) { q.apcontinue = apcontinue; }

return api.get( q ).then( function ( ret ) {		if ( !ret.query ) {			return;		}

for ( var pageinfo of ret.query.allpages ) { titles.push( pageinfo.title ); }

if ( titles.length > 1200 ) { return; }

return findTempPages( ret.continue.apcontinue ); } ); }

function createRedirects { findTempPages.then( function {		for ( var title of titles ) {			var titleWithoutPrefix = title.replace( /^Fd:/, '' );

console.log( "Going to redirect " + titleWithoutPrefix + " to " + title );

// TODO: uncomment // api.create( titleWithoutPrefix, {}, '#REDIRECT ' + title + '' ); }	} ); }