diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json
index c2782048..11a3d609 100644
--- a/public/_locales/en/messages.json
+++ b/public/_locales/en/messages.json
@@ -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."
}
}
diff --git a/public/options/options.html b/public/options/options.html
index 4f2bd730..2d6885bb 100644
--- a/public/options/options.html
+++ b/public/options/options.html
@@ -368,6 +368,14 @@
+
+
+ __MSG_resetToDefault__
+
+
+
__MSG_whatResetToDefault__
+
+
diff --git a/src/config.ts b/src/config.ts
index c1c6d17e..52c9f45a 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -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();
diff --git a/src/options.ts b/src/options.ts
index b0245c6b..a1ddc234 100644
--- a/src/options.ts
+++ b/src/options.ts
@@ -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")) {
- case "copyDebugInformation":
- actionButton.addEventListener("click", copyDebugOutputToClipboard);
- break;
- }
+ actionButton.addEventListener("click", () => {
+ if (confirmMessage !== null && !confirm(chrome.i18n.getMessage(confirmMessage))) {
+ return;
+ }
+ switch (optionsElements[i].getAttribute("data-sync")) {
+ case "copyDebugInformation":
+ copyDebugOutputToClipboard();
+ break;
+ case "resetToDefault":
+ Config.resetToDefault();
+ window.location.reload();
+ break;
+ }
+ });
break;
}