From 972fcaa294e70129ee069ea6e95dfd53b9549c05 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Wed, 6 May 2015 01:30:55 +0200 Subject: [PATCH] Take care of another broken Next Chapter pathology --- lib/worm-scraper.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/worm-scraper.js b/lib/worm-scraper.js index ccfba17..dba01a3 100644 --- a/lib/worm-scraper.js +++ b/lib/worm-scraper.js @@ -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 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 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; } }