diff --git a/plugin/js/parsers/FanFictionParser.js b/plugin/js/parsers/FanFictionParser.js index 309a8fee..235e0bd1 100644 --- a/plugin/js/parsers/FanFictionParser.js +++ b/plugin/js/parsers/FanFictionParser.js @@ -21,7 +21,19 @@ class FanFictionParser extends Parser { // no list of chapters found, assume it's a single chapter story return Promise.resolve(that.singleChapterStory(baseUrl, dom)); } else { - return Promise.resolve(options.map(option => that.optionToChapterInfo(baseUrl, option))); + let foundUrls = new Set(); + let isUnique = function(chapterInfo) { + let unique = !foundUrls.has(chapterInfo.sourceUrl); + if (unique) { + foundUrls.add(chapterInfo.sourceUrl); + } + return unique; + } + + return Promise.resolve( + options.map(option => that.optionToChapterInfo(baseUrl, option)) + .filter(isUnique) + ); } } diff --git a/testdata/FanFiction.html b/testdata/FanFiction.html index 7f758e9e..bfe6658d 100644 --- a/testdata/FanFiction.html +++ b/testdata/FanFiction.html @@ -25,6 +25,13 @@

If you're like me, you will have...

+