From df3c8aabc1f8135eb8ddcc3fc2110ac740e8060a Mon Sep 17 00:00:00 2001 From: dteviot Date: Sun, 26 Feb 2023 13:20:37 +1300 Subject: [PATCH] https://www.royalroad.com/ site changes See: https://github.com/dteviot/WebToEpub/issues/930 --- plugin/js/parsers/RoyalRoadParser.js | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/plugin/js/parsers/RoyalRoadParser.js b/plugin/js/parsers/RoyalRoadParser.js index f8b7d4d9..22b6e2da 100644 --- a/plugin/js/parsers/RoyalRoadParser.js +++ b/plugin/js/parsers/RoyalRoadParser.js @@ -69,33 +69,21 @@ class RoyalRoadParser extends Parser{ } extractTitleImpl(dom) { - let isTitleElement = function (element) { - let tag = element.tagName.toLowerCase(); - let isTitle = ((tag[0] === "h") && (element.getAttribute("property") === "name")); - return isTitle ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP; - } - - for(let e of util.iterateElements(dom.body, e => isTitleElement(e))) { - return e; - } + return dom.querySelector("div.fic-header div.col h1"); } extractAuthor(dom) { - let author = dom.querySelector("h4[property='author']"); - if (author === null) { - return super.extractAuthor(dom); - } - author = author.innerText.trim(); - return author.startsWith("by ") ? author.substring(3) : author; + let author = dom.querySelector("div.fic-header h4 span a"); + return author?.textContent?.trim() ?? super.extractAuthor(dom); } extractSubject(dom) { - let tags = ([...dom.querySelectorAll("[property='genre']")]); + let tags = ([...dom.querySelectorAll("div.fiction-info span.tags .label")]); return tags.map(e => e.textContent.trim()).join(", "); } extractDescription(dom) { - return dom.querySelector("div [property='description']").textContent.trim(); + return dom.querySelector("div.fiction-info div.description").textContent.trim(); } findChapterTitle(dom) {