G.E/EX Keyboard Navigation

Adds many keyboard shortcuts, such as: thumbnail navigation, quick site search.

  1. // ==UserScript==
  2. // @name G.E/EX Keyboard Navigation
  3. // @description Adds many keyboard shortcuts, such as: thumbnail navigation, quick site search.
  4. // @author Hen Tie
  5. // @homepage http://hen-tie.tumblr.com/
  6. // @namespace https://greasyfork.org/en/users/8336
  7. // @include http://g.e-hentai.org/g/*
  8. // @include https//g.e-hentai.org/g/*
  9. // @include http://exhentai.org/g/*
  10. // @include https://exhentai.org/g/*
  11. // @include http://exhentai.org/s/*
  12. // @include https://exhentai.org/s/*
  13. // @include http://g.e-hentai.org/s/*
  14. // @include https://g.e-hentai.org/s/*
  15. // @grant GM_getValue
  16. // @grant GM_setValue
  17. // @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
  18. // @icon https://i.imgur.com/RPv1X1r.png
  19. // @version 5.3
  20. // ==/UserScript==
  21. document.onkeyup = checkNumber;
  22. function checkNumber(e) {
  23. e = e || window.event;
  24. // no shortcuts while commenting
  25. if ($(e.target).is('input, textarea')) {
  26. return;
  27. }
  28. // left arrow, back page
  29. else if (e.keyCode == '37') {
  30. $('table.ptt td:first-child a').click();
  31. }
  32. // right arrow, next page
  33. else if (e.keyCode == '39') {
  34. $('table.ptt td:last-child a').click();
  35. }
  36. // d key, next page
  37. else if (e.keyCode == '68') {
  38. $('table.ptt td:last-child a').click();
  39. }
  40. // a key, back page
  41. else if (e.keyCode == '65') {
  42. $('table.ptt td:first-child a').click();
  43. }
  44. // w key, first page
  45. else if (e.keyCode == '87') {
  46. $('table.ptt td:nth-child(2) a').click();
  47. }
  48. // s key, last page
  49. else if (e.keyCode == '83') {
  50. $('table.ptt td:nth-last-child(2) a').click();
  51. }
  52. // q key, return to gallery
  53. else if (e.keyCode == '81') {
  54. $('.sb a') [0].click();
  55. }
  56. // v key, vote tag up
  57. else if (e.keyCode == '86') {
  58. $('#tagmenu_act a[onclick="tag_vote_up(); return false"]') [0].click();
  59. }
  60. // x key, vote tag down
  61. else if (e.keyCode == '88') {
  62. $('#tagmenu_act a[onclick="tag_vote_down(); return false"]') [0].click();
  63. }
  64. // f key, search all galleries
  65. else if (e.keyCode == '70') {
  66. var tagSearch = prompt('Search ' + document.location.hostname);
  67. if (tagSearch !== null) {
  68. window.location.href = '/?f_search=' + tagSearch;
  69. }
  70. }
  71. // stop browser shortcut interference
  72. else if (e.keyCode == '37' && e.metaKey || e.keyCode == '39' && e.metaKey || e.keyCode == '68' && e.metaKey || e.keyCode == '65' && e.metaKey || e.keyCode == '87' && e.metaKey || e.keyCode == '83' && e.metaKey || e.keyCode == '81' && e.metaKey || e.keyCode == '86' && e.metaKey || e.keyCode == '88' && e.metaKey || e.keyCode == '70' && e.metaKey) {
  73. return;
  74. }
  75. }