首页 / 全部技能 / 内容创作 / canghe-post-to-x
内容创作 · freestylefly/canghe-skills

canghe-post-to-x

Posts content and articles to X (Twitter). Supports regular posts with images/videos and X Articles (long-form Markdown). Uses real Chrome with CDP to bypass anti-automation. Use when user asks to "post to X", "tweet", "publish to Twitter", or "share on X".

L5 严管 · 隔离环境与严格审计V2 已复核条款/合规凭据/登录态执行命令联网读写文件Dual-pass Audit
Author freestyleflyGitHub freestylefly/canghe-skills ↗License MIT(仓库根 LICENSE)Commit dd0bf35595
管控等级描述 skill 的能力与建议配套的管控措施,不代表质量或安全认证,也不表示可用或不可用。是否使用由用户和管理者决定。不同 agent 宿主对权限的约束各不相同,请勿假定宿主一定会提供安全兜底。第三方 skill 版权归原作者,使用风险由使用者自行承担。

1实现原理 · 为什么它能做到

不用 Playwright/Puppeteer,而是驱动真实 Chrome(CDP)把内容填进 X 真实 UI,官方描述即声明目的是绕过反自动化检测。

skills/canghe-post-to-x/SKILL.md
Posts text, images, videos, and long-form articles to X via real Chrome browser (bypasses anti-bot detection).
这里在做什么:SKILL.md 首句把路线动机写死;实现是持久 profile 的真实 Chrome + CDP 会话。

四类内容(常规帖/视频帖/引用/长文)共用同一套 Chrome/CDP 基建与剪贴板子系统。

skills/canghe-post-to-x/SKILL.md
| `scripts/x-video.ts` | Video posts (text + video) |
这里在做什么:Script Reference 表列出各入口脚本;每个脚本各自拉真实 Chrome,参数模型一致。

关键绕过手段:不用 CDP 合成键事件,而用 osascript 发真实 Cmd+V,因为 X 会检测并忽略合成事件。

skills/canghe-post-to-x/references/regular-posts.md
Sends real Cmd+V keystroke to Chrome, bypassing CDP's synthetic events that X can detect
这里在做什么:Image Paste Mechanism 段落解释——CDP 合成键盘事件可被网站识别,故改用系统级真实键击。

启动参数主动关闭自动化特征标志。

skills/canghe-post-to-x/scripts/x-browser.ts
'--disable-blink-features=AutomationControlled',
这里在做什么:x-article/x-browser/x-quote/x-video 四个脚本均带该参数,抹掉 navigator.webdriver 类痕迹。

长文路径:md-to-html.ts 解析 frontmatter/封面并把正文图替换为 XIMGPH_n 占位符,x-article.ts 经 CDP 填编辑器后反向替换占位符插入图片。

skills/canghe-post-to-x/references/articles.md
"placeholder": "XIMGPH_1",
这里在做什么:占位符 + 逐个定位替换是 X Articles 编辑器不接受剪贴板贴图时的替代方案。

剪贴板/键击子系统跨平台:Linux 用 xdotool/ydotool,macOS 用 osascript,Windows 用 PowerShell SendKeys。

skills/canghe-post-to-x/scripts/paste-from-clipboard.ts
{ cmd: 'xdotool', args: ['key', 'ctrl+v'] },
这里在做什么:paste() 按 process.platform 分派;图片先经 copy-to-clipboard.ts(macOS 用内联 Swift)写入系统剪贴板。

默认只填充不发布:脚本把内容填好后停下等人工复核,长文仅 --submit 才真正发布。

skills/canghe-post-to-x/references/articles.md
10. **Publish**: Only with `--submit` flag
这里在做什么:Workflow 第 9-10 步明写浏览器停留预览,发布必须显式 --submit。

预检脚本检查 Chrome、profile 隔离、Bun、辅助功能、剪贴板、粘贴键与 Chrome 冲突。

skills/canghe-post-to-x/SKILL.md
Checks: Chrome, profile isolation, Bun, Accessibility, clipboard, paste keystroke, Chrome conflicts.
这里在做什么:check-paste-permissions.ts 为可选前置体检,失败给出逐项修复指引。

首次运行需人工登录,会话持久化到 profile。

skills/canghe-post-to-x/SKILL.md
- First run: log in to X manually (session saved)
这里在做什么:Prerequisites/Notes 说明用持久 profile 保存登录态,后续脚本复用。

2核心能力

01发常规帖(文字 + 最多 4 图)
02发视频帖(MP4/MOV/WebM)
03引用转发并附评论
04发布 X 长文(Markdown,需 X Premium)
05Markdown → HTML 转换(含封面与正文图片占位符)
06真实键击粘贴(绕开可被检测的 CDP 合成事件)
07多平台剪贴板/键击适配(macOS/Linux/Windows)
08环境预检(Chrome/权限/剪贴板/键击/冲突)与默认人工复核发布

