Sleazy Fork is available in English.

nhentai Page Changer

Allows to change page with keyboard arrows in results /search pages

  1. // ==UserScript==
  2. // @name nhentai Page Changer
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.5.7
  5. // @description Allows to change page with keyboard arrows in results /search pages
  6. // @author You
  7. // @match https://nhentai.net/search/*
  8. // @include https://nhentai.net/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. "use strict";
  14. // Your code here...
  15. window.onkeydown = function (e) {
  16. var origURL = document.URL;
  17. var num;
  18. var prenum;
  19. var newUrl;
  20. function getNum() {
  21. var counter = 1;
  22. do {
  23. prenum = origURL.charAt(origURL.length - counter - 1);
  24. console.log(origURL);
  25. console.log("prenum: " + prenum);
  26. console.log(prenum.match(/[0-9]+/g));
  27. if (prenum.match(/[0-9]+/g)) {
  28. counter++;
  29. }
  30. } while (prenum.match(/[0-9]+/g));
  31.  
  32. return counter;
  33. }
  34.  
  35. var code = e.keyCode ? e.keyCode : e.which;
  36. if (code === 39) {
  37. //right key
  38. if (origURL.includes("page")) {
  39. if (
  40. document.URL.includes("page") &&
  41. !document.URL.charAt(document.URL.length - 1).match(/[1-9]/)
  42. ) {
  43. var regx = /(&page=[0-9]+)/g;
  44. var match;
  45. match = regx.exec(this.document.URL);
  46. var index1 = match.index;
  47. var index2 = match[0].length;
  48. this.console.log(`index 1: ${index1} y index 2: ${index2}`);
  49. this.console.log(this.document.URL.substr(index1,index2));
  50. var array1 = origURL.split(/(&page=[0-9]+)/g);
  51. this.console.log(array1);
  52. var temp = array1[2];
  53. array1[2] = array1[1];
  54. array1[1] = temp;
  55. origURL = array1.join("");
  56. }
  57. var counter = getNum();
  58. console.log("counter: " + counter);
  59. num = origURL.substring(origURL.length - counter, origURL.length);
  60. num++;
  61. newUrl = origURL.substring(0, origURL.length - counter);
  62. newUrl = newUrl.concat(num);
  63. window.location = newUrl;
  64. }
  65. else if (origURL.match(/^.*nhentai.net\/g\/[0-9]*\/$/)){
  66. window.location = origURL.concat("1/");
  67. }else if (origURL.match(/.*nhentai.net\/g\/[0-9]*\//)){
  68. return;
  69. }
  70. else if (origURL.includes("tag") || origURL == "https://nhentai.net/") {
  71. newUrl = origURL;
  72. newUrl = newUrl.concat("?page=2");
  73. window.location = newUrl;
  74. }
  75. else if (!origURL.includes("page")) {
  76. newUrl = origURL.substring(0, origURL.length - 1);
  77. newUrl = newUrl.concat("&page=2");
  78. window.location = newUrl;
  79. }
  80. } else if (code === 37 && !origURL.match(/.*nhentai.net\/g\/[0-9]*\//)) {
  81. //left key
  82. counter = getNum();
  83. console.log(counter);
  84. num = origURL.substring(origURL.length - counter, origURL.length);
  85. console.log(num);
  86. num--;
  87. newUrl = origURL.substring(0, origURL.length - counter);
  88. newUrl = newUrl.concat(num);
  89. window.location = newUrl;
  90. }
  91. };
  92. })();