WebToEpub icon indicating copy to clipboard operation
WebToEpub copied to clipboard

Add option to remove chapter titles (but keep numbers)

Open swanknight opened this issue 3 years ago • 7 comments

I'm not sure if this is possible or not, but I wish there's an option to remove chapter titles and only keep chapter numbers instead. The reason is more often than not, chapter titles contain blatant spoilers..

(ex: Chapter 22: The Hero Dies? ==> Chapter 22)

swanknight avatar Feb 15 '22 07:02 swanknight

@swanknight Not easy to do in the general case, as there's all sorts of chapter names. However, assuming you would be happy with just the titles on the chapters themselves, and not the Table of Contents as well, it should be possible to use EpubEditor to modify them.

  1. Go to https://drive.google.com/drive/folders/1B_X2WcsaI_eg9yA-5bHJb8VeTZGKExl8 and download EpubEditor.
  2. Unzip the file and open main.html in Chrome or Firefox.
  3. Replace the text in the box on the RIGHT with the following
let title = dom.querySelector("h1");
let changed = false
if (title != null) {
    let txt = title.textContent;
    const regexpChapter = new RegExp("Chapter\\s*[0-9]*");
    let match = txt.match(regexpChapter);
    if (match != null) {
        console.log(txt);
        console.log(match[0]);
        title.textContent = match[0];
        changed = true;
    }
}
return changed;
  1. Drop epub with scrambled text into box on LEFT.
  2. Click option "Run script above to modify Epub"
  3. Save result, when it finishes.

Tested with epub from https://www.royalroad.com/fiction/15193/ave-xia-rem-y

For my records: 50 minutes.

dteviot avatar Feb 16 '22 07:02 dteviot

@dteviot I followed the steps above but nothing happens when I press "Run script above to modify Epub". Is there supposed to be some sort of progress indicator?

swanknight avatar Feb 16 '22 07:02 swanknight

@swanknight There is no progress indicator. Generally, it only takes a few seconds and then the save should appear. I'm guessing you perhaps didn't copy the text in step 3 correctly? I suggest:

  1. Reload main.html
  2. Clear all text from the box on the right
  3. Grab the bottom right corner of the box on the right and drag to enlarge the box.
  4. Copy the text from step 3 in my previous note.
  5. Drop the epub into box on LEFT.

Screen should look like this: image

  1. Click option "Run script above to modify Epub"

If it doesn't work, open the developer tools and look on the console tab, it might show an error.

dteviot avatar Feb 16 '22 09:02 dteviot

@dteviot I did copy it and replaced the existing script. I just tried again, I left open for 10~15 mins but still nothing.

swanknight avatar Feb 16 '22 09:02 swanknight

@swanknight Did you open the developer tools and look on the console tab?

dteviot avatar Feb 16 '22 09:02 dteviot

@dteviot it seems there was an issue with the script's format. Anyway, it did work. There were some chapters that still had their titles, but there might be an issue with the epub I was working. I'll continue to test it and if an issue arises, I will let you know. Thank you, I appreciate your help.

swanknight avatar Feb 16 '22 09:02 swanknight

@swanknight

There were some chapters that still had their titles

You might need to tweak the regex to handle the title of those chapters.

dteviot avatar Feb 16 '22 10:02 dteviot