From 4a96a523981028e10c7bce38aef1345bbd711c1f Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sat, 8 Feb 2020 19:19:27 -0500 Subject: [PATCH] Fixed multiple sponsors being hidden. --- src/content.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/content.ts b/src/content.ts index d6521667..ab75c270 100644 --- a/src/content.ts +++ b/src/content.ts @@ -366,11 +366,20 @@ function sponsorsLookup(id: string, channelIDPromise?) { sponsorTimes = JSON.parse(xmlhttp.responseText).sponsorTimes; UUIDs = JSON.parse(xmlhttp.responseText).UUIDs; - for (let i = 0; i < sponsorTimes.length; i++) { - if (sponsorTimes[i][1] - sponsorTimes[i][0] < Config.config.minDuration) { - sponsorTimes.splice(i, 1); - UUIDs.splice(i, 1); + // Remove all submissions smaller than the minimum duration + if (Config.config.minDuration !== 0) { + let smallSponsors = []; + let smallUUIDs = []; + + for (let i = 0; i < sponsorTimes.length; i++) { + if (sponsorTimes[i][1] - sponsorTimes[i][0] >= Config.config.minDuration) { + smallSponsors.push(sponsorTimes[i]); + smallUUIDs.push(UUIDs[i]); + } } + + sponsorTimes = smallSponsors; + UUIDs = smallUUIDs; } // Reset skip save