From 1e1a9f8e90b1546dd5396e00c607adf7e08306d9 Mon Sep 17 00:00:00 2001 From: AlterTobi Date: Tue, 5 Nov 2024 00:17:19 +0100 Subject: [PATCH 1/2] remove code leftover from template file --- no_support/wfes-editChallengeCounter.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/no_support/wfes-editChallengeCounter.js b/no_support/wfes-editChallengeCounter.js index 6f42045a..6272210c 100644 --- a/no_support/wfes-editChallengeCounter.js +++ b/no_support/wfes-editChallengeCounter.js @@ -101,9 +101,6 @@ " D" + result.EDIT_DESCRIPTION + " L" + result.EDIT_LOCATION + ")"; createButton("2024 Edit Challenge", resulttext, resultSum); - - // YOUR CODE HERE - // .catch((e) => {console.warn(GM_info.script.name, ": ", e);}); } const init = () => { From 96a550782de8960be3dfe79a03e61c669995d808 Mon Sep 17 00:00:00 2001 From: AlterTobi Date: Tue, 5 Nov 2024 00:21:49 +0100 Subject: [PATCH 2/2] refactor --- no_support/wfes-editChallengeCounter.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/no_support/wfes-editChallengeCounter.js b/no_support/wfes-editChallengeCounter.js index 6272210c..891cfa9b 100644 --- a/no_support/wfes-editChallengeCounter.js +++ b/no_support/wfes-editChallengeCounter.js @@ -1,5 +1,5 @@ // @name Edit Challenge Counter -// @version 1.0.2 +// @version 1.0.3 // @description Count Edit Contributions for the 2024 Wayfarer Edit Challenge // @author AlterTobi @@ -45,11 +45,11 @@ }); // Zählprozess + const startDate = new Date(START_DATE); + const endDate = new Date(END_DATE); contributions.forEach(item => { // Vergleiche Datum und Typ des Objekts const itemDate = new Date(item.day); - const startDate = new Date(START_DATE); - const endDate = new Date(END_DATE); if (itemDate >= startDate && itemDate <= endDate && TYPES.includes(item.type)) { counts[item.type]++; @@ -96,7 +96,10 @@ const contributions = window.wfes.g.nominationsList(); const result = countContributions(contributions); - const resultSum = result.PHOTO + result.EDIT_TITLE + result.EDIT_DESCRIPTION + result.EDIT_LOCATION; + let resultSum = 0; + TYPES.forEach(type => { + resultSum += result[type]; + }); const resulttext = " (P" + result.PHOTO + " T" + result.EDIT_TITLE + " D" + result.EDIT_DESCRIPTION + " L" + result.EDIT_LOCATION + ")";