Sleazy Fork is available in English.

E-Hentai Infinite Scroll

Auto load next image. Free your hand from keyboard/mouse.

  1. // ==UserScript==
  2. // @name E-Hentai Infinite Scroll
  3. // @namespace http://e-hentai.org/
  4. // @version 0.1
  5. // @description Auto load next image. Free your hand from keyboard/mouse.
  6. // @author Bill.code
  7. // @match https://e-hentai.org/s/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. const displayArea = document.querySelector('#i3');
  14. let page = document;
  15. let lock = false;
  16. document.addEventListener('scroll', checkAndLoad, {passive: true});
  17. checkAndLoad();
  18.  
  19. async function checkAndLoad() {
  20. if (document.body.clientHeight - window.scrollY < window.innerHeight * 4 && !lock) {
  21. lock = true;
  22. page = await loadPage(page);
  23. lock = false;
  24. console.log(page);
  25. }
  26. }
  27. function loadPage(dom) /* Promise<HTMLDocument>: the document of next page */ {
  28. const nextPageA = dom.querySelector('#next');
  29. if (!nextPageA) return;
  30.  
  31. return fetch(nextPageA.href)
  32. .then(e => e.text())
  33. .then(rawHtml => {
  34. const parser = new DOMParser();
  35. const newDom = parser.parseFromString(rawHtml, 'text/html');
  36. displayArea.appendChild(newDom.querySelector('#i3 img'));
  37. return newDom;
  38. });
  39. }
  40. })();