User:GeorgeMoney/UserScripts/rollback mod

From Wikipedia, the free encyclopedia

//

addOnloadHook(function() {
        var ds = document.getElementsByTagName('td');
        for(var i=0; i<ds.length; i++) {
                var a = ds[i];
                if(a.className == 'diff-ntitle') {
                        var fs = a.getElementsByTagName('a');
                        for(var j=0; j<fs.length; j++) {
                                var b = fs[j];
                                if(b.firstChild.data == 'rollback') {
                                        var oldhref = ''+b.href;
                                        var usr = unescape(b.href.split('from=')[1].split('&')[0]);
                                        var cont = 'http://en.wikipedia.org/wiki/'+
                                                       'Special:Contributions/'+usr;
                                        b.href = 'javascript:void(0)';
                                        b.onclick = function() {
                                                var http = new XMLHttpRequest();
                                                http.open('GET', oldhref, true);
                                                http.setRequestHeader("Connection", "close");
                                                http.send(null);
                                                http.onreadystatechange= function() {
                                                        window.location.href = (cont);
                                                }
                                        }
                                }
                        }
                }
        }
});
//