Skip to content

ataoytun/fix-claude-export

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

fix-claude-export

Fix saved Claude.ai HTML pages so they actually work offline.

The Problem

Saving a Claude conversation with Save As > Complete Webpage gives you a white page. The crossorigin attribute on the CSS <link> tag triggers CORS checks that fail on file://, the React app needs 17+ CDN modules that aren't saved locally, and Intercom/analytics scripts throw errors on every load.

The conversation content is already in the HTML. It just needs the CSS unblocked and the dead JavaScript removed.

What This Does

fix_claude_export.py is a Python script that patches saved Claude.ai HTML files for offline viewing. It strips broken resources and optionally injects lightweight JavaScript to restore interactive features.

HTML cleanup (patches 1-3):

  • Fixes the CORS-blocked stylesheet so the page renders
  • Removes dead React bundle, CDN preloads, manifest, favicons, font preloads
  • Removes Intercom chat widget (iframe, scripts, styles)
  • Replaces missing preview image references with a transparent placeholder

Interactive features (patches 4-8):

  • Show more / Show less toggle for truncated messages
  • Thinking panel expand/collapse with a console warning about empty panels
  • Working copy buttons for messages and code blocks (green checkmark animation)
  • Scroll to bottom button
  • Disables offline-only buttons (Retry, Edit, Version nav) with a red hover indicator

Quick Start

python fix_claude_export.py --all page.html           # patch everything
python fix_claude_export.py page.html                  # interactive patch selection
python fix_claude_export.py --all -r ~/claude-exports  # recursive
python fix_claude_export.py --all --backup page.html   # backup first

Interactive Mode

Run without --all to get a checkbox menu:

  Select patches to apply:

    [x] 1. Core: Fix CORS CSS, remove dead scripts & resources
    [x] 2. Remove Intercom chat widget
    [x] 3. Fix broken preview images
    [x] 4. Show more / Show less toggle for messages
    [x] 5. Thinking panel expand/collapse (+ empty panel warning)
    [x] 6. Copy buttons (action bar + code blocks)
    [x] 7. Scroll to bottom button
    [x] 8. Disable offline buttons (Retry, Edit, Version nav)

  Toggle: type numbers (e.g. '3 5'), 'a'=all, 'n'=none
  Apply selected [Enter] >

Type numbers to toggle patches off, press Enter to apply.

CLI Reference

usage: fix_claude_export.py [-h] [-r] [-b] [-a] [-s SELECT] [paths ...]

positional arguments:
  paths                 HTML files or directories (default: current dir)

options:
  -r, --recursive       recurse into subdirectories
  -b, --backup          create .bak before patching
  -a, --all             apply all patches, skip the menu
  -s, --select SELECT   comma-separated patch numbers (e.g. '1,2,3,6')

Preserving Thinking Panels

Thinking panel content lives in React state, not in the DOM. If a panel was collapsed when you saved the page, its content is missing and can't be recovered.

The patcher detects empty panels, disables their toggles, and logs a warning:

[Claude Export Patcher] 12 thinking panel(s) saved without content.
Thinking content lives in React state and is NOT captured by "Save As".
To fix: expand all thinking panels BEFORE saving the page.

expand-thinking-panels.js

A helper script you run in the browser console before saving the page. It clicks every collapsed thinking panel and hits "Show more" inside each one to make sure the full content is in the DOM.

  1. Open your conversation on claude.ai
  2. Open the browser console (F12 > Console)
  3. Paste the contents of expand-thinking-panels.js and press Enter
  4. Wait for it to finish (progress is logged to console)
  5. Save the page (Ctrl+S > "Webpage, Complete")
  6. Run fix_claude_export.py on the saved file

How It Works

The patcher identifies Claude pages by checking for data-theme="claude" in the first 4KB. Files inside _files companion directories are skipped automatically. Already-patched files are detected by a version marker in the injected script. Running a newer version of the patcher will upgrade older patches in place.

Requirements

Python 3.8+ with no external dependencies.

About

python tool to fix saved Claude.ai HTML pages for offline viewing by patching CORS-blocked CSS, removing dead scripts, and restoring interactive features like copy buttons and expand/collapse toggles.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors