'Choose Subject of Homework Question'

Selection hotkeys and auto-submit for Lili Dworkin's HIT 'Choose Subject of Homework Question'

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         'Choose Subject of Homework Question'
// @version      1.0
// @description  Selection hotkeys and auto-submit for Lili Dworkin's HIT 'Choose Subject of Homework Question'
// @author       TheFrostlixen
// @include      https://www.mturkcontent.com/dynamic/*
// @match        https://www.mturk.com/mturk/accept?*
// @match        https://www.mturk.com/mturk/previewandaccept?*
// @grant        none
// @namespace    https://greasyfork.org/en/users/34060
// @require      https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js

// ==/UserScript==
var submit = true;
var $j = jQuery.noConflict(true);

// verify HIT
if ( $j('strong:homework question')) {
    // This HIT is a match for the script, so get it set up
    document.addEventListener( "keydown", key, false);
    $j("input[name='Q1Answer']").eq(5).click();
    $j("input[id='submitButton']").focus();
}

// Wait for keypress
function key(i) {
    if (i.keyCode >= 97 && i.keyCode <= 103) { // numpad 1-7
        $j("input[name='Q1Answer']").eq(i.keyCode - 97).click();
        if (submit) {
            $j("input[id='submitButton']").click();
        }
    }
    if (i.keyCode == 13) { // enter
        console.log( $j("input[id='submitButton']") );
        $j("input[id='submitButton']").click();
    }
}