# dteviot/webtoepub architecture

> Architecture diagram of the GitHub repository dteviot/webtoepub, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dteviot/webtoepub
- Repository: https://github.com/dteviot/webtoepub

## Overview

WebToEpub is a browser extension that turns web novels and other pages into EPUB files for offline reading. The user selects a page and chapters, the extension extracts and packages content, then saves the EPUB or adds it to its library. The graph includes the principal parsing, image, packaging, and library capabilities, plus supported-site adapters. The README documents the product workflow, while sampled source confirms several UI actions; many internal calls and the full parser-to-export path were not shown, so those links are marked unverified.

Main entry points: [`plugin/js/main.js`](https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/main.js) (Conversion UI), [`plugin/js/Parser.js`](https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/Parser.js) (Parser framework), [`plugin/js/ParserFactory.js`](https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/ParserFactory.js) (Parser dispatch), [`plugin/js/parsers`](https://github.com/dteviot/webtoepub/tree/ExperimentalTabMode/plugin/js/parsers) (Site adapters)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Extension interface"]
  node_popup["Conversion UI<br/>[main.js]"]
  node_chapterui["Chapter selection<br/>[ChapterUrlsUI.js]"]
  node_parserui["Parser settings<br/>[DefaultParserUI.js]"]
  node_content["Page messaging<br/>[ContentScript.js]"]
end

subgraph group_acquisition["Page acquisition"]
  node_factory["Parser dispatch<br/>[ParserFactory.js]"]
  node_parser["Parser framework<br/>[Parser.js]"]
  node_siteparsers["Site adapters"]
  node_http["HTTP client<br/>[HttpClient.js]"]
end

subgraph group_conversion["EPUB conversion"]
  node_images["Image collection<br/>[ImageCollector.js]"]
  node_epubitem["EPUB items<br/>[EpubItem.js]"]
  node_metadata["EPUB metadata<br/>[EpubMetaInfo.js]"]
  node_packer["EPUB packaging<br/>[EpubPacker.js]"]
  node_download["File download<br/>[Download.js]"]
end

subgraph group_storage["Library and settings"]
  node_library[("Saved EPUB library<br/>[Library.js]")]
  node_preferences[("User preferences<br/>[UserPreferences.js]")]
end

node_reader(("Reader"))

node_reader -->|"chooses page"| node_popup
node_popup -.->|"selects chapters"| node_chapterui
node_popup -.->|"dispatches parser"| node_factory
node_factory -.->|"selects adapter"| node_siteparsers
node_siteparsers -.->|"uses framework"| node_parser
node_parser -.->|"fetches pages"| node_http
node_popup -.->|"requests page"| node_content
node_parser -.->|"collects images"| node_images
node_parser -.->|"creates items"| node_epubitem
node_popup -.->|"builds metadata"| node_metadata
node_popup -.->|"packages EPUB"| node_packer
node_popup -->|"saves file"| node_download
node_popup -->|"adds EPUB"| node_library
node_popup -->|"loads settings"| node_preferences
node_popup -.->|"configures parsing"| node_parserui

click node_popup "https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/main.js"
click node_chapterui "https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/ChapterUrlsUI.js"
click node_parserui "https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/DefaultParserUI.js"
click node_content "https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/ContentScript.js"
click node_factory "https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/ParserFactory.js"
click node_parser "https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/Parser.js"
click node_siteparsers "https://github.com/dteviot/webtoepub/tree/ExperimentalTabMode/plugin/js/parsers"
click node_http "https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/HttpClient.js"
click node_images "https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/ImageCollector.js"
click node_epubitem "https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/EpubItem.js"
click node_metadata "https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/EpubMetaInfo.js"
click node_packer "https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/EpubPacker.js"
click node_download "https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/Download.js"
click node_library "https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/Library.js"
click node_preferences "https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/UserPreferences.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_popup,node_chapterui,node_parserui,node_content toneBlue
class node_factory,node_parser,node_siteparsers,node_http toneAmber
class node_images,node_epubitem,node_metadata,node_packer,node_download toneMint
class node_library,node_preferences toneRose
class node_reader toneIndigo
```

## Components

### Extension interface

- [Conversion UI](https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/main.js): `plugin/js/main.js`
- [Chapter selection](https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/ChapterUrlsUI.js): `plugin/js/ChapterUrlsUI.js`
- [Parser settings](https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/DefaultParserUI.js): `plugin/js/DefaultParserUI.js`
- [Page messaging](https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/ContentScript.js): `plugin/js/ContentScript.js`

### Page acquisition

- [Parser dispatch](https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/ParserFactory.js): `plugin/js/ParserFactory.js`
- [Parser framework](https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/Parser.js): `plugin/js/Parser.js`
- [Site adapters](https://github.com/dteviot/webtoepub/tree/ExperimentalTabMode/plugin/js/parsers): `plugin/js/parsers`
- [HTTP client](https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/HttpClient.js): `plugin/js/HttpClient.js`

### EPUB conversion

- [Image collection](https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/ImageCollector.js): `plugin/js/ImageCollector.js`
- [EPUB items](https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/EpubItem.js): `plugin/js/EpubItem.js`
- [EPUB metadata](https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/EpubMetaInfo.js): `plugin/js/EpubMetaInfo.js`
- [EPUB packaging](https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/EpubPacker.js): `plugin/js/EpubPacker.js`
- [File download](https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/Download.js): `plugin/js/Download.js`

### Library and settings

- [Saved EPUB library](https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/Library.js): `plugin/js/Library.js`
- [User preferences](https://github.com/dteviot/webtoepub/blob/ExperimentalTabMode/plugin/js/UserPreferences.js): `plugin/js/UserPreferences.js`

### Other components

- **Reader**

## Connections

- Reader → Conversion UI: chooses page
- Conversion UI → Chapter selection: selects chapters
- Conversion UI → Parser dispatch: dispatches parser
- Parser dispatch → Site adapters: selects adapter
- Site adapters → Parser framework: uses framework
- Parser framework → HTTP client: fetches pages
- Conversion UI → Page messaging: requests page
- Parser framework → Image collection: collects images
- Parser framework → EPUB items: creates items
- Conversion UI → EPUB metadata: builds metadata
- Conversion UI → EPUB packaging: packages EPUB
- Conversion UI → File download: saves file (evidence: `plugin/js/main.js`)
- Conversion UI → Saved EPUB library: adds EPUB (evidence: `plugin/js/main.js`)
- Conversion UI → User preferences: loads settings (evidence: `plugin/js/main.js`)
- Conversion UI → Parser settings: configures parsing
