Purification and replacement rules
Non-destructive display-layer text purification, Reader/Legado JSON and ZIP imports, regex capture groups, scoping, quick selection cleanup, and Isolate safety.
このページの内容
Origo X's purification system removes injected ads, watermarks, broken footers, or recurring typos strictly at the display layer. Rules never modify your original local TXT/EPUB files or online source caches—disabling or deleting a rule restores the original text immediately.
Importing Reader / Legado rule packs
Open Settings → Replacement rules (or select text in the reader and tap ⋯ → Purify selected text) to inspect, toggle, reorder, or import rules:
- Accepted formats: Imports Reader/Legado JSON arrays, single rule objects,
rules-wrapped JSON objects, or.ziparchives containing a single JSON file. - Size and count limits: Raw input and decompressed JSON are each capped at 8 MiB and 5,000 rules. ZIP imports stream-check headers and CRCs, reject encrypted archives and symlinks, and never unpack temp files to disk.
- Order and metadata preservation: Imported rules sort by
order(keeping input order on ties) and merge cleanly with existing rules. Names, groups, enabled flags, regex flags, title/body targets,scope,excludeScope,scopeSource,previewText, and timeouts are preserved.
Literal vs. regex rules and capture groups
Each rule operates in either literal plain-text mode or regular-expression mode:
- Literal replacement: Matches exact strings cleanly and unlocks the smooth in-reader deletion animation when removing unwanted text.
- Regex and capture groups: Supports standard regular expressions,
$1and${name}capture group references, and backslash escapes, including compatibility handling for trailing.*+patterns commonly exported from legacy rule packs. - Layout and projection sync: Updating rules invalidates derived pagination using the
replace-rules-v3cache key and prepares the full replacement snapshot in the background before publishing—preventing stale page numbers from pairing with updated text. Active Simplified/Traditional conversion and paragraph comment ranges are automatically rebuilt on top of the purified text.
Scoping (scope / excludeScope) and exclusion priority
Prevent a rule meant for one book or site from affecting the rest of your library:
- Exact matching:
scopeandexcludeScopematch when they contain the full book title or the book source origin URL (falling back to source name only if no origin URL exists). Matching is ASCII case-insensitive and never splits on commas or short words to accidentally match unrelated titles. - Exclusion always wins: If a book or source matches
excludeScope, the rule is skipped even if it also appears inscope.
Format applicability and EPUB protection
- Local TXT and online book-source text: Enabled by default for both chapter titles and body text.
- Local EPUB: Disabled by default to protect publisher formatting and complex layouts; you can opt in per book from its reader settings. When enabled on an EPUB, rules run across the full chapter text and map back cleanly to structural block boundaries—preserving paragraph breaks, illustrations/media, inline links, and text styles. Cross-span matches are kept in the first intersecting style block so replaced text never renders twice.
- Images, comics, and PDF: Text purification rules do not run on non-text readers.
Quick selection purification and anchor recovery
Clean up stray ads directly while reading without leaving your page:
- Select the unwanted text and choose ⋯ → Purify selected text from the glass toolbar.
- The rule editor pre-fills the selected snippet and scopes it to the current book.
- When you save an enabled, literal, empty-replacement (deletion) rule that still matches your active selection, the reader plays a 180 ms glyph fade-out animation on the targeted glyphs alone (instant when Reduce Motion is enabled) while neighboring text stays steady before publishing the repaginated page.
Exact reading-anchor preservation
Even if an identical ad appears dozens of times earlier in the chapter or a large deletion changes total page count, ReaderReplacementPosition keeps your place accurately:
- Literal rules compute cumulative offset deltas from every preceding match and verify that predicted text matches the new body before applying.
- When regex combinations or Chinese script conversion prevent exact prediction, a background Isolate matches surrounding invariant context and excerpts—landing safely on the nearest retained boundary even if an entire paragraph was deleted.
Isolate timeout safety and why @js: scripts stay disabled
- Terminable background Isolate: On native platforms, both literal and regex rules run inside a terminable background Isolate with per-rule watchdog timeouts and output-expansion guards. A runaway regex is safely timed out and disabled without freezing the UI or blocking other rules.
- Why
@js:script replacements remain disabled: Some legacy Reader packs contain@js:JavaScript replacement scripts. Because JavaScriptCore on iOS and macOS does not support safe synchronous interruption—and force-killing a busy JS worker introduces stability risks—Origo X keeps imported@js:rules, incompatible regexes, and targetless entries quarantined as disabled items with an explanation card. They never block valid rules in the same pack and are never inserted into body text.
For source-level compatibility and next steps, see Legado compatibility, Notes, highlights, and auto-coloring, and Troubleshooting and feedback.
このガイドに問題がありますか? 修正を提案