User talk:BabylonAS/Scripts/rollbackUnpatrolled.js

Fix
I need to have this script working. Matt should fix it.

Here is briefly how it works: When on a history page, the script adds a new link after the undo link in the first history entry. That link will revert all revisions to the last revision that is listed in the patrol log.

It should be normally used by whoever has rollback and patrol permissions, but I don't know how to check this, so I currently can restrict it to admins, wiki guardians, and above. For the sake of testing, however, it is restricted to me, Ivan-r, and Matt.

Currently, the new undo link isn't appearing.

– Nick the Red37 — ru.wiki moderator (talk) 15:24, 9 January 2015 (UTC)


 * The undo link wasn't appearing because you made an impossible to be true if statement. The statement is false if the username isn't equal any of those three usernames, which can never be true because the username can only be one of them.

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

});
 * (copy from the edit window, otherwise all the tabs are replaced by 8 spaces, which looks awful) –Majr ᐸ Talk Contribs 07:56, 10 January 2015 (UTC)


 * Thanks, but I don't want to edit from PC right now to test it. -_- – Nick the Red37 — ru.wiki moderator (talk) 08:28, 10 January 2015 (UTC)