aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJoe Dowd <[email protected]>2020-02-09 01:02:40 +0000
committerJoe Dowd <[email protected]>2020-02-09 01:02:40 +0000
commit6bd22896b9ba1d4450312f259a96c6413d4e99d3 (patch)
tree9300200133984982ba33c06b72b196163f26df57
parent3455a79298623887056154cb76f79a50a84cb8e3 (diff)
parent84fbc93c8aaaa98167f587f3164d19290edad2dd (diff)
downloadSponsorBlock-6bd22896b9ba1d4450312f259a96c6413d4e99d3.tar.gz
SponsorBlock-6bd22896b9ba1d4450312f259a96c6413d4e99d3.zip
Merged Lartza/min-duration
-rw-r--r--public/_locales/en/messages.json9
-rw-r--r--public/options/options.css9
-rw-r--r--public/options/options.html16
-rw-r--r--src/config.ts6
-rw-r--r--src/content.ts27
-rw-r--r--src/options.ts20
6 files changed, 83 insertions, 4 deletions
diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json
index 712c577f..260cde5d 100644
--- a/public/_locales/en/messages.json
+++ b/public/_locales/en/messages.json
@@ -395,5 +395,14 @@
},
"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 not be skipeed or show in the player."
+ },
+ "shortCheck": {
+ "message": "The following submission is shorter than your minimum duration option. This could mean that this is already submitted, and just being ignored due to this option. Are you sure you would like to submit?"
}
}
diff --git a/public/options/options.css b/public/options/options.css
index 411dce58..0b10a3f9 100644
--- a/public/options/options.css
+++ b/public/options/options.css
@@ -314,4 +314,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;
} \ No newline at end of file
diff --git a/public/options/options.html b/public/options/options.html
index 1fc7a8a1..196dfc79 100644
--- a/public/options/options.html
+++ b/public/options/options.html
@@ -76,7 +76,7 @@
<br/>
<br/>
-
+
<div option-type="toggle" toggle-type="reverse" sync-option="disableAutoSkip">
<label class="switch-container" label-name="__MSG_autoSkip__">
<label class="switch">
@@ -151,6 +151,20 @@
</span>
</div>
</div>
+
+ <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/>
diff --git a/src/config.ts b/src/config.ts
index 486bfdb0..63c482ff 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -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
diff --git a/src/content.ts b/src/content.ts
index 31e11f3d..d88f8be4 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -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;
diff --git a/src/options.ts b/src/options.ts
index 14f5c942..8d96f4f0 100644
--- a/src/options.ts
+++ b/src/options.ts
@@ -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");
-} \ No newline at end of file
+}