mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 12:37:05 +03:00
missing labels, hide options when sth they depend on gets turned off
This commit is contained in:
@@ -873,5 +873,9 @@
|
|||||||
"optionsTabAdvanced" : {
|
"optionsTabAdvanced" : {
|
||||||
"message": "Advanced",
|
"message": "Advanced",
|
||||||
"description": "Appears in Options as a tab header for advanced/niche options"
|
"description": "Appears in Options as a tab header for advanced/niche options"
|
||||||
|
},
|
||||||
|
"noticeVisibilityLabel" : {
|
||||||
|
"message": "Notice appearance:",
|
||||||
|
"description": "Option label"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,6 +135,20 @@ html, body {
|
|||||||
border-bottom: inherit;
|
border-bottom: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.optionLabel {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type='number'] {
|
||||||
|
width: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.low-profile {
|
||||||
|
height: 23px;
|
||||||
|
line-height: 5px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
.center {
|
.center {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
@@ -155,7 +169,7 @@ html, body {
|
|||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.small-description{
|
.small-description {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
padding: 15px 0 0 20px;
|
padding: 15px 0 0 20px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div data-type="number-change" data-sync="minDuration">
|
<div data-type="number-change" data-sync="minDuration">
|
||||||
|
<span class="optionLabel">__MSG_minDuration__</span>
|
||||||
|
|
||||||
<label class="number-container">
|
<label class="number-container">
|
||||||
<input type="number" step="0.1" min="0">
|
<input type="number" step="0.1" min="0">
|
||||||
</label>
|
</label>
|
||||||
@@ -136,6 +138,8 @@
|
|||||||
<div id="interface-options" class="option-group hidden">
|
<div id="interface-options" class="option-group hidden">
|
||||||
|
|
||||||
<div data-type="number-change" data-sync="skipNoticeDuration">
|
<div data-type="number-change" data-sync="skipNoticeDuration">
|
||||||
|
<span class="optionLabel">__MSG_skipNoticeDuration__</span>
|
||||||
|
|
||||||
<label class="number-container">
|
<label class="number-container">
|
||||||
<input type="number" step="1" min="1">
|
<input type="number" step="1" min="1">
|
||||||
</label>
|
</label>
|
||||||
@@ -156,6 +160,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div data-type="selector" data-sync="noticeVisibilityMode">
|
<div data-type="selector" data-sync="noticeVisibilityMode">
|
||||||
|
<span class="optionLabel">__MSG_noticeVisibilityLabel__</span>
|
||||||
|
|
||||||
<select class="selector-element optionsSelector" >
|
<select class="selector-element optionsSelector" >
|
||||||
<option value="0">__MSG_noticeVisibilityMode0__</option>
|
<option value="0">__MSG_noticeVisibilityMode0__</option>
|
||||||
<option value="1">__MSG_noticeVisibilityMode1__</option>
|
<option value="1">__MSG_noticeVisibilityMode1__</option>
|
||||||
@@ -179,6 +185,30 @@
|
|||||||
<div class="small-description">__MSG_hideButtonsDescription__</div>
|
<div class="small-description">__MSG_hideButtonsDescription__</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div data-type="toggle" data-toggle-type="reverse" data-sync="hideDeleteButtonPlayerControls" data-dependent-on="hideVideoPlayerControls">
|
||||||
|
<div class="switch-container">
|
||||||
|
<label class="switch">
|
||||||
|
<input type="checkbox" checked>
|
||||||
|
<span class="slider round"></span>
|
||||||
|
</label>
|
||||||
|
<div class="switch-label">
|
||||||
|
__MSG_showDeleteButton__
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-type="toggle" data-toggle-type="reverse" data-sync="hideUploadButtonPlayerControls" data-dependent-on="hideVideoPlayerControls">
|
||||||
|
<div class="switch-container">
|
||||||
|
<label class="switch">
|
||||||
|
<input type="checkbox" checked>
|
||||||
|
<span class="slider round"></span>
|
||||||
|
</label>
|
||||||
|
<div class="switch-label">
|
||||||
|
__MSG_showUploadButton__
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div data-type="toggle" data-toggle-type="reverse" data-sync="hideSkipButtonPlayerControls">
|
<div data-type="toggle" data-toggle-type="reverse" data-sync="hideSkipButtonPlayerControls">
|
||||||
<div class="switch-container">
|
<div class="switch-container">
|
||||||
<label class="switch">
|
<label class="switch">
|
||||||
@@ -215,30 +245,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div data-type="toggle" data-toggle-type="reverse" data-sync="hideDeleteButtonPlayerControls">
|
|
||||||
<div class="switch-container">
|
|
||||||
<label class="switch">
|
|
||||||
<input type="checkbox" checked>
|
|
||||||
<span class="slider round"></span>
|
|
||||||
</label>
|
|
||||||
<div class="switch-label">
|
|
||||||
__MSG_showDeleteButton__
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div data-type="toggle" data-toggle-type="reverse" data-sync="hideUploadButtonPlayerControls">
|
|
||||||
<div class="switch-container">
|
|
||||||
<label class="switch">
|
|
||||||
<input type="checkbox" checked>
|
|
||||||
<span class="slider round"></span>
|
|
||||||
</label>
|
|
||||||
<div class="switch-label">
|
|
||||||
__MSG_showUploadButton__
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div data-type="toggle" data-sync="audioNotificationOnSkip">
|
<div data-type="toggle" data-sync="audioNotificationOnSkip">
|
||||||
<div class="switch-container">
|
<div class="switch-container">
|
||||||
<label class="switch">
|
<label class="switch">
|
||||||
@@ -351,7 +357,7 @@
|
|||||||
<div class="small-description">__MSG_whatViewTracking__</div>
|
<div class="small-description">__MSG_whatViewTracking__</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div data-type="toggle" data-sync="trackViewCountInPrivate" data-private-only="true">
|
<div data-type="toggle" data-sync="trackViewCountInPrivate" data-dependent-on="trackViewCount" data-private-only="true">
|
||||||
<div class="switch-container">
|
<div class="switch-container">
|
||||||
<label class="switch">
|
<label class="switch">
|
||||||
<input type="checkbox" checked>
|
<input type="checkbox" checked>
|
||||||
@@ -468,18 +474,18 @@
|
|||||||
<div class="small-description">__MSG_whatEnableTestingServer__</div>
|
<div class="small-description">__MSG_whatEnableTestingServer__</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div data-type="text-change" data-sync="serverAddress">
|
<div data-type="text-change" data-sync="serverAddress" data-dependent-on="testingServer" data-dependent-on-inverted="true">
|
||||||
<div class="text-label-container inline">
|
<div class="text-label-container inline">
|
||||||
<div>__MSG_customServerAddress__</div>
|
<span class="optionLabel">__MSG_customServerAddress__:</span>
|
||||||
|
|
||||||
<input class="option-text-box" type="text">
|
<input class="option-text-box" type="text" style="margin-right:10px">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="option-button text-change-set inline">
|
<div class="option-button text-change-set inline low-profile">
|
||||||
__MSG_save__
|
__MSG_save__
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="option-button text-change-reset inline">
|
<div class="option-button text-change-reset inline low-profile">
|
||||||
__MSG_reset__
|
__MSG_reset__
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ async function init() {
|
|||||||
await utils.wait(() => Config.config !== null);
|
await utils.wait(() => Config.config !== null);
|
||||||
|
|
||||||
if (!showDonationLink()) {
|
if (!showDonationLink()) {
|
||||||
document.getElementById("sbDonate").style.visibility = "hidden";
|
document.getElementById("sbDonate").style.display = "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set all of the toggle options to the correct option
|
// Set all of the toggle options to the correct option
|
||||||
@@ -38,11 +38,18 @@ async function init() {
|
|||||||
const optionsElements = optionsContainer.querySelectorAll("*");
|
const optionsElements = optionsContainer.querySelectorAll("*");
|
||||||
|
|
||||||
for (let i = 0; i < optionsElements.length; i++) {
|
for (let i = 0; i < optionsElements.length; i++) {
|
||||||
|
const dependentOnName = optionsElements[i].getAttribute("data-dependent-on");
|
||||||
|
const dependentOn = optionsContainer.querySelector(`[data-sync='${dependentOnName}']`);
|
||||||
|
let isDependentOnReversed = false;
|
||||||
|
if (dependentOn)
|
||||||
|
isDependentOnReversed = dependentOn.getAttribute("data-toggle-type") === "reverse" || optionsElements[i].getAttribute("data-dependent-on-inverted") === "true";
|
||||||
|
|
||||||
if ((optionsElements[i].getAttribute("data-private-only") === "true" && !(await isIncognitoAllowed()))
|
if ((optionsElements[i].getAttribute("data-private-only") === "true" && !(await isIncognitoAllowed()))
|
||||||
|| (optionsElements[i].getAttribute("data-no-safari") === "true" && navigator.vendor === "Apple Computer, Inc.")
|
|| (optionsElements[i].getAttribute("data-no-safari") === "true" && navigator.vendor === "Apple Computer, Inc.")
|
||||||
|| (optionsElements[i].getAttribute("data-dependent-on") && Config.config[optionsElements[i].getAttribute("data-dependent-on")])) {
|
|| (dependentOn && (isDependentOnReversed ? Config.config[dependentOnName] : !Config.config[dependentOnName]))) {
|
||||||
optionsElements[i].classList.add("hidden");
|
optionsElements[i].classList.add("hidden");
|
||||||
continue;
|
if (!dependentOn)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const option = optionsElements[i].getAttribute("data-sync");
|
const option = optionsElements[i].getAttribute("data-sync");
|
||||||
@@ -56,13 +63,8 @@ async function init() {
|
|||||||
|
|
||||||
const confirmMessage = optionsElements[i].getAttribute("data-confirm-message");
|
const confirmMessage = optionsElements[i].getAttribute("data-confirm-message");
|
||||||
|
|
||||||
if (optionResult != undefined) {
|
if (optionResult != undefined)
|
||||||
checkbox.checked = optionResult;
|
checkbox.checked = reverse ? !optionResult : optionResult;
|
||||||
|
|
||||||
if (reverse) {
|
|
||||||
optionsElements[i].querySelector("input").checked = !optionResult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// See if anything extra should be run first time
|
// See if anything extra should be run first time
|
||||||
switch (option) {
|
switch (option) {
|
||||||
@@ -94,8 +96,29 @@ async function init() {
|
|||||||
const showNoticeSwitch = <HTMLInputElement> document.querySelector("[data-sync='dontShowNotice'] > div > label > input");
|
const showNoticeSwitch = <HTMLInputElement> document.querySelector("[data-sync='dontShowNotice'] > div > label > input");
|
||||||
showNoticeSwitch.checked = true;
|
showNoticeSwitch.checked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
case "showDonationLink":
|
||||||
|
if (checkbox.checked)
|
||||||
|
document.getElementById("sbDonate").style.display = "none";
|
||||||
|
else
|
||||||
|
document.getElementById("sbDonate").style.display = "unset";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If other options depend on this, hide and disable them
|
||||||
|
const dependents = optionsContainer.querySelectorAll(`[data-dependent-on='${option}']`);
|
||||||
|
for (let j = 0; j < dependents.length; j++) {
|
||||||
|
const isDependentReversed = dependents[j].getAttribute("data-toggle-type") === "reverse";
|
||||||
|
const disableWhenChecked = dependents[j].getAttribute("data-dependent-on-inverted") === "true";
|
||||||
|
if (!disableWhenChecked && checkbox.checked || disableWhenChecked && !checkbox.checked) {
|
||||||
|
dependents[j].classList.remove("hidden");
|
||||||
|
} else {
|
||||||
|
if (dependents[j].getAttribute("data-type") === "toggle") {
|
||||||
|
(dependents[j].querySelector("div > label > input") as HTMLInputElement).checked = false;
|
||||||
|
Config.config[dependents[j].getAttribute("data-sync")] = isDependentReversed;
|
||||||
|
}
|
||||||
|
dependents[j].classList.add("hidden");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user