Sleazy Fork is available in English.

All Gallery Thumbs

Load all thumbnail pages for a gallery

  1. // ==UserScript==
  2. // @name All Gallery Thumbs
  3. // @version 1.27
  4. // @description Load all thumbnail pages for a gallery
  5. // @author Hauffen
  6. // @include /https?:\/\/(e-|ex)hentai\.org\/.*/
  7. // @require https://code.jquery.com/jquery-3.3.1.min.js
  8. // @namespace https://greasyfork.org/users/285675
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. let $ = window.jQuery;
  13. var url = document.URL;
  14. var count = 1;
  15. var flag = true;
  16. var timeout;
  17.  
  18. if (url.split('/')[3] === "g") {
  19. var pages = document.getElementsByClassName('ptt')[0].children[0].children[0].children[document.getElementsByClassName('ptt')[0].children[0].children[0].childElementCount - 2].innerText;
  20. var s = setInterval(function() {
  21.  
  22. if(document.hidden) { return; }
  23.  
  24. loadMore();
  25.  
  26. $("<style>.gtb{visibility:hidden;}.ptb{visibility:hidden;}div#gdt{display:grid;grid-template-columns:repeat(auto-fit, minmax(" + $(".gdtm").first().width() + "px, 1fr));}</style>").appendTo("head");
  27. clearInterval(s);
  28. }, 500);
  29. } else {
  30. return;
  31. }
  32.  
  33. function loadMore() {
  34. if (!flag) {
  35. return;
  36. }
  37. flag = false;
  38. clearTimeout(timeout);
  39.  
  40. if (count >= pages) {
  41. clearTimeout(timeout);
  42. return;
  43. }
  44.  
  45. var $content = $('<div>');
  46. var nextUrl = url + "?p=" + count;
  47. count = count + 1;
  48. $content.load(`${nextUrl} #gdt`, function() {
  49. var divs = this.children[0].children;
  50.  
  51. divs[0].parentNode.removeChild(divs[divs.length-1]);
  52.  
  53. while (divs.length > 0) {
  54. $(divs[0]).insertBefore( document.getElementsByClassName('c')[3] );
  55. }
  56. flag = true;
  57. timeout = setTimeout(loadMore(count), 5000);
  58. });
  59. }
  60. })();