mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 04:27:15 +03:00
add reset settings option
This commit is contained in:
@@ -947,5 +947,14 @@
|
||||
},
|
||||
"openOptionsPage": {
|
||||
"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 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 id="advanced" class="option-group hidden">
|
||||
|
||||
@@ -113,6 +113,7 @@ export interface SBObject {
|
||||
local: SBStorage;
|
||||
forceSyncUpdate(prop: string): void;
|
||||
forceLocalUpdate(prop: string): void;
|
||||
resetToDefault(): void;
|
||||
}
|
||||
|
||||
const Config: SBObject = {
|
||||
@@ -289,7 +290,8 @@ const Config: SBObject = {
|
||||
config: null,
|
||||
local: null,
|
||||
forceSyncUpdate,
|
||||
forceLocalUpdate
|
||||
forceLocalUpdate,
|
||||
resetToDefault
|
||||
};
|
||||
|
||||
// Function setup
|
||||
@@ -522,6 +524,10 @@ function addDefaults() {
|
||||
}
|
||||
}
|
||||
|
||||
function resetToDefault() {
|
||||
chrome.storage.sync.set(Config.syncDefaults);
|
||||
}
|
||||
|
||||
// Sync config
|
||||
setupConfig();
|
||||
|
||||
|
||||
@@ -232,12 +232,22 @@ async function init() {
|
||||
}
|
||||
case "button-press": {
|
||||
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":
|
||||
actionButton.addEventListener("click", copyDebugOutputToClipboard);
|
||||
copyDebugOutputToClipboard();
|
||||
break;
|
||||
case "resetToDefault":
|
||||
Config.resetToDefault();
|
||||
window.location.reload();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user