E-Hentai Infinite Scroll

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

< Feedback on E-Hentai Infinite Scroll

Review: Good - script works

§
Posted: 2024/05/04

You can make it work with some modifications.

(function() {
'use strict';
const displayArea = document.querySelector('table.itg.glte');
let page = document;
let lock = false;
document.addEventListener('scroll', checkAndLoad, {passive: true});
checkAndLoad();

async function checkAndLoad() {
if (document.body.clientHeight - window.scrollY < window.innerHeight * 4 && !lock) {
lock = true;
page = await loadPage(page);
lock = false;
console.log(page);
}
}
function loadPage(dom) /* Promise: the document of next page */ {
const nextPageA = dom.getElementById('dnext');
if (!nextPageA) return;

return fetch(nextPageA.href)
.then(e => e.text())
.then(rawHtml => {
const parser = new DOMParser();
const newDom = parser.parseFromString(rawHtml, 'text/html');
var datas = newDom.querySelectorAll('td.gl1e, td.gl2e');
var trElements = Array.from(datas).map(function(td) {
return td.parentNode;
});
trElements.forEach((element) => displayArea.appendChild(element));
return newDom;
});
}
})();

§
Posted: 2024/05/17

Fixed to be compatible with the Read History plugin.

(function() {
'use strict';
const displayArea = document.querySelector('table.itg.glte');
let page = document;
let lock = false;
document.addEventListener('scroll', checkAndLoad, {passive: true});
checkAndLoad();

async function checkAndLoad() {
if (document.body.clientHeight - window.scrollY < window.innerHeight * 4 && !lock) {
lock = true;
page = await loadPage(page);
lock = false;
console.log(page);
}
}
function loadPage(dom) /* Promise: the document of next page */ {
const nextPageA = dom.getElementById('dnext');
if (!nextPageA) return;

return fetch(nextPageA.href)
.then(e => e.text())
.then(rawHtml => {
const parser = new DOMParser();
const newDom = parser.parseFromString(rawHtml, 'text/html');
var datas = newDom.querySelector('.itg.glte tbody');
displayArea.appendChild(datas);
return newDom;
});
}
})();

Post reply

Sign in to post a reply.