From 171aa681af6526ea11e523d9f0e622aafbb15924 Mon Sep 17 00:00:00 2001 From: Leon Date: Sat, 6 Jul 2024 16:15:14 +0200 Subject: [PATCH] Only add the new default options to the user options if the extension version changes --- src/lib/devtool.js | 8 ++++++++ src/popup.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/devtool.js b/src/lib/devtool.js index 006d84d..8bb03f3 100644 --- a/src/lib/devtool.js +++ b/src/lib/devtool.js @@ -87,15 +87,23 @@ export default class Devtool { } addMissingDefaultOptions = (options) => { + if (options.addOptionsForVersion === this.version) return options + const defaultOptions = this.defaultOptions for (const key in defaultOptions) { if (options[key] === undefined) { options[key] = defaultOptions[key] } } + + options.addOptionsForVersion = this.version return options } + get version() { + return chrome.runtime.getManifest().version + } + get isFirefox() { return navigator.userAgent.toLowerCase().indexOf("firefox") > -1 } diff --git a/src/popup.js b/src/popup.js index 8d3af99..4fbe661 100644 --- a/src/popup.js +++ b/src/popup.js @@ -310,7 +310,7 @@ const getCurrentTabOrigin = async () => { document.querySelector(".page-specific-options-wrapper").remove() } - versionString.textContent = chrome.runtime.getManifest().version + versionString.textContent = devTool.version const options = await devTool.getOptions() initializeForm(options)