From 48df1482892517302e7d36d588fafc852dad579e Mon Sep 17 00:00:00 2001 From: MillenniumEarl Date: Thu, 19 Nov 2020 20:45:05 +0100 Subject: [PATCH] Improved changelog detection --- app/scripts/constants/css-selector.js | 2 +- app/scripts/scraper.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/scripts/constants/css-selector.js b/app/scripts/constants/css-selector.js index e985b2d..172b511 100644 --- a/app/scripts/constants/css-selector.js +++ b/app/scripts/constants/css-selector.js @@ -6,7 +6,7 @@ module.exports = Object.freeze({ GT_TAGS: "a.tagItem", GT_TITLE: "h1.p-title-value", GT_TITLE_PREFIXES: "h1.p-title-value > a.labelLink > span[dir=\"auto\"]", - GT_LAST_CHANGELOG: "div.bbCodeBlock-content > div:first-of-type", + GT_LAST_CHANGELOG: "b:contains('Changelog') + br + div > div", GT_JSONLD: "script[type=\"application/ld+json\"]", WT_FILTER_POPUP_BUTTON: "a.filterBar-menuTrigger", WT_NEXT_PAGE: "a.pageNav-jump--next", diff --git a/app/scripts/scraper.js b/app/scripts/scraper.js index 76da12b..5f4925e 100644 --- a/app/scripts/scraper.js +++ b/app/scripts/scraper.js @@ -204,6 +204,11 @@ function extractChangelog(mainPost) { changelog = changelog.replace(/\n+/g, "\n"); changelog = changelog.trim(); + // Delete the version at the start of the changelog + const firstNewLine = changelog.indexOf("\n"); + const supposedVersion = changelog.substring(0, firstNewLine); + if (supposedVersion[0] === "v") changelog = changelog.substring(firstNewLine).trim(); + // Return changelog return changelog ? changelog : null; }