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);

if (!isAuthorized || wgUserName !== 'NickTheRed37' || wgUserName !== 'Ivan r' || 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');

var lastPatrolledID = new mw.Api.get({   action: 'query',    list: 'logevents',    letype: 'patrol',    leprop: 'details',    lelimit: 1,    letitle: mw.config.get('wgPageName') });

// Add the rollback link $('.mw-history-undo').after($('').addClass('rollbackUnpatrolled').prop('href', 'http://minecraft-ru.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));

});