nhentai-infinite-scroll

nhentai infinite scroll.

< 脚本nhentai-infinite-scroll的反馈

提问/评论

§
发表于:2024-12-09

The script can't work with newer chapter from nhentai

§
发表于:2024-12-09

It stopped working since 542136, about 3 days ago

§
发表于:2024-12-10

I think the problem is nhentai switching domain to i4.nhen... instead of i.nhen... I used ChatGPT to change the userscript and it worked perfectly, even with older chapters. Here the code:
// ==UserScript==
// @name nhentai-infinite-scroll
// @namespace Violentmonkey Scripts
// @version 1.0.1
// @description nhentai infinite scroll.
// @author anonymous
// @match https://nhentai.net/g/*/
// @grant none
// @license MIT
// @icon https://i.imgur.com/I5Muasr.png
// ==/UserScript==
(function () {
"use strict";

let thumbnailContainer = document.getElementById("thumbnail-container");
let gallerythumb = document.getElementsByClassName("gallerythumb");

if (
thumbnailContainer === null ||
gallerythumb === null ||
gallerythumb.length === 0
)
return;

let formats = [];

let sheet = (function () {
let style = document.createElement("style");
style.appendChild(document.createTextNode(""));
document.head.appendChild(style);
return style.sheet;
})();

sheet.insertRule("#thumbnail-container > img { width: 100%; }", 0);

let mid = document
.getElementById("cover")
.getElementsByTagName("img")[0]
.src.split("/")[4];

for (let a of gallerythumb) {
let s = a.firstElementChild.getAttribute("data-src").split("/");
formats.push(s[5].split(".")[1]);
mid = s[4];
}

while (thumbnailContainer.firstChild) {
thumbnailContainer.removeChild(thumbnailContainer.firstChild);
}

let lastId = 0;
let timerId = null;
loadNextImage();

function loadNextImage() {
if (timerId !== null) {
clearTimeout(timerId);
timerId = null;
}

let image = new Image();
image.src =
"https://i4.nhentai.net/galleries/" +
mid +
"/" +
(lastId + 1) +
"." +
formats[lastId];
thumbnailContainer.append(image);

image.onload = function () {
lastId++;
if (lastId < formats.length) {
loadNextImage();
}
};

image.onerror = function () {
thumbnailContainer.lastElementChild.remove();
timerId = setTimeout(loadNextImage, 1000);
};
}
})();

§
发表于:2025-01-29

Oh, I didn't realize that someone already got it working again. I used AI to try and fix the userscript but I ended up with something completely different. In my version, you see all of the thumbnails and you don't get infinite scrolling until you click a thumbnail. But it has some problems, so your userscript is better than mine at the moment. I'll publish your fix and link to it so people can find and use it and then I might compare the original, your fixed version, and mine to see if I can make any improvements to mine.

发表回复

登录以发表回复。