- Joined
- Mar 4, 2016
- Messages
- 2,781
- Reaction score
- 5,294
- Points
- 963
- Age
- 34
- Gender
- Female
Code:
// ==UserScript==
// @name Rowan
// @version 2.0
// @description Numpad or Number keys work as keybindings, Spacebar for checkbox, Enter to Submit
// @author SarahAshlee90
// @include /^https://(www|s3)\.(mturkcontent|amazonaws)\.com/
// @grant none
// @require https://code.jquery.com/jquery-3.1.1.min.js
// ==/UserScript==
const radios = Array.from(document.querySelectorAll('[type="radio"]'));
var i = 0;
window.addEventListener("keydown", function (event) {
if(event.code === "Numpad1" || event.code === "Digit1") {
if (i < 18) {
radios[i].click();
i += 3;
radios[i].focus();
} else if (i >= 18) {
radios[i].click();
i += 6;
radios[i].focus();
}
}
if(event.code === "Numpad2" || event.code === "Digit2"){
if (i < 18) {
radios[i+1].click();
i += 3;
radios[i].focus();
} else if (i >= 18) {
radios[i+1].click();
i += 6;
radios[i].focus();
}
}
if(event.code === "Numpad3" || event.code === "Digit3"){
if (i < 18) {
radios[i+2].click();
i += 3;
radios[i].focus();
} else if (i >= 18) {
radios[i+2].click();
i += 6;
radios[i].focus();
}
}
if(event.code === "Numpad4" || event.code === "Digit4"){
if (i < 18) {
return;
} else if (i >= 18 && i <= 29) {
radios[i+3].click();
i += 6;
}
}
if(event.code === "Numpad5" || event.code === "Digit5"){
if (i < 18) {
return;
} else if ( i >= 18 && i <= 29) {
radios[i+4].click();
i += 6;
}
}
if(event.code === "Numpad6" || event.code === "Digit6"){
if (i < 18) {
return;
} else if (i >= 18 && i <= 29) {
radios[i+5].click();
i += 6;
}
}
if(event.code === "Space") {
$('input[name="hard"]').click();
}
if(event.code === "Enter" || event.code === "NumpadEnter") {
coin ();
setTimeout(function(){ $('input[id="submitButton"]').click(); }, 50);
}
});
function coin () {
var audio = document.createElement("audio");
audio.src = "http://www.superluigibros.com/downloads/sounds/GAMECUBE/SUPERMARIOSUNSHINE/WAV/coin.wav";
audio.play();
}
@CrazyCatLady Non-numpad numbers work on this version.
@themildone Numpad Enter submits on this version.