Fixed redirect toggles set to false being reset
Closes https://github.com/libredirect/libredirect/issues/499
This commit is contained in:
parent
c86fe25b44
commit
51bb4e1557
|
@ -4,6 +4,7 @@
|
||||||
"useTabs": true,
|
"useTabs": true,
|
||||||
"arrowParens": "avoid",
|
"arrowParens": "avoid",
|
||||||
"printWidth": 200,
|
"printWidth": 200,
|
||||||
|
"bracketSameLine": true,
|
||||||
"overrides": [
|
"overrides": [
|
||||||
{
|
{
|
||||||
"files": ["*.js", "*.json"],
|
"files": ["*.js", "*.json"],
|
||||||
|
|
|
@ -716,7 +716,11 @@ function processUpdate() {
|
||||||
for (const service in config.services) {
|
for (const service in config.services) {
|
||||||
if (!options[service]) options[service] = {}
|
if (!options[service]) options[service] = {}
|
||||||
if (config.services[service].targets == "datajson") targets[service] = redirects[service]
|
if (config.services[service].targets == "datajson") targets[service] = redirects[service]
|
||||||
for (const defaultOption in config.services[service].options) if (!options[service][defaultOption]) options[service][defaultOption] = config.services[service].options[defaultOption]
|
for (const defaultOption in config.services[service].options) {
|
||||||
|
if (options[service][defaultOption] === undefined) {
|
||||||
|
options[service][defaultOption] = config.services[service].options[defaultOption]
|
||||||
|
}
|
||||||
|
}
|
||||||
for (const frontend in config.services[service].frontends) {
|
for (const frontend in config.services[service].frontends) {
|
||||||
if (config.services[service].frontends[frontend].instanceList) {
|
if (config.services[service].frontends[frontend].instanceList) {
|
||||||
if (!options[frontend]) options[frontend] = {}
|
if (!options[frontend]) options[frontend] = {}
|
||||||
|
@ -733,6 +737,11 @@ function processUpdate() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for (const instance of options[frontend][network].enabled) {
|
||||||
|
let i = redirects[frontend][network].indexOf(instance)
|
||||||
|
if (i < 0) options[frontend][network].enabled.splice(i, 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -784,34 +793,6 @@ function modifyContentSecurityPolicy(details) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function processEnabledInstanceList() {
|
|
||||||
return new Promise(resolve => {
|
|
||||||
fetch("/config/config.json")
|
|
||||||
.then(response => response.text())
|
|
||||||
.then(configData => {
|
|
||||||
const config = JSON.parse(configData)
|
|
||||||
browser.storage.local.get(["redirects", "options"], r => {
|
|
||||||
let options = r.options
|
|
||||||
for (const service in config.services) {
|
|
||||||
for (const frontend in config.services[service].frontends) {
|
|
||||||
if (config.services[service].frontends[frontend].instanceList) {
|
|
||||||
for (const network in config.networks) {
|
|
||||||
for (const instance of options[frontend][network].enabled) {
|
|
||||||
let i = redirects[frontend][network].indexOf(instance)
|
|
||||||
if (i < 0) options[frontend][network].enabled.splice(i, 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
browser.storage.local.set({ options }, () => {
|
|
||||||
resolve()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
redirect,
|
redirect,
|
||||||
computeService,
|
computeService,
|
||||||
|
@ -823,5 +804,4 @@ export default {
|
||||||
upgradeOptions,
|
upgradeOptions,
|
||||||
processUpdate,
|
processUpdate,
|
||||||
modifyContentSecurityPolicy,
|
modifyContentSecurityPolicy,
|
||||||
processEnabledInstanceList,
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,7 +163,12 @@
|
||||||
"instanceList": true
|
"instanceList": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"targets": ["^https?:\\/{2}(www\\.|mobile\\.|)twitter\\.com(\\/|$)", "^https?:\\/{2}(pbs\\.|video\\.|)twimg\\.com(\\/|$)", "^https?:\\/{2}platform\\.twitter\\.com/embed(\\/|$)", "^https?:\\/{2}t\\.co(\\/|$)"],
|
"targets": [
|
||||||
|
"^https?:\\/{2}(www\\.|mobile\\.|)twitter\\.com(\\/|$)",
|
||||||
|
"^https?:\\/{2}(pbs\\.|video\\.|)twimg\\.com(\\/|$)",
|
||||||
|
"^https?:\\/{2}platform\\.twitter\\.com/embed(\\/|$)",
|
||||||
|
"^https?:\\/{2}t\\.co(\\/|$)"
|
||||||
|
],
|
||||||
"name": "Twitter",
|
"name": "Twitter",
|
||||||
"options": {
|
"options": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
|
|
|
@ -37,7 +37,6 @@ browser.runtime.onInstalled.addListener(details => {
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
await servicesHelper.processUpdate()
|
await servicesHelper.processUpdate()
|
||||||
await servicesHelper.processEnabledInstanceList()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue