Last active
April 16, 2020 16:08
-
-
Save IgnoredAmbience/800b38847f881d5592e2148fbc3d4bda to your computer and use it in GitHub Desktop.
Zooniverse Transcription Keyboard Shortcuts User Script
This file contains 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
// ==UserScript== | |
// @name Zooniverse Transcription Keyboard Shortcuts | |
// @namespace https://gist.github.com/IgnoredAmbience/800b38847f881d5592e2148fbc3d4bda | |
// @updateURL https://gist.github.com/IgnoredAmbience/800b38847f881d5592e2148fbc3d4bda/raw/zooniverse.user.js | |
// @version 0.2 | |
// @description Make Zooniverse Transcription quicker to use, enter will change between value entry textboxes, pages, and jump to Done button | |
// @author Thomas Wood | |
// @match https://www.zooniverse.org/projects/*/classify | |
// @grant GM_addStyle | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
GM_addStyle(` | |
.classifier { | |
position: relative; | |
height: 100vh; | |
} | |
.subject-viewer { | |
overflow: scroll; | |
} | |
.classifier .subject { | |
max-width: 300%; | |
width: 300%; | |
max-height: 150vh; | |
} | |
.classifier > div:nth-child(2) { | |
overflow-y: scroll; | |
} | |
`); | |
const keypress = function(e) { | |
const active = document.activeElement; | |
const textareas = document.querySelectorAll('textarea'); | |
const button = document.querySelector('.task-nav > span > button'); | |
if (e.key == 'Enter' && active && active.nodeName == 'TEXTAREA') { | |
e.preventDefault(); | |
let activateNext = false; | |
for (const ta of textareas) { | |
if (activateNext) { | |
ta.focus(); | |
return; | |
} | |
if (ta === active) { | |
activateNext = true; | |
} | |
} | |
if (button.innerText == 'Next') { | |
button.click(); | |
} else if (button.innerText == 'Done') { | |
button.focus(); | |
} else { | |
console.error('dropped through button options'); | |
} | |
} | |
}; | |
document.addEventListener('keydown', keypress); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment