diff options
author | Ajay Ramachandran <[email protected]> | 2020-02-08 19:31:18 -0500 |
---|---|---|
committer | Ajay Ramachandran <[email protected]> | 2020-02-08 19:31:18 -0500 |
commit | ea4331e4b14973527cd9c1498d3f910d0b21b789 (patch) | |
tree | eac26e5c1285df57e947afc810d374a409e881e8 /src/content.ts | |
parent | 1cd84d8a2ccc669856c01efb96e88e5248c87473 (diff) | |
parent | 84fbc93c8aaaa98167f587f3164d19290edad2dd (diff) | |
download | SponsorBlock-ea4331e4b14973527cd9c1498d3f910d0b21b789.tar.gz SponsorBlock-ea4331e4b14973527cd9c1498d3f910d0b21b789.zip |
Merge branch 'master' of https://github.com/ajayyy/SponsorBlock into typescript
# Conflicts:
# src/config.ts
Diffstat (limited to 'src/content.ts')
-rw-r--r-- | src/content.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/content.ts b/src/content.ts index 5851f89b..87fea5cd 100644 --- a/src/content.ts +++ b/src/content.ts @@ -369,6 +369,22 @@ function sponsorsLookup(id: string, channelIDPromise?) { sponsorTimes = JSON.parse(xmlhttp.responseText).sponsorTimes; UUIDs = JSON.parse(xmlhttp.responseText).UUIDs; + // 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 sponsorSkipped = []; @@ -1008,6 +1024,17 @@ function submitSponsorTimes() { //update sponsorTimesSubmitting sponsorTimesSubmitting = sponsorTimes; + // Check to see if any of the submissions are below the minimum duration set + if (Config.config.minDuration > 0) { + for (let i = 0; i < sponsorTimes.length; i++) { + if (sponsorTimes[i][1] - sponsorTimes[i][0] < Config.config.minDuration) { + let confirmShort = chrome.i18n.getMessage("shortCheck") + "\n\n" + getSponsorTimesMessage(sponsorTimes); + + if(!confirm(confirmShort)) return; + } + } + } + let confirmMessage = chrome.i18n.getMessage("submitCheck") + "\n\n" + getSponsorTimesMessage(sponsorTimes) + "\n\n" + chrome.i18n.getMessage("confirmMSG") + "\n\n" + chrome.i18n.getMessage("guildlinesSummary"); if(!confirm(confirmMessage)) return; |