nhentai Infinite Scroll

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

นี่คือเวอร์ชันของสคริปต์นี้ที่โค้ดมีการอัปเดต แสดงเวอร์ชันทั้งหมด

  • v3.1 31-03-2026

    ### 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 31-03-2026

    v3.0 — 2026-04-01

    Full rewrite to support the new SvelteKit-based nhentai.net frontend.

    • 🐛 [FIX] Corrected the Favorites page detection — URL is /user/favorites/, not /favorites/
    • 🐛 [FIX] Updated all pagination selectors from .pagination to section.desktop-pagination to match the new SvelteKit markup
    • 🐛 [FIX] Removed broken data-src → src image swap — the new site sets src directly on all images; no swap is needed
    • 🐛 [FIX] Regular page item selector now scopes to the correct container, preventing accidental duplication of "Popular Now" items on the home page
    • [ADD] Dedicated getCurrentPageNum() function reads page state reliably from the desktop paginator
    • [ADD] Dedicated getLastPageNum() function for cleaner, more readable last-page detection
    • [ADD] Mobile paginator (section.mobile-pagination) is now also updated after each page load for consistency
    • 🔄 [CHANGE] Script initialisation check cleaned up — removed references to non-existent #recent-favorites-container and #related-container
    • 🔄 [CHANGE] Version bumped to 3.0
  • v2.5 23-01-2026

    v2.5 (2026-01-23)

    • Removed ad-blocker - Script now focuses on infinite scroll only
    • Added Favorites page support - infinite scroll now works on favorites (requires login)
    • Added page type detection for different HTML structures
    • Fixed container selection for favorites page
    • Updated to handle .gallery-favorite wrapper elements
    • Reduced script size from 447 to ~220 lines
    • Clean, focused codebase
  • v2.2 29-06-2025
  • v2.1 23-04-2025

    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.

  • v2.0 23-04-2025

    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.

  • v1.0 13-04-2025