Anki add-on: Inline CSS Cleanup

Inline CSS Cleanup Remove inline <style>…</style> blocks from selected note fields and move the CSS into collection.media/_extracted_css.css , with selector-level deduplication. This is useful when large HTML fields (e.g., Yomitan/JP mining glossaries) embed repeated CSS, bloating collection.anki2 and pushing you over AnkiWeb size limits. What It Does Strips inline <style>…</style> blocks from configured fields Extracts CSS and deduplicates by selector (first occurrence wins) Writes the CSS to collection.media/_extracted_css.css Inserts a small <style>@import ...</style> into the field to load the CSS Usage Tools → Inline CSS Cleanup Confirm the prompt Review the summary dialog Run Check Database to shrink the collection file after cleanup Example Screenshot Configuration See config.md for detailed configuration. Quick defaults (from config.json ): { "note_types": ["Lapis"], "fields": ["Glossary", "MainDefinition"], "confirm_before_run": true, "extract_inline_styles": false, "inline_style_min_length": 80, "inline_style_min_ratio": 0.05 } Notes & Safety The add-on does not modify template Styling (useful if your Styling is auto-generated). Re-running is safe and idempotent: it will not duplicate imports or rules. Consider backing up your collection before the first run. Inline style extraction thresholds are based on the number of notes containing inline styles. Extracted CSS is stored in collection.media/_extracted_css.css and also mirrored to user_files/extracted_css.css (easier to find).

GitHub repository: l-m-sherlock/inline_css_cleanup
Languages: Python, Shell