$npx -y skills add freestylefly/canghe-skills --skill canghe-url-to-markdownFetch any URL and convert to markdown using Chrome CDP. Supports two modes - auto-capture on page load, or wait for user signal (for pages requiring login). Use when user wants to save a webpage as markdown.
| 1 | # URL to Markdown |
| 2 | |
| 3 | Fetches any URL via Chrome CDP and converts HTML to clean markdown. |
| 4 | |
| 5 | ## Script Directory |
| 6 | |
| 7 | **Important**: All scripts are located in the `scripts/` subdirectory of this skill. |
| 8 | |
| 9 | **Agent Execution Instructions**: |
| 10 | 1. Determine this SKILL.md file's directory path as `SKILL_DIR` |
| 11 | 2. Script path = `${SKILL_DIR}/scripts/<script-name>.ts` |
| 12 | 3. Replace all `${SKILL_DIR}` in this document with the actual path |
| 13 | |
| 14 | **Script Reference**: |
| 15 | | Script | Purpose | |
| 16 | |--------|---------| |
| 17 | | `scripts/main.ts` | CLI entry point for URL fetching | |
| 18 | |
| 19 | ## Preferences (EXTEND.md) |
| 20 | |
| 21 | Use Bash to check EXTEND.md existence (priority order): |
| 22 | |
| 23 | ```bash |
| 24 | # Check project-level first |
| 25 | test -f .canghe-skills/canghe-url-to-markdown/EXTEND.md && echo "project" |
| 26 | |
| 27 | # Then user-level (cross-platform: $HOME works on macOS/Linux/WSL) |
| 28 | test -f "$HOME/.canghe-skills/canghe-url-to-markdown/EXTEND.md" && echo "user" |
| 29 | ``` |
| 30 | |
| 31 | ┌────────────────────────────────────────────────────────┬───────────────────┐ |
| 32 | │ Path │ Location │ |
| 33 | ├────────────────────────────────────────────────────────┼───────────────────┤ |
| 34 | │ .canghe-skills/canghe-url-to-markdown/EXTEND.md │ Project directory │ |
| 35 | ├────────────────────────────────────────────────────────┼───────────────────┤ |
| 36 | │ $HOME/.canghe-skills/canghe-url-to-markdown/EXTEND.md │ User home │ |
| 37 | └────────────────────────────────────────────────────────┴───────────────────┘ |
| 38 | |
| 39 | ┌───────────┬───────────────────────────────────────────────────────────────────────────┐ |
| 40 | │ Result │ Action │ |
| 41 | ├───────────┼───────────────────────────────────────────────────────────────────────────┤ |
| 42 | │ Found │ Read, parse, apply settings │ |
| 43 | ├───────────┼───────────────────────────────────────────────────────────────────────────┤ |
| 44 | │ Not found │ Use defaults │ |
| 45 | └───────────┴───────────────────────────────────────────────────────────────────────────┘ |
| 46 | |
| 47 | **EXTEND.md Supports**: Default output directory | Default capture mode | Timeout settings |
| 48 | |
| 49 | ## Features |
| 50 | |
| 51 | - Chrome CDP for full JavaScript rendering |
| 52 | - Two capture modes: auto or wait-for-user |
| 53 | - Clean markdown output with metadata |
| 54 | - Handles login-required pages via wait mode |
| 55 | |
| 56 | ## Usage |
| 57 | |
| 58 | ```bash |
| 59 | # Auto mode (default) - capture when page loads |
| 60 | npx -y bun ${SKILL_DIR}/scripts/main.ts <url> |
| 61 | |
| 62 | # Wait mode - wait for user signal before capture |
| 63 | npx -y bun ${SKILL_DIR}/scripts/main.ts <url> --wait |
| 64 | |
| 65 | # Save to specific file |
| 66 | npx -y bun ${SKILL_DIR}/scripts/main.ts <url> -o output.md |
| 67 | ``` |
| 68 | |
| 69 | ## Options |
| 70 | |
| 71 | | Option | Description | |
| 72 | |--------|-------------| |
| 73 | | `<url>` | URL to fetch | |
| 74 | | `-o <path>` | Output file path (default: auto-generated) | |
| 75 | | `--wait` | Wait for user signal before capturing | |
| 76 | | `--timeout <ms>` | Page load timeout (default: 30000) | |
| 77 | |
| 78 | ## Capture Modes |
| 79 | |
| 80 | | Mode | Behavior | Use When | |
| 81 | |------|----------|----------| |
| 82 | | Auto (default) | Capture on network idle | Public pages, static content | |
| 83 | | Wait (`--wait`) | User signals when ready | Login-required, lazy loading, paywalls | |
| 84 | |
| 85 | **Wait mode workflow**: |
| 86 | 1. Run with `--wait` → script outputs "Press Enter when ready" |
| 87 | 2. Ask user to confirm page is ready |
| 88 | 3. Send newline to stdin to trigger capture |
| 89 | |
| 90 | ## Output Format |
| 91 | |
| 92 | YAML front matter with `url`, `title`, `description`, `author`, `published`, `captured_at` fields, followed by converted markdown content. |
| 93 | |
| 94 | ## Output Directory |
| 95 | |
| 96 | ``` |
| 97 | url-to-markdown/<domain>/<slug>.md |
| 98 | ``` |
| 99 | |
| 100 | - `<slug>`: From page title or URL path (kebab-case, 2-6 words) |
| 101 | - Conflict resolution: Append timestamp `<slug>-YYYYMMDD-HHMMSS.md` |
| 102 | |
| 103 | ## Environment Variables |
| 104 | |
| 105 | | Variable | Description | |
| 106 | |----------|-------------| |
| 107 | | `URL_CHROME_PATH` | Custom Chrome executable path | |
| 108 | | `URL_DATA_DIR` | Custom data directory | |
| 109 | | `URL_CHROME_PROFILE_DIR` | Custom Chrome profile directory | |
| 110 | |
| 111 | **Troubleshooting**: Chrome not found → set `URL_CHROME_PATH`. Timeout → increase `--timeout`. Complex pages → try `--wait` mode. |
| 112 | |
| 113 | ## Extension Support |
| 114 | |
| 115 | Custom configurations via EXTEND.md. See **Preferences** section for paths and supported options. |