Repository navigation
Expand file tree
/
Copy pathcanvas_lms.user.js
More file actions
44 lines (41 loc) · 1.6 KB
/
Copy pathcanvas_lms.user.js
File metadata and controls
44 lines (41 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// ==UserScript==
// @name Canvas LMS - Keystrokes
// @namespace https://hkamran.com
// @version 1.0.3
// @description Next (Shift + N, right arrow) and previous (Shift + P, left arrow) page keystrokes
// @author H. Kamran
// @downloadUrl https://github.com/hkamran80/userscripts/raw/main/canvas_lms.user.js
// @updateUrl https://github.com/hkamran80/userscripts/raw/main/canvas_lms.user.js
// @match https://*.instructure.com/courses/*
// @grant none
// ==/UserScript==
/**
* The pagination function
* @param {Event} e The event object
*/
const pagination = (e) => {
const event = window.event ? window.event : e;
if (
document.activeElement.tagName.toLowerCase() !== "textarea" &&
document.activeElement.tagName.toLowerCase() !== "input"
) {
// Module Page Pagination
if ((event.keyCode === 78 && event.shiftKey) || event.keyCode === 39) {
// Next Page Keystroke (Shift + N, right arrow)
const next_button_element = document.querySelector(
"span.module-sequence-footer-button--next a"
);
window.location.href = next_button_element.href;
} else if
(event.keyCode === 80 && event.shiftKey) ||
event.keyCode === 37
) {
// Previous Page Keystroke (Shift + P, left arrow)
const prev_button_element = document.querySelector(
"span.module-sequence-footer-button--previous a"
);
window.location.href = prev_button_element.href;
}
}
};
document.onkeydown = pagination;