Post to X (Twitter)
Posts text, images, videos, and long-form articles to X via real Chrome browser (bypasses anti-bot detection).
Script Directory
Important: All scripts are located in the scripts/ subdirectory of this skill.
Agent Execution Instructions:
- 1. Determine this SKILL.md file's directory path as INLINECODE1
- Script path = INLINECODE2
- Replace all
${SKILL_DIR} in this document with the actual path
Script Reference:
| Script | Purpose |
|---|
| INLINECODE4 | Regular posts (text + images) |
| INLINECODE5 |
Video posts (text + video) |
|
scripts/x-quote.ts | Quote tweet with comment |
|
scripts/x-article.ts | Long-form article publishing (Markdown) |
|
scripts/md-to-html.ts | Markdown → HTML conversion |
|
scripts/copy-to-clipboard.ts | Copy content to clipboard |
|
scripts/paste-from-clipboard.ts | Send real paste keystroke |
Preferences (EXTEND.md)
Use Bash to check EXTEND.md existence (priority order):
CODEBLOCK0
┌──────────────────────────────────────────────────┬───────────────────┐
│ Path │ Location │
├──────────────────────────────────────────────────┼───────────────────┤
│ .baoyu-skills/baoyu-post-to-x/EXTEND.md │ Project directory │
├──────────────────────────────────────────────────┼───────────────────┤
│ $HOME/.baoyu-skills/baoyu-post-to-x/EXTEND.md │ User home │
└──────────────────────────────────────────────────┴───────────────────┘
┌───────────┬───────────────────────────────────────────────────────────────────────────┐
│ Result │ Action │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ Found │ Read, parse, apply settings │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ Not found │ Use defaults │
└───────────┴───────────────────────────────────────────────────────────────────────────┘
EXTEND.md Supports: Default Chrome profile | Auto-submit preference
Prerequisites
- - Google Chrome or Chromium
- INLINECODE11 runtime
- First run: log in to X manually (session saved)
References
- - Regular Posts: See
references/regular-posts.md for manual workflow, troubleshooting, and technical details - X Articles: See
references/articles.md for long-form article publishing guide
Regular Posts
Text + up to 4 images.
CODEBLOCK1
Parameters:
| Parameter | Description |
|---|
| INLINECODE14 | Post content (positional) |
| INLINECODE15 |
Image file (repeatable, max 4) |
|
--submit | Post (default: preview) |
|
--profile <dir> | Custom Chrome profile |
Video Posts
Text + video file.
CODEBLOCK2
Parameters:
| Parameter | Description |
|---|
| INLINECODE18 | Post content (positional) |
| INLINECODE19 |
Video file (MP4, MOV, WebM) |
|
--submit | Post (default: preview) |
|
--profile <dir> | Custom Chrome profile |
Limits: Regular 140s max, Premium 60min. Processing: 30-60s.
Quote Tweets
Quote an existing tweet with comment.
CODEBLOCK3
Parameters:
| Parameter | Description |
|---|
| INLINECODE22 | URL to quote (positional) |
| INLINECODE23 |
Comment text (positional, optional) |
|
--submit | Post (default: preview) |
|
--profile <dir> | Custom Chrome profile |
X Articles
Long-form Markdown articles (requires X Premium).
CODEBLOCK4
Parameters:
| Parameter | Description |
|---|
| INLINECODE26 | Markdown file (positional) |
| INLINECODE27 |
Cover image |
|
--title <text> | Override title |
|
--submit | Publish (default: preview) |
Frontmatter: title, cover_image supported in YAML front matter.
Notes
- - First run: manual login required (session persists)
- Always preview before INLINECODE32
- Cross-platform: macOS, Linux, Windows
Extension Support
Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
发布到 X (Twitter)
通过真实的 Chrome 浏览器发布文本、图片、视频和长文到 X(绕过反机器人检测)。
脚本目录
重要提示:所有脚本均位于此技能的 scripts/ 子目录中。
代理执行说明:
- 1. 确定此 SKILL.md 文件的目录路径为 SKILLDIR
- 脚本路径 = ${SKILLDIR}/scripts/<脚本名称>.ts
- 将本文档中的所有 ${SKILL_DIR} 替换为实际路径
脚本参考:
| 脚本 | 用途 |
|---|
| scripts/x-browser.ts | 常规帖子(文本 + 图片) |
| scripts/x-video.ts |
视频帖子(文本 + 视频) |
| scripts/x-quote.ts | 带评论的引用推文 |
| scripts/x-article.ts | 长文发布(Markdown) |
| scripts/md-to-html.ts | Markdown → HTML 转换 |
| scripts/copy-to-clipboard.ts | 复制内容到剪贴板 |
| scripts/paste-from-clipboard.ts | 发送真实粘贴按键 |
偏好设置 (EXTEND.md)
使用 Bash 检查 EXTEND.md 是否存在(优先级顺序):
bash
首先检查项目级别
test -f .baoyu-skills/baoyu-post-to-x/EXTEND.md && echo project
然后检查用户级别(跨平台:$HOME 在 macOS/Linux/WSL 上均有效)
test -f $HOME/.baoyu-skills/baoyu-post-to-x/EXTEND.md && echo user
┌──────────────────────────────────────────────────┬───────────────────┐
│ 路径 │ 位置 │
├──────────────────────────────────────────────────┼───────────────────┤
│ .baoyu-skills/baoyu-post-to-x/EXTEND.md │ 项目目录 │
├──────────────────────────────────────────────────┼───────────────────┤
│ $HOME/.baoyu-skills/baoyu-post-to-x/EXTEND.md │ 用户主目录 │
└──────────────────────────────────────────────────┴───────────────────┘
┌───────────┬───────────────────────────────────────────────────────────────────────────┐
│ 结果 │ 操作 │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ 找到 │ 读取、解析、应用设置 │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ 未找到 │ 使用默认设置 │
└───────────┴───────────────────────────────────────────────────────────────────────────┘
EXTEND.md 支持:默认 Chrome 配置文件 | 自动提交偏好
前提条件
- - Google Chrome 或 Chromium
- bun 运行时
- 首次运行:手动登录 X(会话会保存)
参考
- - 常规帖子:参见 references/regular-posts.md 了解手动工作流程、故障排除和技术细节
- X 文章:参见 references/articles.md 了解长文发布指南
常规帖子
文本 + 最多 4 张图片。
bash
npx -y bun ${SKILL_DIR}/scripts/x-browser.ts 你好! --image ./photo.png # 预览
npx -y bun ${SKILL_DIR}/scripts/x-browser.ts 你好! --image ./photo.png --submit # 发布
参数:
| 参数 | 描述 |
|---|
| <文本> | 帖子内容(位置参数) |
| --image <路径> |
图片文件(可重复,最多 4 个) |
| --submit | 发布(默认:预览) |
| --profile <目录> | 自定义 Chrome 配置文件 |
视频帖子
文本 + 视频文件。
bash
npx -y bun ${SKILL_DIR}/scripts/x-video.ts 看看这个! --video ./clip.mp4 # 预览
npx -y bun ${SKILL_DIR}/scripts/x-video.ts 精彩内容 --video ./demo.mp4 --submit # 发布
参数:
| 参数 | 描述 |
|---|
| <文本> | 帖子内容(位置参数) |
| --video <路径> |
视频文件(MP4、MOV、WebM) |
| --submit | 发布(默认:预览) |
| --profile <目录> | 自定义 Chrome 配置文件 |
限制:普通用户最长 140 秒,高级用户最长 60 分钟。处理时间:30-60 秒。
引用推文
引用现有推文并添加评论。
bash
npx -y bun ${SKILL_DIR}/scripts/x-quote.ts https://x.com/user/status/123 很有见地! # 预览
npx -y bun ${SKILL_DIR}/scripts/x-quote.ts https://x.com/user/status/123 我同意! --submit # 发布
参数:
| 参数 | 描述 |
|---|
| <推文-URL> | 要引用的 URL(位置参数) |
| <评论> |
评论文本(位置参数,可选) |
| --submit | 发布(默认:预览) |
| --profile <目录> | 自定义 Chrome 配置文件 |
X 文章
长文 Markdown 文章(需要 X Premium)。
bash
npx -y bun ${SKILL_DIR}/scripts/x-article.ts article.md # 预览
npx -y bun ${SKILL_DIR}/scripts/x-article.ts article.md --cover ./cover.jpg # 带封面
npx -y bun ${SKILL_DIR}/scripts/x-article.ts article.md --submit # 发布
参数:
| 参数 | 描述 |
|---|
| <markdown> | Markdown 文件(位置参数) |
| --cover <路径> |
封面图片 |
| --title <文本> | 覆盖标题 |
| --submit | 发布(默认:预览) |
前置元数据:支持 YAML 前置元数据中的 title、cover_image。
注意事项
- - 首次运行:需要手动登录(会话会持久保存)
- 始终在 --submit 前预览
- 跨平台:macOS、Linux、Windows
扩展支持
通过 EXTEND.md 进行自定义配置。参见偏好设置部分了解路径和支持的选项。