x-composer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseX Composer
X Composer
Post to X.com via Chrome DevTools Protocol (CDP). Uses real Chrome to bypass anti-bot detection.
通过Chrome DevTools Protocol(CDP)发布内容到X.com。使用真实Chrome浏览器绕过反机器人检测。
Prerequisites
前置条件
- Google Chrome installed
- npm package
chrome-remote-interface
Install if missing:
bash
npm install -g chrome-remote-interface- 已安装Google Chrome
- 已安装npm包
chrome-remote-interface
若未安装,执行以下命令:
bash
npm install -g chrome-remote-interfaceWorkflow
工作流程
Posting to X involves these steps:
- Launch Chrome with CDP (run )
scripts/cdp-launch.js - Wait for X.com compose page to load (~3s)
- Type draft text (run )
scripts/cdp-type.js - User reviews and clicks Post manually
发布内容到X的步骤如下:
- 启动开启CDP的Chrome浏览器(运行)
scripts/cdp-launch.js - 等待X.com的撰写页面加载完成(约3秒)
- 输入草稿文本(运行)
scripts/cdp-type.js - 用户预览并手动点击「发布」按钮
Step 1: Launch Chrome
步骤1:启动Chrome浏览器
Run with optional URL argument:
scripts/cdp-launch.jsbash
NODE_PATH=$(npm root -g) node scripts/cdp-launch.js| URL | Purpose |
|---|---|
| (default) | |
| Open home feed |
| Search posts |
Reuses existing Chrome CDP instance if running. First run requires manual X.com login — session persists in .
~/.chrome-cdp-profileWait ~3 seconds after launch before typing.
运行,可附带可选的URL参数:
scripts/cdp-launch.jsbash
NODE_PATH=$(npm root -g) node scripts/cdp-launch.js| URL | 用途 |
|---|---|
| (默认) | |
| 打开首页信息流 |
| 搜索推文 |
如果已有Chrome CDP实例在运行,则会复用该实例。首次运行需要手动登录X.com——会话会保存在中。
~/.chrome-cdp-profile启动后等待约3秒再进行文本输入。
Step 2: Type Draft
步骤2:输入草稿内容
Pipe JSON segments to via stdin:
scripts/cdp-type.jsbash
echo '[{"text":"Hello world!"}]' | NODE_PATH=$(npm root -g) node scripts/cdp-type.js通过标准输入将JSON片段管道传输到:
scripts/cdp-type.jsbash
echo '[{"text":"Hello world!"}]' | NODE_PATH=$(npm root -g) node scripts/cdp-type.jsSegment Format
片段格式
| Segment | Effect |
|---|---|
| Insert text (emoji/unicode safe) |
| Single line break |
| Multiple line breaks |
| 片段 | 效果 |
|---|---|
| 插入文本(支持表情符号/Unicode) |
| 插入单个换行符 |
| 插入多个换行符 |
Example: Multi-paragraph post
示例:多段落内容发布
bash
cat << 'EOF' | NODE_PATH=$(npm root -g) node scripts/cdp-type.js
[
{"text": "Hook line with emoji"},
{"enter": 2},
{"text": "Main content paragraph."},
{"enter": 2},
{"text": "- Point one"},
{"enter": true},
{"text": "- Point two"},
{"enter": 2},
{"text": "https://example.com"},
{"enter": true},
{"text": "#hashtag #tags"}
]
EOFbash
cat << 'EOF' | NODE_PATH=$(npm root -g) node scripts/cdp-type.js
[
{"text": "Hook line with emoji"},
{"enter": 2},
{"text": "Main content paragraph."},
{"enter": 2},
{"text": "- Point one"},
{"enter": true},
{"text": "- Point two"},
{"enter": 2},
{"text": "https://example.com"},
{"enter": true},
{"text": "#hashtag #tags"}
]
EOFStep 3: User Posts
步骤3:用户发布内容
Draft is entered in browser. User reviews and clicks "Post" manually. Never auto-post.
草稿内容已输入到浏览器中。用户预览后手动点击「发布」按钮。绝不会自动发布。
Troubleshooting
故障排除
| Issue | Fix |
|---|---|
| Chrome not connecting | |
| No X.com tab found | Launch Chrome first, wait 3s |
| Text not typing | Click compose box in browser first |
| Module not found | |
| Login required | Use default profile path ( |
| 问题 | 解决方法 |
|---|---|
| Chrome无法连接 | 执行 |
| 未找到X.com标签页 | 先启动Chrome浏览器,等待3秒 |
| 文本无法输入 | 先点击浏览器中的撰写框 |
| 模块未找到 | 执行 |
| 需要登录 | 使用默认配置文件路径( |
Notes
注意事项
- resolves globally installed
NODE_PATH=$(npm root -g)chrome-remote-interface - handles emoji/unicode reliably (not character-by-character)
Input.insertText() - Fixed preserves login across Chrome restarts
--user-data-dir - If text appears scrambled, restart Chrome and retry
- 用于解析全局安装的
NODE_PATH=$(npm root -g)模块chrome-remote-interface - 可可靠处理表情符号/Unicode(无需逐个字符输入)
Input.insertText() - 固定的可在Chrome重启后保留登录状态
--user-data-dir - 如果文本显示乱码,请重启Chrome后重试