User:Blue-Haired Lawyer/watchlist undo.js

/* add undo links to my watchlist */ function transFormAddress(url) { var arr = url.split('?'); var base = arr.shift; var rest = arr.join('?') var query = rest.split('&');

var params = {}; for(var h=0; h < query.length; h++) { var x = query[h].split('=');

params[x[0]] = x[1]; }	return base + '?title=' + params['title'] + '&action=edit&undoafter=' + params['oldid'] + '&undo=' + params['diff'];

}

function cycleThroughLinks { var lis = document.querySelectorAll("UL.special LI"); for(var i=0; i < lis.length; i++) { var url = lis[i].getElementsByTagName('A')[0].href.replace('&amp;', '&') var nlink = document.createElement('A'); nlink.href = transFormAddress(url); nlink.appendChild(document.createTextNode('undo')); var nspan = document.createElement('SPAN'); nspan.appendChild(document.createTextNode(' ('));		nspan.appendChild(nlink);		nspan.appendChild(document.createTextNode(')')); lis[i].appendChild(nspan); } }

if(location.pathname == '/wiki/Special:Watchlist') { cycleThroughLinks; }