nhentai-infinite-scroll-fixed-in-2025

nhentai infinite scroll.

当前为 2025-01-29 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name nhentai-infinite-scroll-fixed-in-2025
// @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);
};
}
})();