[WM] Accesskey Navigation for Kobatochan.com

Ctrl + Arrow Key navigation.

当前为 2020-07-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name [WM] Accesskey Navigation for Kobatochan.com
  3. // @namespace https://github.com/WidgetMidget/scripts-and-userstyles
  4. // @author WidgetMidget
  5. // @description Ctrl + Arrow Key navigation.
  6. // @version 2.6.7
  7. // @icon https://www.google.com/s2/favicons?domain=kobatochan.com
  8. // @supportURL https://github.com/WidgetMidget/scripts-and-userstyles/issues
  9. // @match *://*.kobatochan.com/*
  10. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
  11. // ==/UserScript==
  12.  
  13. /* globals $ */
  14.  
  15. var prvCh = function(prv){
  16. var prvId = $('div').find('a').filter(':contains("<< Previous Chapter")');
  17. if ($(prvId).attr("href") == "null") {} else {window.open($(prvId).attr("href"),"_self")}
  18. };
  19.  
  20. var nxtCh = function(nxt){
  21. var nxtId = $('div').find('a').filter(':contains("Next Chapter >>")');
  22. if ($(nxtId).attr("href") == "null") {} else {window.open($(nxtId).attr("href"),"_self")}
  23. }
  24.  
  25. var prvPg = function(prv){
  26. var prvPgId = $('div').find('a').filter(':contains("« Previous Page")');
  27. if ($(prvPgId).attr("href") == "null") {} else {window.open($(prvPgId).attr("href"),"_self")}
  28. };
  29.  
  30. var nxtPg = function(nxt){
  31. var nxtPgId = $('div').find('a').filter(':contains("Next Page »")');
  32. if ($(nxtPgId).attr("href") == "null") {} else {window.open($(nxtPgId).attr("href"),"_self")}
  33. }
  34.  
  35. document.addEventListener('keydown', function(e){
  36. if (e.ctrlKey)
  37. {
  38. switch (e.keyCode)
  39. {
  40. case 37: prvCh(-1); break;
  41. case 39: nxtCh(1); break;
  42. }
  43. }
  44.  
  45. if (e.shiftKey)
  46. {
  47. switch (e.keyCode)
  48. {
  49. case 37: prvPg(-1); break;
  50. case 39: nxtPg(1); break;
  51. }
  52. }
  53. }, false);