// The X site adapter for the wayBetter page runtime (waybetter/packages/runtime). Everything the // framework needs to know about x.com that is not a feature: which requests are X's API, which // pages are heavy (XChat), the plugin API names, and X's navigation rail. The account reader and // the link-routing rules live next to their X code (accountReport.ts, linkRouting.ts); X's source // palettes for the theme engine are `X_PALETTES` in theme.ts. The native half is `site.rs`. // // Importing this module applies the adapter (DOM hub + request hub), so every X module that uses a // hub imports it through the local adapters (domHub.ts, netHub.ts). import { configureRuntime, type SiteAdapter } from '../../../../waybetter/packages/runtime/src/site.ts'; export const X_SITE = { product: 'wayBetter for X', hosts: ['x.com'], runtimeGlobal: 'BetterTwttr', // XChat is WASM heavy and has no posts, composers or profiles for the DOM features. heavyPath: /^\/(?:messages|i\/chat)(?:\/|$)/i, // X renders its chat inside the open shadow root of this host (XChatEmbed, seen live 2026-10-01): // the DOM hub observes and searches it like the page (Chat+ finds X's rows there). shadowHosts: ['[data-testid="xchatEmbedRoute"]'], // `/live_pipeline/events`: X's streamed live counts on api.x.com (one request per page session), // filtered by the like/repost/bookmark fix (src/fixes/mutationGate/liveCounts.ts). apiMarks: ['/i/api/', '/live_pipeline/events'], // X's chunked media upload (upload.x.com); only XHR gates see it (see src/fixes/uploadRetry.ts). xhrMarks: ['/i/media/upload.json'], plugins: { name: 'BetterTwttr', product: 'wayBetter for X', storagePrefix: 'bt-plugin:', styleDataKey: 'betterTwttrPlugin', toastId: 'bt-plugin-toast', toastBackground: 'rgb(29, 155, 240)', itemSelector: 'article[data-testid="tweet"]', // X's "g" chords (g h, g n, ...): their second key is never a plugin shortcut. chordKeys: ['g'], }, rail: { prefix: 'bt', rail: 'header[role="banner"]', anchor: '[data-testid="AppTabBar_Home_Link"]', main: 'main[role="main"]', accentSource: '[data-testid="SideNav_NewTweet_Button"]', modalOpen: '#layers [aria-modal="true"]', menuOpen: '#layers [role="menu"], #layers [data-testid="Dropdown"]', paint: { width: 88, background: 'rgb(0, 0, 0)', line: 'rgba(231, 233, 234, 0.16)', accent: 'rgb(29, 155, 240)', rtl: false }, }, } satisfies SiteAdapter; configureRuntime(X_SITE);