mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2026-01-30 06:10:55 +03:00
Merged Lartza/min-duration
This commit is contained in:
@@ -20,7 +20,8 @@ interface SBConfig {
|
||||
invidiousUpdateInfoShowCount: number,
|
||||
autoUpvote: boolean,
|
||||
supportInvidious: false,
|
||||
customServerAddress: string
|
||||
customServerAddress: string,
|
||||
minDuration: number
|
||||
}
|
||||
|
||||
interface SBObject {
|
||||
@@ -113,7 +114,8 @@ var Config: SBObject = {
|
||||
invidiousUpdateInfoShowCount: 0,
|
||||
autoUpvote: true,
|
||||
supportInvidious: false,
|
||||
customServerAddress: null
|
||||
customServerAddress: null,
|
||||
minDuration: 0
|
||||
},
|
||||
localConfig: null,
|
||||
config: null
|
||||
|
||||
@@ -366,6 +366,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 = [];
|
||||
|
||||
@@ -1006,6 +1022,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;
|
||||
|
||||
@@ -91,6 +91,24 @@ async function init() {
|
||||
break;
|
||||
case "display":
|
||||
updateDisplayElement(<HTMLElement> optionsElements[i])
|
||||
|
||||
break;
|
||||
case "number-change":
|
||||
let numberChangeOption = optionsElements[i].getAttribute("sync-option");
|
||||
let configValue = Config.config[numberChangeOption];
|
||||
let numberInput = optionsElements[i].querySelector("input");
|
||||
|
||||
if (isNaN(configValue) || configValue < 0) {
|
||||
numberInput.value = Config.defaults[numberChangeOption];
|
||||
} else {
|
||||
numberInput.value = configValue;
|
||||
}
|
||||
|
||||
numberInput.addEventListener("input", () => {
|
||||
Config.config[numberChangeOption] = numberInput.value;
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,4 +339,4 @@ function activateTextChange(element: HTMLElement) {
|
||||
});
|
||||
|
||||
element.querySelector(".option-hidden-section").classList.remove("hidden");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user