Skip to content

Zero-Cost Client-Side Web Novel Editing & Glossary Engine

Engineering DimensionArchitecture & Delivery Specification
Domain & ContextHigh-Volume Web Novel Editing, Translation Preprocessing & Text Normalization
Hosting & Infrastructure100% Client-Side Static Single Page Application (GitHub Pages / Cloudflare Pages / Local HTML)
External DependenciesZero paid APIs, zero external databases, zero third-party subscriptions
Large File ProcessingDedicated background Web Worker handling 5MB to 10MB+ TXT files (1.5M+ words) without UI lag
Data Isolation ModelPer-novel glossary sandboxing via local storage; glossaries never cross-pollinate
Precedence LogicNovel-specific terms take strict priority over global predefined dictionaries
Replacement DeterminismStrict regex word-boundary sorting by length descending to prevent prefix collisions

1. Live Interactive Demonstration

Experience the interactive standalone novel editor below. Upload English TXT files, manage isolated novel glossaries, apply priority word replacements, and download clean edited files with zero server overhead:

Private TXT Novel Editing Engine

Open Standalone ↗


2. High-Level Design (HLD) Architecture

Processing massive English text files directly on the browser UI thread freezes the user interface and causes browser crashes. By offloading dictionary compilation and string manipulation to an asynchronous Web Worker, the tool processes multi-megabyte novels smoothly with real-time percentage feedback:

[Raw English TXT (5MB - 10MB)]
│
▼
[Browser FileReader]
│
┌─────────┴─────────┐
│ Load Active Novel │ <─── [LocalStorage / IndexedDB]
└─────────┬─────────┘
▼
[Merge Dictionaries: Novel Takes Priority]
│
▼
[Spawn Dedicated Web Worker]
│
▼
[Sort Terms by Length Descending]
│
▼
[Chunked Regex Word-Boundary Replacement] ──> [Emit Progress %]
│
▼
[Generate Downloadable Text Blob]
│
▼
[Export Clean Edited TXT File]

10-Step Architectural Breakdown

  1. Requirements Clarity: Provide a zero-cost, private text normalization tool for English web novels before external translation, adhering to strict user glossaries.
  2. File Size Assumptions: Handle typical web novel volumes from 200,000 words (1.2 MB) up to 2,000,000 words (10 MB+) without memory leaks.
  3. High-Level Web Architecture: Serverless client-side architecture requiring no backend database, API keys, or operational maintenance.
  4. Data Isolation Design: Store novel profiles in structured local storage objects (novels[novelName].glossary), completely isolating character names and terminology per novel.
  5. Dictionary Precedence Engine: Deep merge global predefined terms (cultivation, fantasy terms) with novel-specific entries, where novel entries unconditionally overwrite global keys.
  6. Collision Avoidance: Sort replacement keys by string length in descending order before compiling the master regular expression, ensuring composite terms (Azure Cloud Sect Master) match before partial substrings (Azure Cloud Sect or Master).
  7. Thread Management: Execute text scanning in a dedicated Web Worker in 250KB memory chunks to keep the browser event loop responsive at 60 FPS.
  8. Fault Tolerance & Retry: Store uploaded file buffers in memory so users can modify glossaries and retry processing instantly without re-uploading the original file.
  9. Zero Creative Rewrite Invariant: Guarantee that text replacement is strictly literal and lexical, preserving sentence structure, numbers, and storyline meaning 100%.
  10. Delivery Packaging: Package as a single portable HTML file that functions both offline on a local laptop and hosted online on free edge static storage.

3. Core Engine Implementation

// Web Worker replacement kernel with length-descending sorting
self.onmessage = function(e) {
const { text, glossary, predefined } = e.data;
const startTime = Date.now();
// Combine dictionaries with novel glossary priority
const combined = { ...predefined, ...glossary };
// Sort terms by length descending to prevent partial match collisions
const terms = Object.keys(combined).sort((a, b) => b.length - a.length);
function escapeRegExp(s) {
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
// Compile unified word-boundary regular expression
const pattern = new RegExp('\\b(' + terms.map(escapeRegExp).join('|') + ')\\b', 'g');
let totalReplacements = 0;
const termHits = {};
const replacedText = text.replace(pattern, (match) => {
totalReplacements++;
termHits[match] = (termHits[match] || 0) + 1;
return combined[match] || match;
});
self.postMessage({
type: 'complete',
resultText: replacedText,
totalReplacements: totalReplacements,
uniqueMatched: Object.keys(termHits).length,
durationMs: Date.now() - startTime
});
};

4. Maintenance and Zero-Cost Warranty

Because this tool executes entirely within the client’s browser without external API tokens, backend microservices, or database servers:

  • Zero Ongoing Operational Costs: Never incurs server bills or subscription charges.
  • Permanent Code Stability: Zero risk of third-party API deprecation breaking core functionality.
  • Air-Gapped Privacy: Confidential novel manuscripts never leave the user’s local device.