fix: scan_full_page captures all content on virtual-scroll pages (#731)#1853
Open
hafezparast wants to merge 1 commit intounclecode:developfrom
Open
fix: scan_full_page captures all content on virtual-scroll pages (#731)#1853hafezparast wants to merge 1 commit intounclecode:developfrom
hafezparast wants to merge 1 commit intounclecode:developfrom
Conversation
…n virtual-scroll pages (unclecode#731) scan_full_page previously captured HTML only once after scrolling completed, so pages that recycle DOM elements (Twitter/X, Xiaohongshu, etc.) only returned the last visible batch. VirtualScrollConfig had a similar gap: it used container.scrollTop which has no effect when the window is the scrollable element. _handle_full_page_scan: - Install a MutationObserver before scrolling that captures every element removed from the DOM (i.e. recycled by virtual scroll). - After scrolling, deduplicate the accumulated elements against what is still visible, then re-inject them into a hidden container so that the subsequent page.content() call includes everything. - Clean up the observer on both success and error paths. _handle_virtual_scroll: - Fall back to window.scrollBy() when container.scrollTop has no effect (window-level scrolling, e.g. Twitter). - Update end-of-scroll detection to check window position when using the window fallback. Tested with a local virtual-scroll page (50 items, 10 visible at a time): - Before: 10/50 captured (only last batch) - After: 50/50 captured Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_handle_full_page_scan: installs aMutationObserverbefore scrolling to capture DOM elements that are removed during scroll (virtual scroll recycling). After scrolling, deduplicates against still-visible elements and re-injects accumulated content into a hidden<div>sopage.content()includes everything._handle_virtual_scroll: falls back towindow.scrollBy()whencontainer.scrollTophas no effect (window-level scrolling, e.g. Twitter/X). Updates end-of-scroll detection accordingly.Before fix:
scan_full_page=Trueon a 50-item virtual-scroll page → only 10 items (last batch)After fix: all 50 items captured
Fixes #731, related to #1087
Test plan
tests/test_repro_731.py) — local virtual-scroll page with 50 items, verifies all 50 captured🤖 Generated with Claude Code