aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManeraKai <manerakai@protonmail.com>2024-03-11 07:51:30 +0300
committerManeraKai <manerakai@protonmail.com>2024-03-11 07:51:30 +0300
commit2a239a2fb29b3a594602cc555a4e8f1946efb542 (patch)
tree602a34d187429c295f8946b242bb9eda90bdeb6c
parentRemoved Nitter https://github.com/libredirect/browser_extension/issues/898 (diff)
downloadlibredirect-2a239a2fb29b3a594602cc555a4e8f1946efb542.zip
Fixed settings conversion on update
Diffstat (limited to '')
-rw-r--r--src/assets/javascripts/services.js37
-rw-r--r--src/pages/options/widgets/general.pug2
2 files changed, 25 insertions, 14 deletions
diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js
index 4e243bb0..1a9c3f29 100644
--- a/src/assets/javascripts/services.js
+++ b/src/assets/javascripts/services.js
@@ -642,7 +642,6 @@ async function reverse(url) {
case "imdb":
case "imgur":
case "tiktok":
- case "twitter":
case "reddit":
case "imdb":
case "snopes":
@@ -702,7 +701,6 @@ const defaultInstances = {
'4get': ['https://4get.ca'],
'rimgo': ['https://rimgo.vern.cc'],
'hyperpipe': ['https://hyperpipe.surge.sh'],
- 'facil': [' https://facilmap.org '],
'osm': ['https://www.openstreetmap.org'],
'breezeWiki': ['https://breezewiki.com'],
'neuters': ['https://neuters.de'],
@@ -749,12 +747,12 @@ function initDefaults() {
}
}
}
- options['exceptions'] = {
+ options.exceptions = {
url: [],
regex: [],
}
options.theme = "detect"
- options.popupServices = ["youtube", "twitter", "tiktok", "imgur", "reddit", "quora", "translate", "maps"]
+ options.popupServices = ["youtube", "tiktok", "imgur", "reddit", "quora", "translate", "maps"]
options.fetchInstances = 'github'
options.redirectOnlyInIncognito = false
@@ -781,28 +779,27 @@ function upgradeOptions() {
function processUpdate() {
return new Promise(async resolve => {
- let config = await utils.getConfig()
+ let frontends = []
+ const config = await utils.getConfig()
let options = await utils.getOptions()
for (const service in config.services) {
if (!options[service]) options[service] = {}
if (!(options[service].frontend in config.services[service].frontends)) {
- options[service] = config.services[service].options
- delete options[options[service].frontend]
+ options[service] = config.services[service].options // Reset settings for service
+ delete options[options[service].frontend] // Remove deprecated frontend
}
for (const defaultOption in config.services[service].options) {
- if (options[service][defaultOption] === undefined) {
+ if (!(defaultOption in options[service])) {
options[service][defaultOption] = config.services[service].options[defaultOption]
}
}
for (const frontend in config.services[service].frontends) {
- if (options[frontend] === undefined && config.services[service].frontends[frontend].instanceList) {
- options[frontend] = defaultInstances[frontend]
- }
- else if (frontend in options && !(frontend in config.services[service].frontends)) {
- delete options[frontend]
+ frontends.push(frontend)
+ if (!(frontend in options) && config.services[service].frontends[frontend].instanceList) {
+ options[frontend] = defaultInstances[frontend] || []
}
}
@@ -813,6 +810,20 @@ function processUpdate() {
}
}
}
+ const general = ['theme', 'popupServices', 'fetchInstances', 'redirectOnlyInIncognito']
+ const combined = [
+ ...Object.keys(config.services),
+ ...frontends,
+ ...general,
+ 'exceptions',
+ 'popupServices',
+ 'version',
+ ]
+ for (const key in options) {
+ if (combined.indexOf(key) < 0) {
+ delete options[key] // Remove any unknown settings in options
+ }
+ }
browser.storage.local.set({ options }, () => {
resolve()
})
diff --git a/src/pages/options/widgets/general.pug b/src/pages/options/widgets/general.pug
index 70316473..1388584a 100644
--- a/src/pages/options/widgets/general.pug
+++ b/src/pages/options/widgets/general.pug
@@ -51,7 +51,7 @@ section(class="block-option" id="general_page")
path(d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z")
|&nbsp;
x(data-localise="__MSG_importSettings__") Import Settings
- input(id="import-settings" type="file" style="display: none")
+ input(id="import-settings" type="file" accept=".json" style="display: none")
|&nbsp;&nbsp;