System view
How Ranobe Gemini Works
A modular browser-extension architecture: content scripts for in-page UX, background orchestration for AI/backup flows, and storage-first state.
Runtime
Reader-to-Result Flow
Open chapter -> Detect handler -> Inject controls -> Check API key -> Process with background pipeline -> Render enhanced content + summary boxes
- A: User starts from any supported site chapter page.
- B: Site-specific handler is selected dynamically.
- G: Large chapters are chunked to avoid model timeout risk.
- I: Collapsible sections and style boxes are applied after model output.
Modular Design
Extension Component Map
UI modules -> Shared settings/storage -> Background orchestrator -> AI provider registry (Gemini, OpenAI-compatible, Ollama) + storage orchestrator (Drive, OneDrive, Dropbox, WebDAV, native sync), with content scripts and website handlers as isolated modules
- Website Handlers: One module per website keeps extraction logic isolated.
- Background Orchestrator: Centralizes API calls, alarms, and backup sync.
- Storage and Settings: Shared contract for popup, library, and content layers.
- AI Provider Registry: One adapter per provider behind a shared interface, so switching from Gemini to a local Ollama model changes a setting, not a code path.
- Storage Orchestrator: Optional module selecting the sync destination you configured; with it off you still have the full local workflow.
Reliability
Backup and Sync Decision Flow
Library change -> Mode decision (scheduled/continuous/both) -> Create backup artifact -> If Drive connected upload, else keep local history
- Both mode: Combines periodic safety points with near-real-time rolling backup.
- Drive connected? Backup always remains local-first; cloud sync is optional.
- User ownership: Backup files remain in the user's own Google Drive account.
Inter-Process Communication
Message Flow Between Contexts
Content -> Background: addToLibrary -> Storage: read -> Background: merge -> Storage: save -> Background: confirm -> Content: notify user
- Async Messaging: All cross-context communication uses browser.tabs.sendMessage with timeouts.
- Storage Contract: Background owns library state; content reads are query-only.
- Error Recovery: Failed messages trigger UI notifications and retry logic.
Data Model
Library Storage Schema Overview
📚 Novel Entry
Stores shelf ID, site novel ID, title, author, status, reading lists, metadata (characters, relationships, tags), chapter count, and URLs.
⚙️ Settings Object
API key, model selection, reading lists definitions, collapsible section types, backup mode, Drive credentials, and UI layout preferences.
📋 Backup History
Versioned and continuous backup metadata including filename, creation timestamp, Drive file ID, upload status, and reconciliation markers.
🔧 Handler Cache
Per-handler site-specific metadata, extraction patterns, URL templates, and favicon/icon fallback URLs for robust display.
Running State Example
| Key | Type | Purpose |
|---|---|---|
novels |
Object<novelId, Novel> | Central library indexed by generated novel IDs |
readingLists |
Array<{id, label}> | User-defined list definitions (rereading, favourites, custom) |
settings |
Object | User preferences and API/backup configuration |
backupHistory |
Array<BackupEntry> | Last 50 backup records with Drive sync status |
Site Integration
Handler Registration and Discovery
(*.handler.js)"] --> BR["Build Process
(build.js)"] BR --> HRG["Handler Registry
(generated)"] BR --> MAN["Manifest Domains
(updated)"] HRG --> CSS["Content Script
Loads Registry"] CSS --> DET["Runtime Detection
on Page Open"] MAN --> EXT["Extension Manifest
content_scripts"] EXT --> INJ["Inject Controls
on Matching Domains"]
Handler files -> build.js processes -> registry generated + manifest updated -> content script loads registry -> runtime detection on page -> inject controls on matching domains
- Auto-Registration: Adding a new file `*-handler.js` automatically registers it via build process.
- Dynamic Detection: Content script detects handler at runtime based on domain match patterns.
- Manifest Coupling: Handler domains automatically sync to manifest `content_scripts` matches.
State Machine
Novel Reading Status Lifecycle
PlanToRead -> Reading -> OnHold/Completed, Reading <-> Rereading (list toggle)
- Primary Status: Novel has one primary reading status at any time.
- Reading Lists: Independent list membership (rereading, favourites, custom) can be toggled via dropdown.
- Soft Transitions: Reading state can move between any status without validation.
URL Import Pipeline
Adaptive Batch Import with Deduplication
(raw list)"] --> B["Filter Supported
(by domain)"] B --> C["Extract Novel IDs
(per handler pattern)"] C --> D["Check Library
(existing novels)"] D --> E["Dedupe Batch
(same paste)"] E --> F{Queue
Ready} F -->|No matches| G["Report: Skipped all"] F -->|Has URLs| H["Build Canonical
(handler templates)"] H --> I["Open Background
Tabs"] I --> J["Send Add Messages
(explicit flow)"] J --> K["Close Tabs
(cleanup)"] K --> L["Report Results
(added/skipped/failed)"]
Paste URLs -> Filter domains -> Extract IDs -> Check existing -> Dedupe batch -> Build canonical -> Open tabs -> Send add messages -> Close tabs -> Report
- Handler-Driven: Each handler provides canonical URL template and extraction pattern.
- Existing Skip: Library is queried first; already-added novels are skipped silently.
- Batch Dedupe: Duplicates in the same paste are removed before processing.
- Explicit Flow: Import uses explicit addToLibrary messages, not passive tab opens.
Ready to Install
Install once, then verify every module yourself
Use published Firefox and Edge builds, or temporary install on Chromium browsers. Then open Library and inspect handlers, filters, and backups in action.