User:BabylonAS/Scripts/rollbackUnpatrolled.js

// Script to rollback last unpatrolled edits on a page. // WARNING: Incomplete

// Usage: // importScript('User:NickTheRed37/Scripts/rollbackToPatrolled.js');

// WARNING: Requires privileges of at least an administrator or wiki guardian $(function { 'use strict';

// Check the privileges // (wiki guardians, administrators, Curse) //var isAuthorized = (mw.config.get('wgUserGroups').indexOf('Curse') !== -1) || (mw.config.get('wgUserGroups').indexOf('sysop') !== -1) || (mw.config.get('wgUserGroups').indexOf('wiki_guardian') !== -1); // disabled for the sake of testing var isAuthorized = true;

if (!isAuthorized || mw.config.get('wgUserName') !== 'NickTheRed37' || mw.config.get('wgUserName') !== 'Ivan r' || mw.config.get('wgUserName') !== 'Majr') { return; }

// Add a new link after .mw-history-undo

mw.util.addCSS([ // Separator '.mw-history-undo::after {',   'content: "|";', '}', // Link itself '.rollbackUnpatrolled {',    'display: inline-block;',    'margin-left: .1em;', '}'].join('\n'));

// Determine the last patrolled edit and last edit on a page

var lastEditID = mw.config.get('wgCurRevisionId'); new mw.Api.get({   action: 'query',    list: 'logevents',    letype: 'patrol',    leprop: 'details',    lelimit: 1,    letitle: mw.config.get('wgPageName') }).done(function (data) {    var lastPatrolledID = data.query.logevents[0].patrol.cur;    // Add the rollback link    $('.mw-history-undo').after($('').addClass('rollbackUnpatrolled').prop('href', 'http://minecraft.gamepedia.com/index.php?title=' + mw.config.get('wgPageName') + '&action=edit&undoafter=' + lastPatrolledID + '&undo=' + lastEditID + '&summary=Reverted+last+unpatrolled+edits+to+revision+' + lastPatrolledID).val('revert to revision ' + lastPatrolledID)); });

});