Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
1. Update code to get Title image
2. Migrate from promise to async
  • Loading branch information
dteviot committed Jan 25, 2022
1 parent 77865eb commit 2c370fd
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions plugin/js/parsers/RoyalRoadParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ class RoyalRoadParser extends Parser{
super();
}

getChapterUrls(dom) {
async getChapterUrls(dom) {
// Page in browser has links reduced to "Number of links to show"
// Fetch new page to get all chapter links.
return HttpClient.wrapFetch(dom.baseURI).then(function (xhr) {
let table = xhr.responseXML.querySelector("table#chapters");
return util.hyperlinksToChapterList(table);
});
let tocHtml = (await HttpClient.wrapFetch(dom.baseURI)).responseXML;
let table = tocHtml.querySelector("table#chapters");
return util.hyperlinksToChapterList(table);
}

// find the node(s) holding the story content
Expand Down Expand Up @@ -112,8 +111,7 @@ class RoyalRoadParser extends Parser{
}

findCoverImageUrl(dom) {
let img = dom.querySelector("img.img-offset");
return (img === null) ? img : img.src;
return dom.querySelector("img.thumbnail")?.src ?? null;
}

removeUnusedElementsToReduceMemoryConsumption(webPageDom) {
Expand Down

0 comments on commit 2c370fd

Please sign in to comment.