Dynamically loads more comics as you scroll on nhentai.net (including favorites)
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 |
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.
| 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 |
| 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.
| Manager | Supported browsers |
|---|---|
| Tampermonkey | Chrome, Firefox, Edge, Opera |
| Violentmonkey | Chrome, Firefox, Edge |
| Greasemonkey | Firefox |
nhentai Infinite Scroll.txt and paste it inCtrl + S or click the Save buttonBrowse 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.
| 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);
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.
Gallery discovery — initPage() 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 |
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.
Dynamic page tracking — getLastPageNum() 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.
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.
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.
SPA support, flexible container detection, and dynamic page tracking.
history.pushState / replaceState and popstate so the script reinitialises on every SvelteKit client-side navigation.container.index-container), search result pages (.index-container), and any other structure via gallery-item parent detectionextractGalleries() when parsing HTTP-fetched pagesscroll.nhi) — old listener is removed cleanly before a new one is attached on every navigationisFavoritesPage changed from a startup constant to a live function — was returning a stale value after navigating between page typeslastPageNum 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 loadssection.desktop-pagination a.last to be present before evaluating page counts, preventing premature interval termination on slow rendersonNavigate() delays start at 200 ms to avoid reading stale DOM from the previous SvelteKit page before it is replacedgetLastPageNum() returns 0 (not 1) when a.last is absent, allowing callers to distinguish "not rendered yet" from "only one page"Full rewrite for the SvelteKit-based nhentai frontend.
/user/favorites/ not /favorites/section.desktop-paginationdata-src → src image swap — the new site uses native src directly.advertisement and .index-popular sectionsgetCurrentPageNum() and getLastPageNum() helper functionssection.mobile-pagination) updated after each page loadinfinite_load toggle via GM_getValuegetGalleryContainer() helperLicensed under the MIT License. You are free to use, modify, and distribute this script for any purpose provided the original copyright notice is retained.
Snow2122