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, "hideDiscordLink": false,
"invidiousInstances": ["invidio.us", "invidiou.sh", "invidious.snopyta.org"], "invidiousInstances": ["invidio.us", "invidiou.sh", "invidious.snopyta.org"],
"invidiousUpdateInfoShowCount": 0, "invidiousUpdateInfoShowCount": 0,
"autoUpvote": true "autoUpvote": true,
"minDuration": 0
} }
// Reset config // Reset config

View File

@@ -386,5 +386,11 @@
}, },
"invidiousInfo2": { "invidiousInfo2": {
"message": "You MUST enable it in the options for it to work." "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; 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)) { if (checkIfTimeToSkip(v.currentTime, sponsorTimes[index][0], sponsorTimes[index][1]) && !hiddenSponsorTimes.includes(index)) {
//skip it //skip it
skipToTime(v, index, sponsorTimes, openNotice); skipToTime(v, index, sponsorTimes, openNotice);

View File

@@ -309,4 +309,13 @@ h1,h2,h3,h4,h5,h6 {
svg { svg {
text-decoration: none; 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/>
<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"> <div option-type="toggle" toggle-type="reverse" sync-option="disableAutoSkip">
<label class="switch-container" label-name="__MSG_autoSkip__"> <label class="switch-container" label-name="__MSG_autoSkip__">
<label class="switch"> <label class="switch">
@@ -94,7 +108,7 @@
<br/> <br/>
<br/> <br/>
<div option-type="keybind-change" sync-option="startSponsorKeybind"> <div option-type="keybind-change" sync-option="startSponsorKeybind">
<div class="option-button trigger-button"> <div class="option-button trigger-button">
__MSG_setStartSponsorShortcut__ __MSG_setStartSponsorShortcut__

View File

@@ -68,6 +68,20 @@ async function init() {
break; break;
case "display": case "display":
updateDisplayElement(optionsElements[i]) 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;
});
} }
} }