Skip to content

Commit df3c8aa

Browse files
committed
1 parent 997d175 commit df3c8aa

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

plugin/js/parsers/RoyalRoadParser.js

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,33 +69,21 @@ class RoyalRoadParser extends Parser{
6969
}
7070

7171
extractTitleImpl(dom) {
72-
let isTitleElement = function (element) {
73-
let tag = element.tagName.toLowerCase();
74-
let isTitle = ((tag[0] === "h") && (element.getAttribute("property") === "name"));
75-
return isTitle ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
76-
}
77-
78-
for(let e of util.iterateElements(dom.body, e => isTitleElement(e))) {
79-
return e;
80-
}
72+
return dom.querySelector("div.fic-header div.col h1");
8173
}
8274

8375
extractAuthor(dom) {
84-
let author = dom.querySelector("h4[property='author']");
85-
if (author === null) {
86-
return super.extractAuthor(dom);
87-
}
88-
author = author.innerText.trim();
89-
return author.startsWith("by ") ? author.substring(3) : author;
76+
let author = dom.querySelector("div.fic-header h4 span a");
77+
return author?.textContent?.trim() ?? super.extractAuthor(dom);
9078
}
9179

9280
extractSubject(dom) {
93-
let tags = ([...dom.querySelectorAll("[property='genre']")]);
81+
let tags = ([...dom.querySelectorAll("div.fiction-info span.tags .label")]);
9482
return tags.map(e => e.textContent.trim()).join(", ");
9583
}
9684

9785
extractDescription(dom) {
98-
return dom.querySelector("div [property='description']").textContent.trim();
86+
return dom.querySelector("div.fiction-info div.description").textContent.trim();
9987
}
10088

10189
findChapterTitle(dom) {

0 commit comments

Comments
 (0)