User:Pcj/FixDoubleRedirects.js

a = new mw.Api; dr=[]; cr = 0; function eNR { if (cr>=dr.length) return; a.get({action:"query",titles:dr[cr].title,prop:"revisions",rvprop:"content",rvlimit:1}).done(function(data) {		for (p in data.query.pages) {			txt = data.query.pages[p].revisions[0]["*"].replace(/ /g,"_");			a.postWithToken('csrf',{action:"edit",title:dr[cr].title,text:txt.replace(dr[cr].databaseResult.tb,dr[cr].databaseResult.tc).replace(/_/g," "),summary:"Fixing double redirect",bot:1}).done(function(d){ cr++; eNR; }).fail(function(d){ console.log("could not edit "+dr[cr].title); cr++; eNR; });		}	}); } a.get({action:"query",list:"querypage",qppage:"DoubleRedirects",qplimit:5000}).done(function(data){	dr = data.query.querypage.results;	eNR; });