baoyu-post-to-weibo

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Post to Weibo

发布到微博

Posts text, images, and long-form articles to Weibo via real Chrome browser (bypasses anti-bot detection).
通过真实Chrome浏览器向微博发布文字、图片和长文(可绕过反机器人检测)。

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
    SKILL_DIR
  2. Script path =
    ${SKILL_DIR}/scripts/<script-name>.ts
  3. Replace all
    ${SKILL_DIR}
    in this document with the actual path
  4. Resolve
    ${BUN_X}
    runtime: if
    bun
    installed →
    bun
    ; if
    npx
    available →
    npx -y bun
    ; else suggest installing bun
Script Reference:
ScriptPurpose
scripts/weibo-post.ts
Regular posts (text + images)
scripts/weibo-article.ts
Headline article publishing (Markdown)
scripts/copy-to-clipboard.ts
Copy content to clipboard
scripts/paste-from-clipboard.ts
Send real paste keystroke
重要提示:所有脚本都位于本skill的
scripts/
子目录下。
Agent执行说明:
  1. 确定本SKILL.md文件的目录路径为
    SKILL_DIR
  2. 脚本路径 =
    ${SKILL_DIR}/scripts/<script-name>.ts
  3. 将本文档中所有的
    ${SKILL_DIR}
    替换为实际路径
  4. 解析
    ${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
发送真实粘贴按键操作

Preferences (EXTEND.md)

偏好设置(EXTEND.md)

Check EXTEND.md existence (priority order):
bash
undefined
按优先级顺序检查EXTEND.md是否存在:
bash
undefined

macOS, Linux, WSL, Git Bash

macOS, Linux, WSL, Git Bash

test -f .baoyu-skills/baoyu-post-to-weibo/EXTEND.md && echo "project" test -f "$HOME/.baoyu-skills/baoyu-post-to-weibo/EXTEND.md" && echo "user"

```powershell
test -f .baoyu-skills/baoyu-post-to-weibo/EXTEND.md && echo "project" test -f "$HOME/.baoyu-skills/baoyu-post-to-weibo/EXTEND.md" && echo "user"

```powershell

PowerShell (Windows)

PowerShell (Windows)

if (Test-Path .baoyu-skills/baoyu-post-to-weibo/EXTEND.md) { "project" } if (Test-Path "$HOME/.baoyu-skills/baoyu-post-to-weibo/EXTEND.md") { "user" }

┌──────────────────────────────────────────────────┬───────────────────┐
│                       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
if (Test-Path .baoyu-skills/baoyu-post-to-weibo/EXTEND.md) { "project" } 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配置文件

Prerequisites

前置要求

  • Google Chrome or Chromium
  • bun
    runtime
  • First run: log in to Weibo manually (session saved)

  • Google Chrome或Chromium
  • bun
    运行时
  • 首次运行:手动登录微博(会话会被保存)

Regular Posts

常规微博发布

Text + up to 9 images. Posted on Weibo homepage.
bash
${BUN_X} ${SKILL_DIR}/scripts/weibo-post.ts "Hello Weibo!" --image ./photo.png
Parameters:
ParameterDescription
<text>
Post content (positional)
--image <path>
Image file (repeatable, max 9)
--profile <dir>
Custom Chrome profile
Note: Script opens browser with content filled in. User reviews and publishes manually.

支持文字+最多9张图片,发布到微博首页。
bash
${BUN_X} ${SKILL_DIR}/scripts/weibo-post.ts "Hello Weibo!" --image ./photo.png
参数说明:
参数描述
<text>
微博内容(位置参数)
--image <path>
图片文件(可重复添加,最多9张)
--profile <dir>
自定义Chrome配置文件目录
注意:脚本会打开浏览器并自动填充内容,用户审核后手动发布即可。

Headline Articles (头条文章)

头条文章

Long-form Markdown articles published at
https://card.weibo.com/article/v3/editor
.
bash
${BUN_X} ${SKILL_DIR}/scripts/weibo-article.ts article.md
${BUN_X} ${SKILL_DIR}/scripts/weibo-article.ts article.md --cover ./cover.jpg
Parameters:
ParameterDescription
<markdown>
Markdown file (positional)
--cover <path>
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)
Article Workflow:
  1. Opens
    https://card.weibo.com/article/v3/editor
  2. Clicks "写文章" button, waits for editor to become editable
  3. Fills title (validated for 32-char limit)
  4. Fills summary/导语 (validated for 44-char limit)
  5. Inserts HTML content into ProseMirror editor via paste
  6. 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.

长格式Markdown文章会发布到
https://card.weibo.com/article/v3/editor
bash
${BUN_X} ${SKILL_DIR}/scripts/weibo-article.ts article.md
${BUN_X} ${SKILL_DIR}/scripts/weibo-article.ts article.md --cover ./cover.jpg
参数说明:
参数描述
<markdown>
Markdown文件(位置参数)
--cover <path>
封面图片
--title <text>
自定义标题(最多32字符,超出会被截断)
--summary <text>
自定义摘要(最多44字符,超出会自动从内容生成)
--profile <dir>
自定义Chrome配置文件目录
Frontmatter支持:YAML front matter中支持
title
summary
cover_image
字段。
字符限制:
  • 标题:最多32个字符(超出会截断并给出警告)
  • 摘要/导语:最多44个字符(超出会自动从内容生成)
文章发布流程:
  1. 打开
    https://card.weibo.com/article/v3/editor
  2. 点击「写文章」按钮,等待编辑器可编辑
  3. 填充标题(会校验32字符限制)
  4. 填充摘要/导语(会校验44字符限制)
  5. 通过粘贴将HTML内容插入到ProseMirror编辑器
  6. 逐个替换图片占位符(复制图片→选中占位符→粘贴)
内容完成后校验:所有图片插入完成后脚本会自动校验:
  • 编辑器内容中是否还有剩余的
    WBIMGPH_
    占位符
  • 预期图片数量和实际图片数量是否一致
如果校验失败(输出中会有警告),在用户发布前提醒具体问题。

Troubleshooting

问题排查

Chrome debug port not ready

Chrome调试端口未就绪

If a script fails with
Chrome debug port not ready
or
Unable to connect
, kill existing Chrome CDP instances first, then retry:
bash
pkill -f "Chrome.*remote-debugging-port" 2>/dev/null; pkill -f "Chromium.*remote-debugging-port" 2>/dev/null; sleep 2
Important: This should be done automatically -- when encountering this error, kill Chrome CDP instances and retry the command without asking the user.
如果脚本运行失败并提示
Chrome debug port not ready
Unable to connect
,先杀掉现有的Chrome CDP实例,再重试:
bash
pkill -f "Chrome.*remote-debugging-port" 2>/dev/null; pkill -f "Chromium.*remote-debugging-port" 2>/dev/null; sleep 2
重要提示:该操作应该自动执行——遇到该错误时,无需询问用户,直接杀掉Chrome CDP实例并重试命令即可。

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
  • 首次运行:需要手动登录(会话会持久保存)
  • 所有脚本仅负责向浏览器填充内容,用户必须审核后手动发布
  • 跨平台支持:macOS, Linux, Windows

Extension Support

扩展支持

Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
可通过EXTEND.md自定义配置,路径和支持的选项见偏好设置部分。