mic_none

User:Danski454/undo-move.js Source: en.wikipedia.org/wiki/User:Danski454/undo-move.js

( function( mw, $ ) {
	var re = /<abbr class="minoredit".+<span.+class="mw-plusminus-null mw-diff-bytes".*>\D*0\D*<\/span>.+<span class="comment.*">.+ moved page <a.+>(.+?)<\/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 );