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 canRollback, userGroups = mw.config.get('wgUserGroups'); $.each(['Curse', 'sysop', 'wiki_guardian'], function {	if ($.inArray(this, userGroups) > -1) {		canRollback = true;		return;	} }); if (!canRollback) { return; }

mw.loader.using(['mediawiki.util','mediawiki.api'], function {	var pageName = mw.config.get('wgPageName');	// Determine the last patrolled edit and last edit on a page	new mw.Api.get({ action: 'query', list: 'logevents', letype: 'patrol', leprop: 'details', lelimit: 1, letitle: pageName }).done(function(data) { try { var lastPatrolledID = data.query.logevents[0].patrol.cur; } catch(e) { // Nothing to rollback to			return; }		// Add a new link after .mw-history-undo $('#mw-history-compare li:first-child > .mw-history-undo').after(			' | ',			$(' ').addClass('rollback-unpatrolled').html( $('').prop('href', mw.util.getUrl(pageName, { action: 'edit', undoafter: lastPatrolledID, undo: mw.config.get('wgCurRevisionId'), summary: 'Reverted last unpatrolled edits to revision ' + lastPatrolledID })).text('revert to revision ' + lastPatrolledID) )		);	}); });

});