fix: dynamic queryId & features resolution from X search page - #83
Open
gnuhpc wants to merge 1 commit into
Open
Conversation
X rotated all GraphQL queryIds and the homepage no longer contains the ondemand.s file reference. This PR fixes multiple root causes: 1. Scan X search page instead of homepage for JS bundles - Search page (x.com/search?q=AI&f=live) still uses legacy frontend - Contains main.*.js with all 106 queryId definitions - Homepage uses new React Router (TSR) with no queryId refs 2. Resolve queryId: scan bundles first, then GitHub, then fallback - GitHub twitter-openapi is also frequently stale - Live bundle scanning is the most reliable source 3. Dynamically merge features from GitHub twitter-openapi - Default FEATURES dict has only 20 keys - GitHub has 65+ feature flags needed by SearchTimeline etc. - Merged at import time, non-blocking on failure 4. Match both responsive-web and x-web JS URL patterns - Old: abs.twimg.com/responsive-web/client-web/*.js - New: abs.twimg.com/x-web/x-web/*.js 5. Recursively scan entry-client JS for chunk file references - New X frontend uses __vite__mapDeps for dynamic chunks - Extract chunk filenames from entry bundle and scan them too Fixes public-clis#78, public-clis#73, public-clis#69
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.
Problem
After X rotated all GraphQL
queryIds and redesigned its homepage,twitter searchreturns HTTP 404,user-postsreturns empty results, andfeedfails intermittently.Related issues: #78, #73, #69
This PR complements #79 (cookie fix) and #82 (fallback ID refresh) — but addresses the root cause more comprehensively.
Root Causes
1. Homepage no longer contains JS bundles with queryId definitions
X redesigned its homepage to use React Router (TSR). The new homepage returns a minimal HTML with
entry-client-*.js(a Vite bootstrap loader) instead of the legacymain.*.jsthat containsqueryId/operationNamemappings.2.
_scan_bundlesfetches the wrong pageThe function fetches
https://x.com(homepage) to find JS bundles, but the new homepage only hasx-web/x-web/URLs, which the existing regex does not match.3. GitHub twitter-openapi queryIds are also stale
_resolve_query_idfalls back to_fetch_from_github(), but the community-maintainedplaceholder.jsonis also frequently behind X's rotation schedule.4. Features dict is incomplete
Default
FEATUREShas only 20 keys, butSearchTimelinerequires 39 specific feature flags. Missing flags cause silent API failures.Fix
Scan X search page instead of homepage
The search page has NOT been redesigned — it still uses
responsive-web/client-web/main.*.jswith all 106 queryId definitions.QueryId resolution priority
Dynamic features from GitHub
Merge all feature flags from
twitter-openapi placeholder.jsonat import time (non-blocking on failure). This brings FEATURES from 20 to 65+ keys.Match both URL patterns
Added
x-web/x-webto the regex alongsideresponsive-web/client-web.Recursive chunk scanning
New X frontend uses
__vite__mapDepsfor dynamic chunk loading. Extract chunk filenames from the entry bundle and scan them too.Verification
After applying this PR:
twitter search "AI"returns results (was 404)twitter user-posts karpathyreturns tweets (was empty)twitter feedreturns timelinetwitter postandtwitter quotewere unaffected and still work