Created
November 8, 2018 03:13
-
-
Save Strikeskids/4101ddaf2c9aed4d5b164f8c0ba352ae to your computer and use it in GitHub Desktop.
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 Gradescope Keyboard Shortcuts | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Keyboard shortcuts to make grading faster. | |
// @author Strikeskids | |
// @match https://www.gradescope.com/*grade | |
// @grant none | |
// ==/UserScript== | |
/* Shortcuts | |
* | |
* [S]croll around | |
* [E]rase | |
* [D]raw lines | |
* [T]ext comment | |
* [C]omment box | |
* [P]oint box | |
*/ | |
(function() { | |
'use strict'; | |
let buttons = null; | |
let commentBox = null; | |
let initialized = false; | |
let pointBox = null; | |
function setup() { | |
try { | |
buttons = document.querySelector('.pageViewerControls--row-top').querySelectorAll('.btnGroup')[1].children; | |
} catch (e) { | |
buttons = null; | |
} | |
commentBox = document.querySelector('.form--textArea'); | |
pointBox = document.querySelector('#pointAdjustment'); | |
initialized = buttons !== null && commentBox !== null && pointBox !== null; | |
if (!initialized) console.log('Failed to initialize', buttons, commentBox, pointBox); | |
} | |
if (document.readyState !== 'loading') setup(); | |
else document.body.addEventListener('DOMContentLoaded', setup); | |
document.body.addEventListener('keydown', (e) => { | |
if (document.querySelector('.focus-ring') || !initialized) return; | |
switch (e.code) { | |
case 'KeyE': | |
buttons[4].click(); | |
break; | |
case 'KeyS': | |
buttons[0].click(); | |
break; | |
case 'KeyT': | |
buttons[1].click(); | |
break; | |
case 'KeyD': | |
buttons[2].click(); | |
break; | |
case 'KeyC': | |
commentBox.focus(); | |
break; | |
case 'KeyP': | |
pointBox.focus(); | |
break; | |
default: return; | |
} | |
e.preventDefault(); | |
e.stopPropagation(); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment