MediaWiki:RollbackSpamUserContribs/code.js

function rollbackSpamUserContribs(username,reason) { Object.assign(arguments,{username: , reason: }); $.getJSON('/api.php?action=query&list=usercontribs&ucuser=' + username + '&uclimit=500&ucdir=newer&format=json', function(res) {       res.query.usercontribs.forEach(function(contrib) { contribInfo = new mw.Title(contrib.title); if(contribInfo.namespace !== 6) { $.getJSON('/api.php?action=query&prop=revisions&rvtoken=rollback&titles=' + encodeURIComponent(contrib.title) + '&rvuser=' + contrib.user + '&rvprop=ids&indexpageids&format=json',function(rev) {                   token = encodeURIComponent(rev.query.pages[rev.query.pageids[0]].revisions[0].rollbacktoken);                    $.post('/api.php?action=rollback&title=' + encodeURIComponent(contrib.title) + '&user=' + contrib.user + '&markbot&format=json&token=' + token,function(_res) { if(_res.hasOwnProperty('error')) { if(_res.error == "onlyauthor") { $.post('/api.php?action=delete&title=' + encodeURIComponent(contrib.title) + '&token=' + mw.user.tokens.get('editToken') + '&tags=apiedit&reason=' + reason); }                       }                        console.log(_res); });               });            }			else { $.post('/api.php?action=delete&title=' + contrib.title + '&token=' + mw.user.tokens.get('editToken')); }       });    }); } if(wgCanonicalSpecialPageName == 'Block' && /Spezial:Sperren\/(.*)/.test(wgPageName)) { $('.mw-ipb-conveniencelinks').append(		'|',		$('').text('Alle Bearbeitungen des Benutzers rollbacken').click(rollbackSpamUserContribs.bind(this,$('#mw-bi-target')))	); } else if(wgCanonicalSpecialPageName == 'Contributions' && /Spezial:Beiträge\/(.*)/.test(wgPageName)) { $('.chat-change-ban').after(		'|',		$('').text(' Alle Bearbeitungen des Benutzers rollbacken ').click(rollbackSpamUserContribs.bind(this,$('#mw-bi-target')))	); }