From 93623b8f3e25bdd8bc61ab337c26f98caf271db3 Mon Sep 17 00:00:00 2001 From: dteviot Date: Tue, 17 Oct 2023 19:59:16 +1300 Subject: [PATCH] Remove empty blocks from moonlightnovel.com See: https://github.com/dteviot/WebToEpub/issues/1095 --- plugin/js/parsers/NoblemtlParser.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugin/js/parsers/NoblemtlParser.js b/plugin/js/parsers/NoblemtlParser.js index 99e3167a..6cd7b1fb 100644 --- a/plugin/js/parsers/NoblemtlParser.js +++ b/plugin/js/parsers/NoblemtlParser.js @@ -44,11 +44,17 @@ class NoblemtlParser extends Parser{ let toRemove = [...element.querySelectorAll("p")] .filter(p => p.style.opacity === "0"); util.removeElements(toRemove); + util.removeElements(this.findEmptySpanElements(element)); util.removeChildElementsMatchingCss(element, "span.modern-footnotes-footnote__note"); util.removeChildElementsMatchingCss(element, "span.footnote_tooltip"); super.removeUnwantedElementsFromContentElement(element); } + findEmptySpanElements(element) { + return [...element.querySelectorAll("span")] + .filter(s => !s.firstChild); + } + findChapterTitle(dom) { return dom.querySelector("h1.entry-title"); }