VimKeys Navigation for WeebCentral

hjkl navigation within WeebCentral's reader. <Alt-c> to show reader's settings. <Alt-g> to show page select dialog.

目前為 2025-05-04 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name VimKeys Navigation for WeebCentral
  3. // @namespace Violentmonkey Scripts
  4. // @match https://weebcentral.com/chapters/*
  5. // @grant none
  6. // @version 0.1
  7. // @author Sadist
  8. // @license MIT
  9. // @description hjkl navigation within WeebCentral's reader. <Alt-c> to show reader's settings. <Alt-g> to show page select dialog.
  10. // ==/UserScript==
  11. scrollLines = 35;
  12. ratioExp = 2.6;
  13.  
  14. document.addEventListener("keydown", (event) => {
  15. if ((event.key === 'g') && (event.altKey) && (document.activeElement.tagName != "INPUT")) {
  16. // console.log("keydown", event);
  17. document.getElementById('nav-top').querySelector('div > button:nth-child(6)').click();
  18. }
  19. });
  20. document.addEventListener("keydown", (event) => {
  21. if ((event.key === 'l') && (document.activeElement.tagName != "INPUT")) {
  22. // console.log("keydown", event);
  23. document.getElementById('nav-top').querySelector('div > button:nth-child(8)').click();
  24. }
  25. });
  26. document.addEventListener("keydown", (event) => {
  27. if ((event.key === 'h') && (document.activeElement.tagName != "INPUT")) {
  28. // console.log("keydown", event);
  29. document.getElementById('nav-top').querySelector('div > button:nth-child(4)').click();
  30. }
  31. });
  32. document.addEventListener("keydown", (event) => {
  33. if ((event.key === 'j') && (document.activeElement.tagName != "INPUT")) {
  34. // console.log("keydown", event);
  35. scrollByLines(scrollLines * Math.pow(window.devicePixelRatio, ratioExp));
  36. }
  37. });
  38. document.addEventListener("keydown", (event) => {
  39. if ((event.key === 'k') && (document.activeElement.tagName != "INPUT")) {
  40. // console.log("keydown", event);
  41. scrollByLines(-scrollLines * Math.pow(window.devicePixelRatio, ratioExp));
  42. }
  43. });
  44. document.addEventListener("keydown", (event) => {
  45. if ((event.key === 'c') && (event.altKey) && (document.activeElement.tagName != "INPUT")) {
  46. // console.log("keydown", event);
  47. preference_modal.showModal()
  48. }
  49. });