Take care of another broken Next Chapter pathology

This commit is contained in:
Domenic Denicola 2015-05-06 01:30:55 +02:00
commit 972fcaa294

View file

@ -136,12 +136,14 @@ function cleanContentEl(el) {
}
function getNextChapterUrl(rawChapterDoc) {
// a[title="Next Chapter"] doesn't always work (e.g. https://parahumans.wordpress.com/2011/09/27/shell-4-2/)
// So instead search for the first <a> within the main content area starting with "Next".
// a[title="Next Chapter"] doesn't always work. Two different pathologies:
// - https://parahumans.wordpress.com/2011/09/27/shell-4-2/
// - https://parahumans.wordpress.com/2012/04/21/sentinel-9-6/
// So instead search for the first <a> within the main content area starting with "Next", trimmed.
const aEls = rawChapterDoc.querySelectorAll(".entry-content a");
for (let i = 0; i < aEls.length; ++i) {
if (aEls[i].textContent.startsWith("Next")) {
if (aEls[i].textContent.trim().startsWith("Next")) {
return aEls[i].href;
}
}