From 89d127c5c5f58caabddbe00727f4e2d4b8ba3e15 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Thu, 22 Aug 2019 22:43:19 -0400 Subject: [PATCH] Added a check to make sure the time doesn't exceed the duration of the video. --- content.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/content.js b/content.js index e88b602b..28846568 100644 --- a/content.js +++ b/content.js @@ -953,6 +953,13 @@ function submitSponsorTimes() { let sponsorTimes = result[sponsorTimeKey]; if (sponsorTimes != undefined && sponsorTimes.length > 0) { + //check if a sponsor exceeds the duration of the video + for (let i = 0; i < sponsorTimes.length; i++) { + if (sponsorTimes[i][1] > v.duration) { + sponsorTimes[i][1] = v.duration; + } + } + let confirmMessage = chrome.i18n.getMessage("submitCheck") + "\n\n" + getSponsorTimesMessage(sponsorTimes); confirmMessage += "\n\n" + chrome.i18n.getMessage("confirmMSG"); if(!confirm(confirmMessage)) return;