Dynamically loads more comics as you scroll on nhentai.net (including favorites)
นี่คือเวอร์ชันของสคริปต์นี้ที่โค้ดมีการอัปเดต แสดงเวอร์ชันทั้งหมด
### 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"
Full rewrite to support the new SvelteKit-based nhentai.net frontend.
/user/favorites/
/favorites/
.pagination
section.desktop-pagination
data-src → src
src
getCurrentPageNum()
getLastPageNum()
section.mobile-pagination
#recent-favorites-container
#related-container
.gallery-favorite
NHentai Infinite Load v2.1🔧 New Features:- Infinite Scroll: Automatically loads more galleries as you scroll, removing the need for manual pagination.- Blacklist Filtering: Optionally remove galleries tagged as blacklisted, both on initial load and during infinite scroll.- Settings Menu: Easy toggles via userscript menu to enable/disable infinite scroll and blacklist filtering.⚡ Enhancements:- Improved Performance: Optimized DOM manipulation and scroll handling with debounced events.- Smart Retry Logic: Automatically retries loading failed pages with exponential backoff on rate limits (e.g., HTTP 429).- Cleaner Codebase: Modular configuration and function separation for better readability and maintainability.- Loading Indicator: Custom animated loader appears while new content is fetched.🛡️ Compatibility & Safety:- Safe fallback when pagination isn't detected (e.g., on Favorites page).- Extensive console logging to help with debugging and customization.
Changes made in Version (v2.0)- Infinite Scroll Enhancement: Automatically loads more comics as you scroll, improving the browsing experience.- Blacklist Filtering: Optionally hides blacklisted content (as marked on the site) even during infinite scrolling.- User Settings UI: Easily toggle infinite loading and blacklist removal directly from the userscript menu.- Improved Performance: Efficient loading using IntersectionObserver and debounced scroll events.- Visual Loader Indicator: Displays a loading animation while new content is being fetched.- Retry Logic: Handles fetch failures with exponential backoff retries for robustness.