fix(twitter): repair lists scraping from detail pages#1053
Merged
jackwener merged 1 commit intojackwener:mainfrom Apr 16, 2026
Merged
fix(twitter): repair lists scraping from detail pages#1053jackwener merged 1 commit intojackwener:mainfrom
jackwener merged 1 commit intojackwener:mainfrom
Conversation
huanghe
pushed a commit
to huanghe/OpenCLI
that referenced
this pull request
Apr 18, 2026
The DOM-scraping / detail-click approach in PR jackwener#1053 remained fragile against X's frequent overview-page rendering changes and slow (N+1 page loads per list). Rewrite `twitter lists` to call `ListsManagementPageTimeline` GraphQL directly — one request returns all owned + subscribed lists with id/name/member_count/subscriber_count/mode. Also add `twitter list-tweets <listId>` for pulling the tweet stream from a list, completing the read-side chain (lists → pick an id → list-tweets). - lists: drop positional `user` arg (GraphQL returns only logged-in user's lists), add `id` column, change followers to exact integer from subscriber_count. - list-tweets: same GraphQL pattern as bookmarks/likes (BEARER + ct0 + dynamic queryId with static fallback + cursor pagination). - Delete obsolete lists-parser.js and lists.d.ts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6 tasks
huanghe
added a commit
to huanghe/OpenCLI
that referenced
this pull request
Apr 18, 2026
The DOM-scraping / detail-click approach in PR jackwener#1053 remained fragile against X's frequent overview-page rendering changes and slow (N+1 page loads per list). Rewrite `twitter lists` to call `ListsManagementPageTimeline` GraphQL directly — one request returns all owned + subscribed lists with id/name/member_count/subscriber_count/mode. Also add `twitter list-tweets <listId>` for pulling the tweet stream from a list, completing the read-side chain (lists → pick an id → list-tweets). - lists: drop positional `user` arg (GraphQL returns only logged-in user's lists), add `id` column, change followers to exact integer from subscriber_count. - list-tweets: same GraphQL pattern as bookmarks/likes (BEARER + ct0 + dynamic queryId with static fallback + cursor pagination). - Delete obsolete lists-parser.js and lists.d.ts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
jackwener
added a commit
that referenced
this pull request
Apr 18, 2026
…1076) * feat(twitter): rewrite lists via GraphQL + add list-tweets The DOM-scraping / detail-click approach in PR #1053 remained fragile against X's frequent overview-page rendering changes and slow (N+1 page loads per list). Rewrite `twitter lists` to call `ListsManagementPageTimeline` GraphQL directly — one request returns all owned + subscribed lists with id/name/member_count/subscriber_count/mode. Also add `twitter list-tweets <listId>` for pulling the tweet stream from a list, completing the read-side chain (lists → pick an id → list-tweets). - lists: drop positional `user` arg (GraphQL returns only logged-in user's lists), add `id` column, change followers to exact integer from subscriber_count. - list-tweets: same GraphQL pattern as bookmarks/likes (BEARER + ct0 + dynamic queryId with static fallback + cursor pagination). - Delete obsolete lists-parser.js and lists.d.ts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(twitter): add list-add / list-remove with Save-button commit Two new commands to toggle list membership. X's list dialog uses a "click-to-stage, Save-to-commit" pattern — clicking a row only updates optimistic UI; the actual POST fires when the user clicks the top-right "Save" button. Pressing ESC or the close-X silently cancels the change. Implementation: - Resolve listId → name via ListsManagementPageTimeline GraphQL, so we match the dialog row by name (dialog rows have no data-testid listId). - Open profile page → DOM click "…" menu → "Add/remove from Lists". - Scroll dialog to locate target row (virtualized list). - page.nativeClick on row — trusted CDP Input.dispatchMouseEvent fires React's onclick, flips aria-checked (.click() alone does not suffice; X ignores non-trusted events for list mutations). - page.nativeClick on the Save button — commits to server. - Verify by re-fetching ListsManagementPageTimeline and diffing member_count: success only if N→N±1. No silent successes. This fixes the pattern where batch `list-add` calls returned success for every user but committed zero to the server (optimistic UI lied). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix: stabilize twitter list manifest and query ids * docs: add twitter list command discoverability --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: jackwener <jakevingoo@gmail.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.
Description
Repair
twitter listsafter X changed the lists overview page.The command no longer relies on overview-page anchors. It now discovers
data-testid="listCell"entries from the overview page, opens each canonical/i/lists/<id>detail page, and parses metrics from the detail view after filtering leading page chrome. It also keeps known list-slot counts separate from ready cells so temporary blank rerenders fail clearly instead of silently truncating results.Closes #1046
Type of Change
Checklist
Documentation (if adding/modifying an adapter)
docs/adapters/(if new adapter)docs/adapters/index.mdtable (if new adapter)docs/.vitepress/config.mts(if new adapter)README.md/README.zh-CN.mdwhen command discoverability changedCliErrorsubclasses instead of rawErrorScreenshots / Output
[ { "name": "Monkeys", "members": "0", "followers": "51.8K", "mode": "public" } ]Checks run:
npx vitest run clis/twitter/lists.test.jsnpx tsc --noEmitnpx tsx src/main.ts twitter lists elonmusk --limit 1 --format json -v