mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-12 22:47:18 +03:00
Add minimum duration option
This commit is contained in:
3
SB.js
3
SB.js
@@ -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
|
||||
|
||||
@@ -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."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -309,4 +309,13 @@ 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;
|
||||
}
|
||||
@@ -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">
|
||||
@@ -94,7 +108,7 @@
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<div option-type="keybind-change" sync-option="startSponsorKeybind">
|
||||
<div class="option-button trigger-button">
|
||||
__MSG_setStartSponsorShortcut__
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user