Add minimum duration option

This commit is contained in:
Lartza
2020-01-24 01:02:23 +02:00
parent 2b7f940669
commit e6ef27936e
6 changed files with 51 additions and 3 deletions

3
SB.js
View File

@@ -176,7 +176,8 @@ SB.defaults = {
"hideDiscordLink": false,
"invidiousInstances": ["invidio.us", "invidiou.sh", "invidious.snopyta.org"],
"invidiousUpdateInfoShowCount": 0,
"autoUpvote": true
"autoUpvote": true,
"minDuration": 0
}
// Reset config

View File

@@ -386,5 +386,11 @@
},
"invidiousInfo2": {
"message": "You MUST enable it in the options for it to work."
},
"minDuration": {
"message": "Minimum duration (seconds)"
},
"minDurationDescription": {
"message": "Sponsor segments shorter than the set value will be ignored."
}
}

View File

@@ -521,6 +521,10 @@ function checkSponsorTime(sponsorTimes, index, openNotice) {
lastTime = v.currentTime - 0.0001;
}
if (sponsorTimes[index][1] - sponsorTimes[index][0] < SB.config.minDuration) {
return false;
}
if (checkIfTimeToSkip(v.currentTime, sponsorTimes[index][0], sponsorTimes[index][1]) && !hiddenSponsorTimes.includes(index)) {
//skip it
skipToTime(v, index, sponsorTimes, openNotice);

View File

@@ -310,3 +310,12 @@ h1,h2,h3,h4,h5,h6 {
svg {
text-decoration: none;
}
.number-container:before {
content: attr(label-name);
padding-right: 4px;
width: max-content;
font-size: 14px;
color: white;
}

View File

@@ -78,6 +78,20 @@
<br/>
<br/>
<div option-type="number-change" sync-option="minDuration">
<label class="number-container" label-name="__MSG_minDuration__">
<input type="number" step="0.1" min="0">
</label>
<br/>
<br/>
<div class="small-description">__MSG_minDurationDescription__</div>
</div>
<br/>
<br/>
<div option-type="toggle" toggle-type="reverse" sync-option="disableAutoSkip">
<label class="switch-container" label-name="__MSG_autoSkip__">
<label class="switch">

View File

@@ -68,6 +68,20 @@ async function init() {
break;
case "display":
updateDisplayElement(optionsElements[i])
break;
case "number-change":
let numberChangeOption = optionsElements[i].getAttribute("sync-option");
let configValue = SB.config[numberChangeOption];
let numberInput = optionsElements[i].querySelector("input");
if (configValue != undefined) {
numberInput.value = configValue;
}
numberInput.addEventListener("input", () => {
SB.config[numberChangeOption] = numberInput.value;
});
}
}