$npx -y skills add Dicklesworthstone/agent_flywheel_clawdbot_skills_and_integrations --skill csctfChat Shared Conversation To File - Convert ChatGPT, Gemini, Grok, and Claude share links to clean Markdown + HTML transcripts. Preserves code fences with language detection, deterministic filenames, GitHub Pages publishing. Bun-native CLI.
| 1 | # CSCTF — Chat Shared Conversation To File |
| 2 | |
| 3 | A Bun-native CLI that turns public ChatGPT, Gemini, Grok, and Claude share links into clean Markdown + HTML transcripts with preserved code fences, stable filenames, and optional GitHub Pages publishing. |
| 4 | |
| 5 | ## Why This Exists |
| 6 | |
| 7 | Copy/pasting AI share links often: |
| 8 | - **Breaks fenced code blocks** — loses formatting and structure |
| 9 | - **Loses language hints** — no syntax highlighting |
| 10 | - **Produces messy filenames** — random or unreadable names |
| 11 | - **Requires manual cleanup** — inconsistent formatting |
| 12 | |
| 13 | CSCTF fixes this with: |
| 14 | - **Stable slugs** — deterministic, collision-proof filenames |
| 15 | - **Language-preserving fences** — code blocks retain syntax hints |
| 16 | - **Normalized whitespace** — clean, consistent output |
| 17 | - **Static HTML twin** — no JS, ready for hosting/archiving |
| 18 | - **One-command GitHub Pages** — instant shareable microsite |
| 19 | |
| 20 | ## Quick Start |
| 21 | |
| 22 | ```bash |
| 23 | # Install |
| 24 | curl -fsSL https://raw.githubusercontent.com/Dicklesworthstone/chat_shared_conversation_to_file/main/install.sh | bash |
| 25 | |
| 26 | # Convert any share link |
| 27 | csctf https://chatgpt.com/share/69343092-91ac-800b-996c-7552461b9b70 |
| 28 | csctf https://gemini.google.com/share/66d944b0e6b9 |
| 29 | csctf https://grok.com/share/bGVnYWN5_d5329c61-f497-40b7-9472-c555fa71af9c |
| 30 | csctf https://claude.ai/share/549c846d-f6c8-411c-9039-a9a14db376cf |
| 31 | ``` |
| 32 | |
| 33 | Output: |
| 34 | - `<conversation_title>.md` — Clean Markdown with preserved code fences |
| 35 | - `<conversation_title>.html` — Styled static HTML (zero JavaScript) |
| 36 | |
| 37 | ## Supported Providers |
| 38 | |
| 39 | | Provider | URL Pattern | Method | Notes | |
| 40 | |----------|-------------|--------|-------| |
| 41 | | **ChatGPT** | `chatgpt.com/share/*` | Headless Chromium | Public shares only | |
| 42 | | **Gemini** | `gemini.google.com/share/*` | Headless Chromium | Public shares only | |
| 43 | | **Grok** | `grok.com/share/*` | Headless Chromium | Public shares only | |
| 44 | | **Claude** | `claude.ai/share/*` | Your Chrome session | Requires login | |
| 45 | |
| 46 | ### Claude.ai Special Handling |
| 47 | |
| 48 | Claude.ai uses Cloudflare protection that blocks standard browser automation. CSCTF handles this automatically: |
| 49 | |
| 50 | 1. Copies your Chrome session cookies to a temporary profile |
| 51 | 2. Launches Chrome with remote debugging enabled |
| 52 | 3. Connects via Chrome DevTools Protocol to extract conversation |
| 53 | 4. If Chrome is running, offers to save tabs, restart, and restore afterward |
| 54 | |
| 55 | **Requirements:** Chrome installed + logged into claude.ai in your regular Chrome session. |
| 56 | |
| 57 | ## Design Principles |
| 58 | |
| 59 | | Principle | Implementation | |
| 60 | |-----------|----------------| |
| 61 | | **Determinism** | Explicit slugging and collision handling | |
| 62 | | **Minimal network** | Only share URL fetched (update checks/publish opt-in) | |
| 63 | | **Safety** | Static HTML (inline CSS/HLJS), no scripts emitted | |
| 64 | | **Clarity** | Colorized step-based logging, confirmation gates | |
| 65 | | **Atomicity** | Temp+rename writes prevent partial files | |
| 66 | |
| 67 | ## How It Works |
| 68 | |
| 69 | ### ChatGPT, Gemini, Grok (End-to-End) |
| 70 | |
| 71 | ``` |
| 72 | 1. Launch headless Playwright Chromium with stealth config |
| 73 | (spoofed navigator properties, realistic headers) |
| 74 | 2. Navigate twice (domcontentloaded → networkidle) for late-loading assets |
| 75 | 3. Detect provider from URL hostname |
| 76 | 4. Wait for provider-specific selectors with retry/fallback |
| 77 | 5. Extract each role's inner HTML (assistant/user), traverse Shadow DOM |
| 78 | 6. Clean pills/metadata, run Turndown with fenced-code rule |
| 79 | 7. Normalize whitespace and newlines |
| 80 | 8. Write Markdown to temp file, rename atomically |
| 81 | 9. Render HTML twin with inline CSS/TOC/HLJS |
| 82 | ``` |
| 83 | |
| 84 | ### Claude.ai |
| 85 | |
| 86 | ``` |
| 87 | 1. Copy Chrome session cookies to temporary profile |
| 88 | 2. Launch Chrome with remote debugging |
| 89 | 3. Connect via Chrome DevTools Protocol |
| 90 | 4. Extract conversation HTML |
| 91 | 5. Process through same Turndown/normalization pipeline |
| 92 | 6. Clean up temporary profile |
| 93 | ``` |
| 94 | |
| 95 | ## Processing Algorithms |
| 96 | |
| 97 | ### Selector Strategy |
| 98 | Provider-specific selectors with fallback chains: |
| 99 | - **ChatGPT:** `article [data-message-author-role]` |
| 100 | - **Gemini:** Custom web components (`share-turn-viewer`, `response-container`) |
| 101 | - **Grok:** Flexible `data-testid` patterns |
| 102 | - **Claude:** `[data-testid="user-message"]` and streaming indicators |
| 103 | |
| 104 | Each has multiple fallbacks tried with short timeouts. |
| 105 | |
| 106 | ### Turndown Customization |
| 107 | - Injects fenced code blocks |
| 108 | - Detects language via `class="language-*"` |
| 109 | - Strips citation pills and `data-start`/`data-end` attributes |
| 110 | |
| 111 | ### Normalization |
| 112 | - Converts newlines to `\n` |
| 113 | - Removes Unicode LS/PS characters |
| 114 | - Collapses excessive blank lines |
| 115 | |
| 116 | ### Slugging Algorithm |
| 117 | ``` |
| 118 | Title → lowercase → non-alphanumerics → "_" → trim → max 120 chars |
| 119 | → Windows reserved-name suffix → collision suffix (_2, _3, ...) |
| 120 | ``` |
| 121 | |
| 122 | ### HTML Rendering |
| 123 | - Markdown-it + highlight.js |
| 124 | - Heading slug de-dupe for TOC |
| 125 | - Inline CSS for light/dark/print |
| 126 | - Zero JavaScript |
| 127 | |
| 128 | ## Command Reference |
| 129 | |
| 130 | ```bash |
| 131 | csctf <share-url> [o |