Add option to disable tracking downvotes and clear when disabled

This commit is contained in:
Ajay
2022-02-07 10:58:47 -05:00
parent 008079c74c
commit cbb8d48820
5 changed files with 36 additions and 4 deletions

View File

@@ -87,6 +87,7 @@ async function init() {
const reverse = optionsElements[i].getAttribute("data-toggle-type") === "reverse";
const confirmMessage = optionsElements[i].getAttribute("data-confirm-message");
const confirmOnTrue = optionsElements[i].getAttribute("data-confirm-on") !== "false";
if (optionResult != undefined)
checkbox.checked = reverse ? !optionResult : optionResult;
@@ -101,8 +102,9 @@ async function init() {
// Add click listener
checkbox.addEventListener("click", async () => {
// Confirm if required
if (checkbox.checked && confirmMessage && !confirm(chrome.i18n.getMessage(confirmMessage))){
checkbox.checked = false;
if (confirmMessage && ((confirmOnTrue && checkbox.checked) || (!confirmOnTrue && !checkbox.checked))
&& !confirm(chrome.i18n.getMessage(confirmMessage))){
checkbox.checked = !checkbox.checked;
return;
}
@@ -135,6 +137,11 @@ async function init() {
document.documentElement.setAttribute("data-theme", "light");
}
break;
case "trackDownvotes":
if (!checkbox.checked) {
Config.local.downvotedSegments = {};
}
break;
}
// If other options depend on this, hide/show them