baoyu-danger-x-to-markdown

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

X to Markdown

X 转 Markdown

Converts X content to markdown:
  • Tweets/threads → Markdown with YAML front matter
  • X Articles → Full content extraction
将X内容转换为Markdown格式:
  • 推文/推文线程 → 带YAML前置元数据的Markdown
  • X文章 → 完整内容提取

Script Directory

脚本目录

Scripts located in
scripts/
subdirectory.
Path Resolution:
  1. SKILL_DIR
    = this SKILL.md's directory
  2. Script path =
    ${SKILL_DIR}/scripts/main.ts
脚本位于
scripts/
子目录中。
路径解析:
  1. SKILL_DIR
    = 本SKILL.md所在目录
  2. 脚本路径 =
    ${SKILL_DIR}/scripts/main.ts

Consent Requirement

同意要求

Before any conversion, check and obtain consent.
在进行任何转换之前,需检查并获得用户同意。

Consent Flow

同意流程

Step 1: Check consent file
bash
undefined
步骤1:检查同意文件
bash
undefined

macOS

macOS

cat ~/Library/Application\ Support/baoyu-skills/x-to-markdown/consent.json
cat ~/Library/Application\ Support/baoyu-skills/x-to-markdown/consent.json

Linux

Linux

cat ~/.local/share/baoyu-skills/x-to-markdown/consent.json

**Step 2**: If `accepted: true` and `disclaimerVersion: "1.0"` → print warning and proceed:
Warning: Using reverse-engineered X API. Accepted on: <acceptedAt>

**Step 3**: If missing or version mismatch → display disclaimer:
DISCLAIMER
This tool uses a reverse-engineered X API, NOT official.
Risks:
  • May break if X changes API
  • No guarantees or support
  • Possible account restrictions
  • Use at your own risk
Accept terms and continue?

Use `AskUserQuestion` with options: "Yes, I accept" | "No, I decline"

**Step 4**: On accept → create consent file:
```json
{
  "version": 1,
  "accepted": true,
  "acceptedAt": "<ISO timestamp>",
  "disclaimerVersion": "1.0"
}
Step 5: On decline → output "User declined. Exiting." and stop.
cat ~/.local/share/baoyu-skills/x-to-markdown/consent.json

**步骤2**:如果`accepted: true`且`disclaimerVersion: "1.0"` → 打印警告并继续:
Warning: Using reverse-engineered X API. Accepted on: <acceptedAt>

**步骤3**:如果文件缺失或版本不匹配 → 显示免责声明:
DISCLAIMER
This tool uses a reverse-engineered X API, NOT official.
Risks:
  • May break if X changes API
  • No guarantees or support
  • Possible account restrictions
  • Use at your own risk
Accept terms and continue?

使用`AskUserQuestion`函数,选项为:"Yes, I accept" | "No, I decline"

**步骤4**:用户同意后 → 创建同意文件:
```json
{
  "version": 1,
  "accepted": true,
  "acceptedAt": "<ISO timestamp>",
  "disclaimerVersion": "1.0"
}
步骤5:用户拒绝后 → 输出"User declined. Exiting."并停止操作。

Preferences (EXTEND.md)

偏好设置(EXTEND.md)

Use Bash to check EXTEND.md existence (priority order):
bash
undefined
使用Bash检查EXTEND.md文件是否存在(优先级顺序):
bash
undefined

Check project-level first

先检查项目级

test -f .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md && echo "project"
test -f .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md && echo "project"

Then user-level (cross-platform: $HOME works on macOS/Linux/WSL)

再检查用户级(跨平台:$HOME 在macOS/Linux/WSL中均适用)

test -f "$HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md" && echo "user"

┌────────────────────────────────────────────────────────────┬───────────────────┐
│                            Path                            │     Location      │
├────────────────────────────────────────────────────────────┼───────────────────┤
│ .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md         │ Project directory │
├────────────────────────────────────────────────────────────┼───────────────────┤
│ $HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md   │ User home         │
└────────────────────────────────────────────────────────────┴───────────────────┘

┌───────────┬───────────────────────────────────────────────────────────────────────────┐
│  Result   │                                  Action                                   │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ Found     │ Read, parse, apply settings                                               │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│ Not found │ Use defaults                                                              │
└───────────┴───────────────────────────────────────────────────────────────────────────┘

**EXTEND.md Supports**: Default output directory | Output format preferences
test -f "$HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md" && echo "user"

┌────────────────────────────────────────────────────────────┬───────────────────┐
│                            路径                            │        位置        │
├────────────────────────────────────────────────────────────┼───────────────────┤
│ .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md         │    项目目录        │
├────────────────────────────────────────────────────────────┼───────────────────┤
│ $HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md   │    用户主目录      │
└────────────────────────────────────────────────────────────┴───────────────────┘

┌───────────┬───────────────────────────────────────────────────────────────────────────┐
│   结果    │                                  操作                                   │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│   存在    │ 读取、解析并应用设置                                                     │
├───────────┼───────────────────────────────────────────────────────────────────────────┤
│   不存在  │ 使用默认设置                                                              │
└───────────┴───────────────────────────────────────────────────────────────────────────┘

**EXTEND.md支持**:默认输出目录 | 输出格式偏好设置

Usage

使用方法

bash
npx -y bun ${SKILL_DIR}/scripts/main.ts <url>
npx -y bun ${SKILL_DIR}/scripts/main.ts <url> -o output.md
npx -y bun ${SKILL_DIR}/scripts/main.ts <url> --json
bash
npx -y bun ${SKILL_DIR}/scripts/main.ts <url>
npx -y bun ${SKILL_DIR}/scripts/main.ts <url> -o output.md
npx -y bun ${SKILL_DIR}/scripts/main.ts <url> --json

Options

选项

OptionDescription
<url>
Tweet or article URL
-o <path>
Output path
--json
JSON output
--login
Refresh cookies only
选项描述
<url>
推文或文章链接
-o <path>
输出路径
--json
输出JSON格式
--login
仅刷新Cookie

Supported URLs

支持的链接

  • https://x.com/<user>/status/<id>
  • https://twitter.com/<user>/status/<id>
  • https://x.com/i/article/<id>
  • https://x.com/<user>/status/<id>
  • https://twitter.com/<user>/status/<id>
  • https://x.com/i/article/<id>

Output

输出示例

markdown
---
url: https://x.com/user/status/123
author: "Name (@user)"
tweet_count: 3
---

Content...
File structure:
x-to-markdown/{username}/{tweet-id}.md
markdown
---
url: https://x.com/user/status/123
author: "Name (@user)"
tweet_count: 3
---

内容...
文件结构:
x-to-markdown/{username}/{tweet-id}.md

Authentication

认证方式

  1. Environment variables (preferred):
    X_AUTH_TOKEN
    ,
    X_CT0
  2. Chrome login (fallback): Auto-opens Chrome, caches cookies locally
  1. 环境变量(推荐):
    X_AUTH_TOKEN
    X_CT0
  2. Chrome登录(备选):自动打开Chrome,在本地缓存Cookie

Extension Support

扩展支持

Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
可通过EXTEND.md进行自定义配置。路径及支持的选项请查看偏好设置章节。