canvas navigator

navigate left and right using arrow keys in canvas modules and download using command shift s

当前为 2022-12-01 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name canvas navigator
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description navigate left and right using arrow keys in canvas modules and download using command shift s
  6. // @author icycoldveins
  7. // @icon none
  8. // @grant none
  9. // @license MIT
  10. // @match *://*.instructure.com/*
  11. // @match *://*.canvas.com/*
  12. // ==/UserScript==
  13. (function () {
  14. "use strict";
  15.  
  16. // detect if text has Previos or Next
  17. // if yes, click it
  18. // if no, do nothing
  19. //using left and right arrow keys
  20. // aria-label="Previous Module Item"
  21. document.addEventListener("keydown", function (event) {
  22. if (event.key == "ArrowLeft") {
  23. if (document.querySelector("[aria-label='Previous Module Item']")) {
  24. document.querySelector("[aria-label='Previous Module Item']").click();
  25. }
  26. }
  27. if (event.key == "ArrowRight") {
  28. if (document.querySelector("[aria-label='Next Module Item']")) {
  29. document.querySelector("[aria-label='Next Module Item']").click();
  30. }
  31. }
  32. if (event.key == "s" && event.metaKey && event.shiftKey) {
  33. // download the file
  34. document.querySelector("[download='true']").click();
  35. }
  36. });
  37. })();