Skip to content

Fix Novel543Parser: clean up split-chapter headings, ads, and promo banners - #2942

Open
s4daharu wants to merge 1 commit into
dteviot:ExperimentalTabModefrom
s4daharu:novel543-split-chapter-cleanup
Open

Fix Novel543Parser: clean up split-chapter headings, ads, and promo banners#2942
s4daharu wants to merge 1 commit into
dteviot:ExperimentalTabModefrom
s4daharu:novel543-split-chapter-cleanup

Conversation

@s4daharu

Copy link
Copy Markdown
Contributor

Problem

novel543.com (and twbook.cc) split long chapters across multiple part pages (8096_1.html8096_1_2.html), which walkPagesOfChapter merges. This produces several content problems in the packed EPUB:

  • Every part page repeats the chapter heading with a page-part marker, so merged chapters contain e.g. <h1>第1章 xxx (1/2)</h1> followed by <h1>第1章 xxx (2/2)</h1>.
  • Ad slots (div.adBlock, div.gadBlock), red "溫馨提示" site-notice paragraphs, and the VIP membership promo banner are kept as book content.
  • The VIP promo banner image is collected by the ImageCollector and packed into the EPUB even after its element is removed from the content, leaving an unused ~12 KB image in the manifest.

Changes

  • extractTitleImpl: prefer the chapter heading, and strip the trailing (1/2) part marker from titles.
  • customRawDomToContentStep: keep only the first heading of a merged split chapter and strip the part markers from it.
  • New removeNovel543Junk(root): removes ad slots, 溫馨提示 notice paragraphs, and the VIP banner.
    • Called from preprocessRawDom on the whole fetched document before image collection, so the promo banner is no longer downloaded/packed as an orphaned image.
    • Called again from customRawDomToContentStep when packing (idempotent).

Applies to both registered sites: novel543.com, twbook.cc.

Testing

  • Added unitTest/UtestNovel543Parser.js (7 QUnit tests: heading dedupe/marker strip, title extraction incl. book pages, continuation-link detection for moreChapterTextUrl, and whole-document junk removal via preprocessRawDom) and registered it in Tests.html.
  • All tests pass; eslint --config eslint/.eslintrc.js plugin/js/parsers/Novel543Parser.js is clean.
  • Verified against live site: converting a real book now yields one clean heading per chapter, no ad/notice/banner content, and no unused VIP banner image in the EPUB.

…anners

- strip the '(1/2)' page part marker from chapter titles
- keep only the first heading when a split chapter is merged from
  multiple part pages, instead of repeating it for every part
- remove ad slots (div.adBlock / div.gadBlock), the '溫馨提示' site
  notice paragraphs, and the VIP membership promo banner

Junk removal runs in preprocessRawDom (whole document, before image
collection) so the VIP banner is not packed as an unused image, and is
repeated in customRawDomToContentStep when packing.

Covers novel543.com and twbook.cc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant