From 369364f5742232a6b515c1b7290c259e152a57f3 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Fri, 13 Dec 2019 22:38:00 -0500 Subject: [PATCH] Fixed downvoted sponsors reappearing. --- content.js | 7 ++++++- utils/previewBar.js | 2 ++ utils/skipNotice.js | 10 +--------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/content.js b/content.js index 8547342f..8a22c0a9 100644 --- a/content.js +++ b/content.js @@ -479,7 +479,12 @@ function updatePreviewBar() { //create an array of the sponsor types let types = []; for (let i = 0; i < localSponsorTimes.length; i++) { - types.push("sponsor"); + if (!hiddenSponsorTimes.includes(i)) { + types.push("sponsor"); + } else { + // Don't show this sponsor + types.push(null); + } } for (let i = 0; i < sponsorTimesSubmitting.length; i++) { types.push("previewSponsor"); diff --git a/utils/previewBar.js b/utils/previewBar.js index c746c5d4..e5a74b62 100644 --- a/utils/previewBar.js +++ b/utils/previewBar.js @@ -59,6 +59,8 @@ class PreviewBar { duration = Math.floor(duration * 100) / 100; let width; for (let i = 0; i < timestamps.length; i++) { + if (types[i] == null) continue; + width = (timestamps[i][1] - timestamps[i][0]) / duration * 100; width = Math.floor(width * 100) / 100; diff --git a/utils/skipNotice.js b/utils/skipNotice.js index c69e62d2..a9e537b3 100644 --- a/utils/skipNotice.js +++ b/utils/skipNotice.js @@ -324,15 +324,7 @@ class SkipNotice { //add this as a hidden sponsorTime hiddenSponsorTimes.push(i); - let sponsorTimesLeft = sponsorTimes.slice(); - for (let j = 0; j < hiddenSponsorTimes.length; j++) { - //remove this sponsor time - sponsorTimesLeft.splice(hiddenSponsorTimes[j], 1); - } - - //update the preview - previewBar.set(sponsorTimesLeft, [], v.duration); - + updatePreviewBar(); break; } }