User:Danski454/undo-move.js

( function( mw, $ ) {

var re = /\D*0\D*<\/span>.+.+ moved page (.+?)<\/a> to .+/;

function convertLinks(){

var curPage = encodeURIComponent(mw.config.get('wgPageName'));

$("#pagehistory li").each(function(index){

var match = $(this).html().match(re);

if (match === null) {

return true;//not a move

}

var oldPage = match[1].replace(/ /g, "_");

oldPage = encodeURIComponent(oldPage);

var url = "https://en.wikipedia.org/w/index.php?title=Special:MovePage&wpOldTitle=" + curPage + "&wpNewTitle=" + oldPage + "&wpReason=revert";

$(this).find(".mw-history-undo a").attr('href', url);

});

}

$(document).ready(function(){

if (mw.config.get('wgAction') === 'history') {

convertLinks();

}

});

} )( mediaWiki, jQuery );