fix(xiaohongshu): scope note interaction selectors to .interact-container#839
Open
y4h2 wants to merge 1 commit intojackwener:mainfrom
Open
fix(xiaohongshu): scope note interaction selectors to .interact-container#839y4h2 wants to merge 1 commit intojackwener:mainfrom
y4h2 wants to merge 1 commit intojackwener:mainfrom
Conversation
…iner The .like-wrapper / .collect-wrapper / .chat-wrapper class names are also used by every comment's like/reply buttons in the comment section. querySelector returned the FIRST match — which on a note with comments is a comment's count, not the post's. As a result, `xiaohongshu note` returned wrong like/collect/comment counts for any note that had user comments. Scoping each selector to .interact-container (the post's main interaction bar) returns the correct post-level counts. Verified on multiple notes: - Note A: was returning likes=2, now correctly returns likes=74 - Note B: was returning likes=1, now correctly returns likes=796 - Note C: was returning likes=1, now correctly returns likes=269
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
xiaohongshu notewas returning wrong like/collect/comment counts for any note that had user comments.Root cause
The DOM selectors
.like-wrapper .count/.collect-wrapper .count/.chat-wrapper .countare not unique to the post's main interaction bar. Every comment in the comment section also renders a.like-wrapper > .countfor its own like button (and the comment count input has.chat-wrapper).document.querySelectorreturns the first match, which on a note with comments is a comment's count, not the post's.In practice the post's true counts live inside
.interact-container, while comment-level counts are scattered throughout the comment list above/below it. Whether the bug fired depended on DOM order, which is why the bug surfaced inconsistently across different notes.Fix
Scope each selector to
.interact-container:Verification
Tested on three notes that previously returned wrong values:
All three now match the values displayed on xiaohongshu.com.
Test plan
opencli xiaohongshu note <url>against several notes with commentsnote.test.tsif any)