Detect "Next Chapter" links better
This commit is contained in:
parent
ae1937df41
commit
925dcc6861
1 changed files with 11 additions and 2 deletions
|
|
@ -117,6 +117,15 @@ function cleanContentEl(el) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNextChapterUrl(rawChapterDoc) {
|
function getNextChapterUrl(rawChapterDoc) {
|
||||||
const nextEl = rawChapterDoc.querySelector("a[title=\"Next Chapter\"]");
|
// a[title="Next Chapter"] doesn't always work (e.g. https://parahumans.wordpress.com/2011/09/27/shell-4-2/)
|
||||||
return nextEl && nextEl.href;
|
// So instead search for the first <a> within the main content area starting with "Next".
|
||||||
|
|
||||||
|
const aEls = rawChapterDoc.querySelectorAll(".entry-content a");
|
||||||
|
for (let i = 0; i < aEls.length; ++i) {
|
||||||
|
if (aEls[i].textContent.startsWith("Next")) {
|
||||||
|
return aEls[i].href;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue