mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 12:37:05 +03:00
add reset settings option
This commit is contained in:
@@ -947,5 +947,14 @@
|
|||||||
},
|
},
|
||||||
"openOptionsPage": {
|
"openOptionsPage": {
|
||||||
"message": "Open options page"
|
"message": "Open options page"
|
||||||
|
},
|
||||||
|
"resetToDefault": {
|
||||||
|
"message": "Reset to default"
|
||||||
|
},
|
||||||
|
"confirmResetToDefault": {
|
||||||
|
"message": "Are you sure you want to reset all settings to their default values? This cannot be undone."
|
||||||
|
},
|
||||||
|
"whatResetToDefault": {
|
||||||
|
"message": "This resets all settings to their default values."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -368,6 +368,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div data-type="button-press" data-sync="resetToDefault" data-confirm-message="confirmResetToDefault">
|
||||||
|
<div class="option-button trigger-button">
|
||||||
|
__MSG_resetToDefault__
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="small-description">__MSG_whatResetToDefault__</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="advanced" class="option-group hidden">
|
<div id="advanced" class="option-group hidden">
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ export interface SBObject {
|
|||||||
local: SBStorage;
|
local: SBStorage;
|
||||||
forceSyncUpdate(prop: string): void;
|
forceSyncUpdate(prop: string): void;
|
||||||
forceLocalUpdate(prop: string): void;
|
forceLocalUpdate(prop: string): void;
|
||||||
|
resetToDefault(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Config: SBObject = {
|
const Config: SBObject = {
|
||||||
@@ -289,7 +290,8 @@ const Config: SBObject = {
|
|||||||
config: null,
|
config: null,
|
||||||
local: null,
|
local: null,
|
||||||
forceSyncUpdate,
|
forceSyncUpdate,
|
||||||
forceLocalUpdate
|
forceLocalUpdate,
|
||||||
|
resetToDefault
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function setup
|
// Function setup
|
||||||
@@ -522,6 +524,10 @@ function addDefaults() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetToDefault() {
|
||||||
|
chrome.storage.sync.set(Config.syncDefaults);
|
||||||
|
}
|
||||||
|
|
||||||
// Sync config
|
// Sync config
|
||||||
setupConfig();
|
setupConfig();
|
||||||
|
|
||||||
|
|||||||
@@ -232,12 +232,22 @@ async function init() {
|
|||||||
}
|
}
|
||||||
case "button-press": {
|
case "button-press": {
|
||||||
const actionButton = optionsElements[i].querySelector(".trigger-button");
|
const actionButton = optionsElements[i].querySelector(".trigger-button");
|
||||||
|
const confirmMessage = optionsElements[i].getAttribute("data-confirm-message");
|
||||||
|
|
||||||
switch(optionsElements[i].getAttribute("data-sync")) {
|
actionButton.addEventListener("click", () => {
|
||||||
|
if (confirmMessage !== null && !confirm(chrome.i18n.getMessage(confirmMessage))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (optionsElements[i].getAttribute("data-sync")) {
|
||||||
case "copyDebugInformation":
|
case "copyDebugInformation":
|
||||||
actionButton.addEventListener("click", copyDebugOutputToClipboard);
|
copyDebugOutputToClipboard();
|
||||||
|
break;
|
||||||
|
case "resetToDefault":
|
||||||
|
Config.resetToDefault();
|
||||||
|
window.location.reload();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user