nhentai Infinite Scroll

Dynamically loads more comics as you scroll on nhentai.net (including favorites)

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

יוצר
Snow2122
התקנות יומיות
3
סה"כ התקנות
162
דירוגים
0 0 0
גרסה
3.1
נוצר
13-04-2025
עודכן
31-03-2026
Size
12.9 קילו-בייט
רישיון
MIT
חל על

nhentai Infinite Scroll

Dynamically loads more comics as you scroll on nhentai.net — no clicking required.


Script file nhentai Infinite Scroll.txt
Author Snow2122
Original Author Hentiedup
Version 3.1
License MIT
Updated 2026-04-01
Applies to nhentai.net

Overview

A userscript that adds infinite scroll functionality to nhentai.net. When you reach the bottom of a page, the next page of comics is automatically fetched and appended — no need to ever click "Next page" again. The script is fully compatible with nhentai's SvelteKit SPA architecture, meaning it detects client-side navigation and reinitialises itself automatically whenever you browse to a new page.


✨ Features

Feature Description
Automatic loading Next page loads as you scroll within 500 px of the document bottom
Short-page fill If the page is too short to scroll, pages are loaded automatically until a scrollbar appears
Animated spinner A loading indicator is shown while a page fetch is in progress
Retry logic Retries up to 5 times (1-second gap between attempts) on network failure
Duplicate guard Already-loaded comics are skipped to prevent duplicates across page boundaries
Paginator sync Both desktop and mobile paginators are updated after each page load
SPA-aware Re-initialises automatically on every SvelteKit client-side navigation
Flexible container detection Three-level fallback selector chain finds the gallery on every page type, including search result pages

📄 Supported Pages

Page URL Pattern Login Required
Home nhentai.net/ ❌ No
Search results nhentai.net/search?q=… ❌ No
Tag pages nhentai.net/tag/… ❌ No
Artist pages nhentai.net/artist/… ❌ No
Character pages nhentai.net/character/… ❌ No
Parody pages nhentai.net/parody/… ❌ No
Group pages nhentai.net/group/… ❌ No
Favorites nhentai.net/user/favorites/ ✅ Yes

Note: The Favorites page requires you to be logged in to nhentai.net. All other pages work regardless of login status.


📦 Installation

Step 1 — Install a userscript manager

Manager Supported browsers
Tampermonkey Chrome, Firefox, Edge, Opera
Violentmonkey Chrome, Firefox, Edge
Greasemonkey Firefox

Step 2 — Install the script

  1. Open your userscript manager's dashboard from the browser toolbar
  2. Click "Create a new script" (or "Add new script")
  3. Delete any placeholder code the editor has pre-filled
  4. Copy the full contents of nhentai Infinite Scroll.txt and paste it in
  5. Save with Ctrl + S or click the Save button

🖱️ Usage

Browse nhentai.net normally. When you scroll near the bottom of any supported page, the next page of comics is automatically fetched and appended below. An animated spinner briefly appears while loading is in progress.

If the initial page content is too short to produce a scrollbar, the script will automatically keep loading pages until the content overflows the viewport.


🛠️ Configuration

Setting Default Description
infinite_load true Set to false to disable infinite scroll without uninstalling the script

To disable the script without uninstalling it, open the script in your userscript manager's editor and change the second argument of GM_getValue:

// Change true → false to disable
const infinite_load = GM_getValue("infinite_load", false);

🔍 How It Works

  1. Navigation detection — The script patches history.pushState, history.replaceState, and popstate so it is notified of every SvelteKit client-side navigation. On each navigation, it schedules initPage() at six staggered delays to handle varying SvelteKit render speeds.

  2. Gallery discoveryinitPage() uses a three-level fallback to locate the gallery container:

| Level | Selector | Used for | |---|---|---| | 1 | .container.index-container:not(.advertisement, .index-popular) | Home, tag, artist, character, parody, group | | 2 | .index-container:not(.advertisement, .index-popular) | Search result pages | | 3 | Parent of any div.gallery not in a special section | Universal fallback |

  1. Scroll listener — A named (scroll.nhi) scroll event fires when the user is within 500 px of the document bottom. The old listener is removed and replaced cleanly on every navigation.

  2. Dynamic page trackinggetLastPageNum() and getCurrentPageNum() are read fresh on every scroll event — never cached at init time — so they always reflect the current page's paginator, not a stale value from a previous page.

  3. Fetching and appending$.get() fetches the next page's raw HTML. Gallery items are extracted using the same three-level fallback and appended to the live container. Duplicate entries are skipped via cover href comparison.

  4. Paginator update — After each successful load, the desktop (and mobile, if present) paginator is updated to mark the newly loaded page as current, so subsequent scroll events calculate the next page correctly.


📋 Changelog

v3.1 — 2026-04-01

SPA support, flexible container detection, and dynamic page tracking.

  • [ADD] SPA navigation detection — patches history.pushState / replaceState and popstate so the script reinitialises on every SvelteKit client-side navigation
  • [ADD] Three-level gallery container fallback — handles standard listing pages (.container.index-container), search result pages (.index-container), and any other structure via gallery-item parent detection
  • [ADD] Same three-level fallback applied inside extractGalleries() when parsing HTTP-fetched pages
  • [ADD] Named scroll event (scroll.nhi) — old listener is removed cleanly before a new one is attached on every navigation
  • 🐛 [FIX] isFavoritesPage changed from a startup constant to a live function — was returning a stale value after navigating between page types
  • 🐛 [FIX] lastPageNum is now read dynamically inside every scroll and interval tick — previously captured at init time and could hold a value from the wrong page, causing broken or missing loads
  • 🐛 [FIX] Auto-fill interval now waits for section.desktop-pagination a.last to be present before evaluating page counts, preventing premature interval termination on slow renders
  • 🔄 [CHANGE] onNavigate() delays start at 200 ms to avoid reading stale DOM from the previous SvelteKit page before it is replaced
  • 🔄 [CHANGE] getLastPageNum() returns 0 (not 1) when a.last is absent, allowing callers to distinguish "not rendered yet" from "only one page"

v3.0 — 2026-04-01

Full rewrite for the SvelteKit-based nhentai frontend.

  • 🐛 [FIX] Corrected Favorites page URL detection — /user/favorites/ not /favorites/
  • 🐛 [FIX] Updated all pagination selectors to section.desktop-pagination
  • 🐛 [FIX] Removed broken data-src → src image swap — the new site uses native src directly
  • 🐛 [FIX] Gallery container selector scoped to exclude .advertisement and .index-popular sections
  • [ADD] getCurrentPageNum() and getLastPageNum() helper functions
  • [ADD] Mobile paginator (section.mobile-pagination) updated after each page load

v2.5 — Prior release

  • [ADD] Favorites page support
  • [ADD] Retry logic (up to 5 retries on network failure)
  • [ADD] Short-page auto-fill using a polling interval
  • [ADD] Duplicate-entry guard via cover href comparison

v2.2 — Prior release

  • [ADD] Configurable infinite_load toggle via GM_getValue
  • 🔄 [CHANGE] Refactored to use getGalleryContainer() helper

v2.0 — Original

  • [ADD] Initial infinite scroll (based on Hentiedup's original concept, adapted by Snow2122)

🙏 Credits

  • Hentiedup — Original script author and concept
  • Snow2122 — Adaptation, SPA rewrite, multi-level container fallback, documentation

📜 License

Licensed under the MIT License. You are free to use, modify, and distribute this script for any purpose provided the original copyright notice is retained.


✍️ Author

Snow2122