Jump to content

MediaWiki:Gadget-modrollback.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Ilmari Karonen (talk | contribs) at 16:05, 11 November 2008 (fix per talk, use sajax_init_object() from /skins-1.5/common/ajax.js for IE6 compatibility). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//
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 = b.href.split('from=')[1].split('&')[0];
                                        var cont = wgServer + wgScript + '?title=Special:Contributions/' + usr;
                                        b.href = 'javascript:void(0)';
                                        b.onclick = function() {
                                                var http = sajax_init_object();
                                                http.open('GET', oldhref, true);
                                                http.setRequestHeader("Connection", "close");
                                                http.send(null);
                                                http.onreadystatechange= function() {
                                                        window.location.href = (cont);
                                                }
                                        }
                                }
                        }
                }
        }
});
//