Last active
June 26, 2019 21:36
-
-
Save cuylerstuwe/c1701d29c18e14426182c49e9b00d3b4 to your computer and use it in GitHub Desktop.
A short Javascript fragment for quickly adding the most common "click-submit-on-enter" functionality to an mTurk userscript.
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
| document.addEventListener("keyup", e => { | |
| const {key} = e; | |
| if(key === "Enter") { | |
| e.preventDefault(); | |
| const submitButton = [ | |
| document.querySelector("#submitButton"), | |
| document.querySelector("#SubmitButton"), | |
| document.querySelector("[type='submit']") | |
| ].find(el => !!el); | |
| el.click(); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment