Skip to content

Instantly share code, notes, and snippets.

@cr4m3r
Created August 8, 2016 02:21
Show Gist options
  • Save cr4m3r/6b2cd150b02591eaea0aed88dea89e1a to your computer and use it in GitHub Desktop.
Save cr4m3r/6b2cd150b02591eaea0aed88dea89e1a to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Good or bad image
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 'w' or 'up' for top, 's' or 'down' for bottom, autosubmit
// @author slothbear
// @include *.mturkcontent.com/*
// @include https://s3.amazonaws.com/mturk_bulk/*
// @require http://code.jquery.com/jquery-2.1.0.min.js
// @grant GM_log
// ==/UserScript==
// 'w' or 'up arrow' selects top option
// 's' or 'down arrow' selects bottom option
// 'enter' submits
var submitOnSelect = true; // 'true' submits on selection, 'false' doesn't
$(document).ready(function() {
window.focus();
$(document).keydown(function(e){
switch(e.which){
case 87: //w for top choice
case 68: // i for top choice
case 38: // up arrow for top choice
case 97: // keypad 1
$("input[value='good']").click();
//$("input[value='yes']").click();
submitOnSelection();
break;
case 83: // s for bottom choice
case 75: // k for bottom choice
case 40: // down arrow for bottom choice
case 98: // keypad 2
$("input[value='bad']").click();
//$("input[value='no']").click();
submitOnSelection();
break;
case 88: // x for 'not a whatever'
case 99: // keypad 3
$("input[value='not_salad']").click();
submitOnSelection();
break;
case 13: // enter for submit
submitOnSelection();
break;
default: return;
}
e.preventDefault();
});
function submitOnSelection(){
if(submitOnSelect){
$("input[value='Submit']").click();
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment