Skip to content

Instantly share code, notes, and snippets.

@tidusx18
Created August 10, 2017 15:34
Show Gist options
  • Save tidusx18/7808a26eb8fb25ad23a9ca81c4407b40 to your computer and use it in GitHub Desktop.
Save tidusx18/7808a26eb8fb25ad23a9ca81c4407b40 to your computer and use it in GitHub Desktop.
Use keyboard arrow left/right to go back/forward a month in Turnitin's date picker.
// ==UserScript==
// @name Turnitin Date Picker Hotkeys
// @namespace https://github.com/tidusx18
// @version 0.0.1
// @description Adds action for "Arrow Left and Right" hotkey to go back and forward a month in Turnitin's date picker.
// @match https://api.turnitin.com/t_modify_assignment.asp?*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// NOTE: Refactor with specifically targeted elements this will work with.
document.addEventListener("keydown", function(e) {
submitPage(e);
}, false);
function submitPage(e) {
if (e.keyCode === 37) {
e.preventDefault();
var backMonth = document.querySelector('.calnavleft'); // Back a month
if (backMonth) {
backMonth.click();
}
}
if (e.keyCode === 39) {
e.preventDefault();
var forwardMonth = document.querySelector('.calnavright'); // Forward a month
if (forwardMonth) {
forwardMonth.click();
}
}
}
// document.addEventListener("keydown", function(e) {
// console.log(e, e.key, e.keyCode);
// }, false);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment