Skip to content

How EpubEditor works.

dteviot edited this page Aug 16, 2026 · 1 revision

An epub is a zip file, containing a bunch of HTML files.

What EpubEditor does is,

  1. Open the epub,
  2. Take each HTML file, and pass it to the EpubEditor Script. (the HTML is passed as DOM, called "dom") to the script
  3. Script can modify the DOM and return true, if the HTML is changed. Or false if not changed.
  4. If DOM is changed, EpubEditor replaces the HTML file in the zip (epub) with the changed file.

A simple EpubEditor script (that removes all <button> elements from a page)

let changed = false;
for(let p of [...dom.querySelectorAll("button")]) {
    p.remove();
    changed = true;
}
return changed;

Clone this wiki locally