Skip to content

Commit

Permalink
Construct fanfiction chapter URLs using onchange
Browse files Browse the repository at this point in the history
See: #670
  • Loading branch information
dteviot committed Dec 28, 2021
1 parent da8d6aa commit e37260d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions plugin/js/parsers/FanFictionParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ class FanFictionParser extends Parser {
}

optionToChapterInfo(baseUrl, optionElement) {
// constructing the URL is a bit complicated as the value is not final part of URL.
let relativeUrl = "../" + optionElement.getAttribute("value");
let pathNodes = baseUrl.split("/");
relativeUrl = relativeUrl + "/" + pathNodes[pathNodes.length - 1];
let url = util.resolveRelativeUrl(baseUrl, relativeUrl);
// constructing the URL is a bit complicated as the value is only part of URL.
let onchange = optionElement.parentElement.getAttribute("onchange");
onchange = onchange.split("'");
let url = new URL(baseUrl);
url.pathname = onchange[1] + optionElement.getAttribute("value") + onchange[3];
return {
sourceUrl: url,
sourceUrl: url.href,
title: optionElement.innerText
};
}
Expand Down

0 comments on commit e37260d

Please sign in to comment.