User:ATEMVEGETA/monobook.js

/* rollback without rights */ importScriptPage('MediaWiki:APIQuery.js', 'monchbox'); function MagicRollbacks { var list = document.getElementById(skin == 'oasis' ? 'WikiaArticle' : 'bodyContent').getElementsByTagName('li'); var api = new APIQuery; var used = {}; for(var i = 0; i < list.length; i++) { var as = list[i].getElementsByTagName('a'); if(!used[as[0].title]) { list[i].innerHTML += ' [rollback] '; used[as[0].title] = true; }           }    }    addOnloadHook(MagicRollbacks); function Rollback(page, user) { api.send(new api.Query(api, 'GET', {action: 'query', prop: 'revisions', titles: page, rvlimit: '5000', indexpageids: 1}, function(result) { var revs = result.query.pages[result.query.pageids[0]].revisions; if(revs[0].user != user) {return;} var i = 1; while(revs[i].user == revs[0].user) {i++;} api.send(new api.Query(api, 'POST', {action: 'edit', title: this.params.titles, undo: revs[i].revid, undoafter: revs[0].revid, summary: 'Reverted edits by ' + revs[0].user + ' (talk | contribs) to last version by ' + revs[i + 1].user + ''}, function(result) { var el = (skin == 'oasis' ? '#WikiaArticle' : '#bodyContent'); $(el).load(location.href + ' ' + el + ' > *', function { //stolen from AjaxRC                               MagicRollbacks;                            }); }));           }));    }