Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Post text, images, videos, and long-form articles to X (Twitter) via real Chrome browser automation.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/regular-posts.md
1# Regular Posts - Detailed Guide23Detailed documentation for posting text and images to X.45## Manual Workflow67If you prefer step-by-step control:89### Step 1: Copy Image to Clipboard1011```bash12${BUN_X} {baseDir}/scripts/copy-to-clipboard.ts image /path/to/image.png13```1415### Step 2: Paste from Clipboard1617```bash18# Simple paste to frontmost app19${BUN_X} {baseDir}/scripts/paste-from-clipboard.ts2021# Paste to Chrome with retries22${BUN_X} {baseDir}/scripts/paste-from-clipboard.ts --app "Google Chrome" --retries 52324# Quick paste with shorter delay25${BUN_X} {baseDir}/scripts/paste-from-clipboard.ts --delay 20026```2728### Step 3: Use Playwright MCP (if Chrome session available)2930```bash31# Navigate32mcp__playwright__browser_navigate url="https://x.com/compose/post"3334# Get element refs35mcp__playwright__browser_snapshot3637# Type text38mcp__playwright__browser_click element="editor" ref="<ref>"39mcp__playwright__browser_type element="editor" ref="<ref>" text="Your content"4041# Paste image (after copying to clipboard)42mcp__playwright__browser_press_key key="Meta+v" # macOS43# or44mcp__playwright__browser_press_key key="Control+v" # Windows/Linux4546# Screenshot to verify47mcp__playwright__browser_take_screenshot filename="preview.png"48```4950## Image Support5152- Formats: PNG, JPEG, GIF, WebP53- Max 4 images per post54- Images copied to system clipboard, then pasted via keyboard shortcut5556## Example Session5758```59User: /post-to-x "Hello from Claude!" --image ./screenshot.png6061Claude:621. Runs: ${BUN_X} {baseDir}/scripts/x-browser.ts "Hello from Claude!" --image ./screenshot.png632. Chrome opens with X compose page643. Text is typed into editor654. Image is copied to clipboard and pasted665. Browser stays open 30s for preview676. Reports: "Post composed. Use --submit to post."68```6970## Troubleshooting7172- **Chrome not found**: Set `X_BROWSER_CHROME_PATH` environment variable73- **Not logged in**: First run opens Chrome - log in manually, cookies are saved74- **Image paste fails**:75- Verify clipboard script: `${BUN_X} {baseDir}/scripts/copy-to-clipboard.ts image <path>`76- On macOS, grant "Accessibility" permission to Terminal/iTerm in System Settings > Privacy & Security > Accessibility77- Keep Chrome window visible and in front during paste operations78- **osascript permission denied**: Grant Terminal accessibility permissions in System Preferences79- **Rate limited**: Wait a few minutes before retrying8081## How It Works8283The `x-browser.ts` script uses Chrome DevTools Protocol (CDP) to:841. Launch real Chrome (not Playwright) with `--disable-blink-features=AutomationControlled`852. Use persistent profile directory for saved login sessions863. Interact with X via CDP commands (Runtime.evaluate, Input.dispatchKeyEvent)874. **Paste images using osascript** (macOS): Sends real Cmd+V keystroke to Chrome, bypassing CDP's synthetic events that X can detect8889This approach bypasses X's anti-automation detection that blocks Playwright/Puppeteer.9091### Image Paste Mechanism (macOS)9293CDP's `Input.dispatchKeyEvent` sends "synthetic" keyboard events that websites can detect. X ignores synthetic paste events for security. The solution:94951. Copy image to system clipboard via Swift/AppKit (`copy-to-clipboard.ts`)962. Bring Chrome to front via `osascript`973. Send real Cmd+V keystroke via `osascript` and System Events984. Wait for upload to complete99100This requires Terminal to have "Accessibility" permission in System Settings.101