[WM] Accesskey Navigation for Kobatochan.com

Ctrl + Arrow Key navigation.

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

  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 1.5.4
  7. // @supportURL https://github.com/WidgetMidget/scripts-and-userstyles/issues
  8. // @match *://*.kobatochan.com/*
  9. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
  10. // ==/UserScript==
  11.  
  12. /* globals $ */
  13.  
  14. var prvCh = function(prv){
  15. var prvId = $('div').find('a').filter(':contains("<< Previous Chapter")');
  16. if ($(prvId).attr("href") == "null") {} else {window.open($(prvId).attr("href"),"_self")}
  17. };
  18.  
  19. var nxtCh = function(nxt){
  20. var nxtId = $('div').find('a').filter(':contains("Next Chapter >>")');
  21. if ($(nxtId).attr("href") == "null") {} else {window.open($(nxtId).attr("href"),"_self")}
  22. }
  23.  
  24. document.addEventListener('keydown', function(e){
  25. if (e.ctrlKey)
  26. {
  27. switch (e.keyCode)
  28. {
  29. case 37: prvCh(-1); break;
  30. case 39: nxtCh(1); break;
  31. }
  32. }
  33. }, false);