From 51e902b5ff7557387c32e13499d0e960d9d6df28 Mon Sep 17 00:00:00 2001 From: nuttylmao Date: Thu, 5 Jun 2025 06:13:46 +1000 Subject: [PATCH] Fixed 'TwitchUpcomingAd' function --- twitch-ad-countdown-timer/script.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/twitch-ad-countdown-timer/script.js b/twitch-ad-countdown-timer/script.js index 191ecf1..02b16e1 100644 --- a/twitch-ad-countdown-timer/script.js +++ b/twitch-ad-countdown-timer/script.js @@ -44,6 +44,7 @@ let singleAdLength = 30; let timerBarLocked = false; let timerLabelLocked = false; let upcomingAdWarningLocked = false; +let upcomingAdWarningStartTime; ///////////////// // PAGEE SETUP // @@ -152,12 +153,16 @@ function TwitchAdRun(data) { } function TwitchUpcomingAd(data) { - // TODO: Need to scrape UpcomingAd data to continue this + // Twitch does not give us ANY data to work with, so we will just + // assume each UpcomingAd warning is 5 minutes const warningMinute = 5; - const delayStart = warningMinute * 60 - warningSeconds; + if (!upcomingAdWarningStartTime) + upcomingAdWarningStartTime = warningMinute * 60 - warningSeconds + // Start the countdown animation setTimeout(() => { + upcomingAdWarningStartTime = null; UpcomingAdWarning(warningSeconds); }, delayStart * 1000); }