3外部依赖

KindDependency / Endpoint
networkX 编辑器页面(浏览器端访问)
clibun(经 npx -y 即时拉取)
cliGoogle Chrome / Chromium(CDP)
cli真实键击工具:osascript / xdotool / ydotool / powershell.exe
packagemarked / highlight.js / front-matter / remark-*(md 转换)
mcpPlaywright MCP(可选的手工工作流示例调用)

4管控建议与判定依据

建议配套管控措施
面向 Agent
隔离环境,逐次授权
面向管理者
严格授权、全量审计、合规确认
判定依据(文件路径与关键语句摘要)
  • SKILL.md / 脚本参数: 包含绕过自动化检测、关闭宿主沙箱或跳过 SSL 证书校验
  • SKILL.md / 会话存储: 读取或复用浏览器用户登录态与会话 Cookie
  • scripts/: 执行本地脚本或命令: npx -y bun ${SKILL_DIR}/scripts/x-browser.ts / x-video.ts / x-quote.ts / x-
  • 网络端点: 声明外部网络访问: CDP 端口发现 http://127.0.0.1:<port>/json/version 并以 WebSocket 连 CDP(x-utils.ts
  • 本地工作目录: 文件读写与工件输出: Chrome profile 目录(X_BROWSER_CHROME_PATH / profile 参数可改指向)
审计说明: (能力/策略级判定,非恶意植入)。红轴=反自动化侦测的技术性绕过:SKILL.md 明写 'bypasses anti-bot detection',regular-posts.md 解释为何改用真实 Cmd+V('bypassing CDP'\''s synthetic events that X can detect')并点名 'This approach bypasses X'\''s anti-automation detection that blocks Playwright/Puppeteer.';x-article/x-browser/x-quote/x-video 四脚本均带 --disable-blink-features=AutomationControlled。凭证面为共享 Chrome profile 的已登录 X 会话;--submit 会以用户账号发布不可逆内容。无凭证文件读取、无 TLS/沙箱降级、无混淆,故判红仅因绕过轴,与 baoyu-post-to-x 同族(先例 notebooklm-skill、baoyu-post-to-x)。

5第二遍独立确认

  • [ok] 反自动化绕过动机 — SKILL.md 描述、regular-posts.md 的 How It Works 与 paste-from-clipboard.ts 顶部注释三处一致声明绕过检测。
  • [ok] AutomationControlled 标志 — 风险扫描在 x-article.ts:117 / x-browser.ts:44 / x-quote.ts:48 / x-video.ts:48 四处定位同一参数,判红据成立。
  • [ok] 四条内容路径 — SKILL.md Script Reference 与各命令行示例互证 x-browser/x-video/x-quote/x-article 四个入口。
  • [ok] 剪贴板/键击跨平台适配 — paste-from-clipboard.ts 正文完整展开,pasteMac/pasteLinux/pasteWindows 分派逐字可核。
  • [ok] 长文占位符机制 — articles.md 的 images XIMGPH_n 与 Workflow 第 8 步『反向替换』描述自洽。
  • [ok] 凭证读取 — 「凭证/环境变量」39 条命中均为 ${SKILL_DIR}/$HOME/profile 参数与示例,未见密钥/cookie 文件读取;凭据即 profile 登录态,与结论一致。
  • [unlocatable] 主脚本的 CDP DOM 细节 — x-browser/x-video/x-quote/x-article.ts 全文未在 bundle 展开,文本注入与 DOM 操作细节以 SKILL.md/references 描述与扫描行为据,未代码级复核。
  • [ok] Playwright MCP 引用 — 仅出现在 regular-posts.md 的可选手工工作流示例,非脚本内置依赖,不改变档位。

6结论

  • 覆盖 X 的四类发布形态(常规帖/视频/引用/长文),一个 skill 内闭环。
  • 默认不自动发布:只填充内容并停留预览,发布需显式 --submit。
  • 剪贴板/键击子系统跨平台完备,并附环境预检与修复指引。
  • 适合: 需要把文字/图片/视频/长文发布到 X 的内容创作者,且接受以真实浏览器登录态半自动操作。
    不适合: 要求完全合规、不绕过平台自动化检测的场景;不愿复用真实 Chrome 登录态或授予辅助功能权限的环境。
    Install Agent-Ready
    ① Verified Mirror 2026-10-10
    Option A · Direct DownloadDownload canghe-post-to-x.tar.gz
    sha256: aa885729a2c33e40…
    Option B · Copy Guide for Agent
    install.json
    agent 读 JSON 指南后会自动从本站下载安装,无需更多说明。
    ② Upstream GitHub
    GitHub Repo ↗
    Pinned to commit dd0bf35595.