Skip to content

Commit e37260d

Browse files
committed
Construct fanfiction chapter URLs using onchange
See: #670
1 parent da8d6aa commit e37260d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

plugin/js/parsers/FanFictionParser.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ class FanFictionParser extends Parser {
2727
}
2828

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

0 commit comments

Comments
 (0)