Post to Weibo
Posts text, images, videos, and long-form articles to Weibo 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
{baseDir} in this document with the actual path - Resolve
${BUN_X} runtime: if bun installed → bun; if npx available → npx -y bun; else suggest installing bun
Script Reference:
| Script | Purpose |
|---|
| INLINECODE9 | Regular posts (text + images) |
| INLINECODE10 |
Headline article publishing (Markdown) |
|
scripts/copy-to-clipboard.ts | Copy content to clipboard |
|
scripts/paste-from-clipboard.ts | Send real paste keystroke |
Preferences (EXTEND.md)
Check EXTEND.md existence (priority order):
CODEBLOCK0
CODEBLOCK1
┌──────────────────────────────────────────────────┬───────────────────┐
│ Path │ Location │
├──────────────────────────────────────────────────┼───────────────────┤
│ .baoyu-skills/baoyu-post-to-weibo/EXTEND.md │ Project directory │
├──────────────────────────────────────────────────┼───────────────────┤
│ $HOME/.baoyu-skills/baoyu-post-to-weibo/EXTEND.md│ User home │
└──────────────────────────────────────────────────┴───────────────────┘
┌───────────┬───────────────────────────────────────────────────────────────────────────┐
│ Result │ Action │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ Found │ Read, parse, apply settings │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ Not found │ Use defaults │
└───────────┴───────────────────────────────────────────────────────────────────────────┘
EXTEND.md Supports: Default Chrome profile
Prerequisites
- - Google Chrome or Chromium
- INLINECODE13 runtime
- First run: log in to Weibo manually (session saved)
Regular Posts
Text + images/videos (max 18 files total). Posted on Weibo homepage.
CODEBLOCK2
Parameters:
| Parameter | Description |
|---|
| INLINECODE14 | Post content (positional) |
| INLINECODE15 |
Image file (repeatable) |
|
--video <path> | Video file (repeatable) |
|
--profile <dir> | Custom Chrome profile |
Note: Script opens browser with content filled in. User reviews and publishes manually.
Headline Articles (头条文章)
Long-form Markdown articles published at https://card.weibo.com/article/v3/editor.
CODEBLOCK3
Parameters:
| Parameter | Description |
|---|
| INLINECODE19 | Markdown file (positional) |
| INLINECODE20 |
Cover image |
|
--title <text> | Override title (max 32 chars, truncated if longer) |
|
--summary <text> | Override summary (max 44 chars, auto-regenerated if longer) |
|
--profile <dir> | Custom Chrome profile |
Frontmatter: title, summary, cover_image supported in YAML front matter.
Character Limits:
- - Title: 32 characters max (truncated with warning if longer)
- Summary/导语: 44 characters max (auto-regenerated from content if longer)
Markdown-to-HTML: Do NOT pass any --theme parameter when converting markdown to HTML. Use the default theme (no theme argument).
Article Workflow:
- 1. Opens INLINECODE28
- Clicks "写文章" button, waits for editor to become editable
- Fills title (validated for 32-char limit)
- Fills summary/导语 (validated for 44-char limit)
- Inserts HTML content into ProseMirror editor via paste
- Replaces image placeholders one by one (copy image → select placeholder → paste)
Post-Composition Check: The script automatically verifies after all images are inserted:
- - Remaining
WBIMGPH_ placeholders in editor content - Expected vs actual image count
If the check fails (warnings in output), alert the user with the specific issues before they publish.
Post Type Selection
Unless the user explicitly specifies the post type:
- - Markdown file (
.md) → Headline Article (头条文章) - Plain text / text with images → Regular Post
Troubleshooting
Chrome debug port not ready
If a script fails with Chrome debug port not ready or Unable to connect, kill only the CDP Chrome instances (those with --remote-debugging-port AND the baoyu-skills profile), then retry:
CODEBLOCK4
CRITICAL: Never kill all Chrome processes (pkill -f "Google Chrome"). Only kill Chrome instances launched by CDP with the baoyu-skills profile directory. The user may have regular Chrome windows open.
Important: This should be done automatically -- when encountering this error, kill the CDP Chrome instances and retry the command without asking the user.
Notes
- - First run: manual login required (session persists)
- All scripts only fill content into the browser, user must review and publish manually
- Cross-platform: macOS, Linux, Windows
Extension Support
Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
发布到微博
通过真实的Chrome浏览器(绕过反机器人检测)将文本、图片、视频和长文发布到微博。
脚本目录
重要:所有脚本均位于此技能的 scripts/ 子目录中。
代理执行说明:
- 1. 确定此 SKILL.md 文件的目录路径为 {baseDir}
- 脚本路径 = {baseDir}/scripts/<脚本名称>.ts
- 将本文档中的所有 {baseDir} 替换为实际路径
- 解析 ${BUN_X} 运行时:若已安装 bun → bun;若可用 npx → npx -y bun;否则建议安装 bun
脚本参考:
| 脚本 | 用途 |
|---|
| scripts/weibo-post.ts | 普通帖子(文本+图片) |
| scripts/weibo-article.ts |
头条文章发布(Markdown) |
| scripts/copy-to-clipboard.ts | 复制内容到剪贴板 |
| scripts/paste-from-clipboard.ts | 发送真实粘贴按键 |
偏好设置(EXTEND.md)
检查 EXTEND.md 是否存在(优先级顺序):
bash
macOS, Linux, WSL, Git Bash
test -f .baoyu-skills/baoyu-post-to-weibo/EXTEND.md && echo project
test -f ${XDG
CONFIGHOME:-$HOME/.config}/baoyu-skills/baoyu-post-to-weibo/EXTEND.md && echo xdg
test -f $HOME/.baoyu-skills/baoyu-post-to-weibo/EXTEND.md && echo user
powershell
PowerShell (Windows)
if (Test-Path .baoyu-skills/baoyu-post-to-weibo/EXTEND.md) { project }
$xdg = if ($env:XDG
CONFIGHOME) { $env:XDG
CONFIGHOME } else { $HOME/.config }
if (Test-Path $xdg/baoyu-skills/baoyu-post-to-weibo/EXTEND.md) { xdg }
if (Test-Path $HOME/.baoyu-skills/baoyu-post-to-weibo/EXTEND.md) { user }
┌──────────────────────────────────────────────────┬───────────────────┐
│ 路径 │ 位置 │
├──────────────────────────────────────────────────┼───────────────────┤
│ .baoyu-skills/baoyu-post-to-weibo/EXTEND.md │ 项目目录 │
├──────────────────────────────────────────────────┼───────────────────┤
│ $HOME/.baoyu-skills/baoyu-post-to-weibo/EXTEND.md│ 用户主目录 │
└──────────────────────────────────────────────────┴───────────────────┘
┌───────────┬───────────────────────────────────────────────────────────┐
│ 结果 │ 操作 │
├───────────┼───────────────────────────────────────────────────────────┤
│ 找到 │ 读取、解析、应用设置 │
├───────────┼───────────────────────────────────────────────────────────┤
│ 未找到 │ 使用默认设置 │
└───────────┴───────────────────────────────────────────────────────────┘
EXTEND.md 支持:默认 Chrome 配置文件
前置条件
- - Google Chrome 或 Chromium
- bun 运行时
- 首次运行:手动登录微博(会话会保存)
普通帖子
文本 + 图片/视频(总共最多 18 个文件)。发布在微博首页。
bash
${BUN_X} {baseDir}/scripts/weibo-post.ts 你好微博! --image ./photo.png
${BUN_X} {baseDir}/scripts/weibo-post.ts 看这个 --video ./clip.mp4
参数:
| 参数 | 描述 |
|---|
| <text> | 帖子内容(位置参数) |
| --image <路径> |
图片文件(可重复) |
| --video <路径> | 视频文件(可重复) |
| --profile <目录> | 自定义 Chrome 配置文件 |
注意:脚本会打开浏览器并填充内容。用户需自行审核并手动发布。
头条文章
长格式 Markdown 文章,发布在 https://card.weibo.com/article/v3/editor。
bash
${BUN_X} {baseDir}/scripts/weibo-article.ts article.md
${BUN_X} {baseDir}/scripts/weibo-article.ts article.md --cover ./cover.jpg
参数:
| 参数 | 描述 |
|---|
| <markdown> | Markdown 文件(位置参数) |
| --cover <路径> |
封面图片 |
| --title <文本> | 覆盖标题(最多 32 字符,超出则截断) |
| --summary <文本> | 覆盖摘要(最多 44 字符,超出则自动重新生成) |
| --profile <目录> | 自定义 Chrome 配置文件 |
Frontmatter:支持 YAML 前置元数据中的 title、summary、cover_image。
字符限制:
- - 标题:最多 32 个字符(超出则截断并发出警告)
- 摘要/导语:最多 44 个字符(超出则从内容自动重新生成)
Markdown 转 HTML:转换 Markdown 为 HTML 时,请勿传递任何 --theme 参数。使用默认主题(无主题参数)。
文章工作流程:
- 1. 打开 https://card.weibo.com/article/v3/editor
- 点击写文章按钮,等待编辑器变为可编辑状态
- 填写标题(验证 32 字符限制)
- 填写摘要/导语(验证 44 字符限制)
- 通过粘贴将 HTML 内容插入 ProseMirror 编辑器
- 逐个替换图片占位符(复制图片 → 选择占位符 → 粘贴)
发布后检查:脚本会在所有图片插入后自动验证:
- - 编辑器中剩余的 WBIMGPH_ 占位符
- 预期图片数量与实际图片数量
如果检查失败(输出中有警告),在用户发布前提醒具体问题。
帖子类型选择
除非用户明确指定帖子类型:
- - Markdown 文件(.md) → 头条文章
- 纯文本 / 带图片的文本 → 普通帖子
故障排除
Chrome 调试端口未就绪
如果脚本因 Chrome 调试端口未就绪 或 无法连接 而失败,请仅终止 CDP Chrome 实例(那些带有 --remote-debugging-port 且使用 baoyu-skills 配置文件的实例),然后重试:
bash
pkill -f remote-debugging-port.*baoyu-skills/chrome-profile 2>/dev/null; sleep 2
关键:切勿终止所有 Chrome 进程(pkill -f Google Chrome)。仅终止由 CDP 启动且使用 baoyu-skills 配置文件目录的 Chrome 实例。用户可能打开了常规的 Chrome 窗口。
重要:此操作应自动执行——遇到此错误时,终止 CDP Chrome 实例并重试命令,无需询问用户。
注意事项
- - 首次运行:需要手动登录(会话会持久保存)
- 所有脚本仅将内容填充到浏览器中,用户必须审核并手动发布
- 跨平台:macOS、Linux、Windows
扩展支持
通过 EXTEND.md 进行自定义配置。参见偏好设置部分了解路径和支持的选项。