Created
May 1, 2020 05:58
-
-
Save mctrafik/d78af59bbe00ec68eab2c451b95736aa to your computer and use it in GitHub Desktop.
Zooniverse Zoo-Keeper Shortcuts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addHints() { | |
document.querySelectorAll('label.answer p').forEach((p, i) => { | |
if (p.getAttribute('data-processed')) return; | |
let hint = document.createTextNode(` (SHIFT: ${i + 1})`); | |
p.appendChild(hint); | |
p.setAttribute('data-processed', 'true'); | |
}); | |
} | |
setInterval(addHints, 1000); | |
window.addEventListener('keydown', (k) => { | |
if (!k.shiftKey) return; | |
if (k.code.indexOf('Digit') === 0) { | |
/* Actually select an option. */ | |
let numeral = k.keyCode - 48; | |
document.querySelector(`label.answer:nth-child(${numeral}) input`).click(); | |
setTimeout(() => { | |
let buttons = document.querySelectorAll('nav.task-nav button'); | |
if (!buttons.length) return; | |
buttons[buttons.length - 1].focus(); | |
}, 100); | |
} else { | |
/* Else display options */ | |
adddHints(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment