Localize.drupal.org, a bad guy and The Holy Hammer

At the last Drupal Czech Translators Meetup we realized, that we had cuckoo in our translators group. Someone, apparently not Czech, uploaded to the localize.drupal.org translation server more than 3000 suggestions, which were only rough machine translations. Some of the machine generated suggestions were right, but it was only 1 hit from 10 or 20 shots... :-(

We were thinking how to remove all his suggestions as they were priceless and only makes the approval process harder. Unfortunetaly Localization server module which is used for community translation doesn't have any features which can be used for this kind of batch wipe operation. So I decided to make a bookmarklet - a script which automatically declines all suggestions from some bad user or spammer.

And here it is... a source code of the mighty Holy Hammer:

/**
 * Holy Hammer - A machine gun for translation moderators at localize.drupal.org 
 * Author: Vojtech Kusy - www.vojtechkusy.com 
 * Version: 1.1 - 20.5.2010
 */
var badAuthor = '';
var results = document.cookie.match ( '(^|;) ?hammeredauthor=([^;]*)(;|$)' );
if (results) badAuthor = (unescape(results[2]));
badAuthor = prompt('Enter name of author to be hammered:', badAuthor);
document.cookie = "hammeredauthor=" + badAuthor; 
$('.translation.is-declinable.filter-match').each( function(){
	var author = $('div.author a', this).text();
	if (author == badAuthor) {
		$('li.declined label input', this).attr('checked', 1).change();
	}
});
void($('#edit-submit-1').click());

Note that I'm using jQuery in the script. It is possible because translation server loads it during page load, so it is ready to use when you hit bookmarklet in your favorites toolbar.

Workflow is following:

  1. Use Localize interface and filter only suggestions from a "bad" user.
  2. Click on the bookmarklet in your browser toolbar. A prompt box appears asking the name of the "bad" user.
  3. If you fill it before, last value is offered as default (value is stored in the cookie).
  4. After you hit Ok, script automatically declines all suggestions from that user on the current page.
  5. Continue on the next page... and hammer'em all! Woo ha ha ha

The bookmarklet is here: Add this link - Holly Hammer - to your favorites bookmarks toolbar and name it Holy Hammer (or Witches' Hammer ?)

Please, use this bookmarklet with care, remember that this script is Holy. Discuss it with other translation moderators in your group before you are going to use it.