aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages
diff options
context:
space:
mode:
authorHygna <hygna@proton.me>2022-10-15 14:00:46 +0100
committerHygna <hygna@proton.me>2022-10-15 14:00:46 +0100
commitea4126d75e4884eb26921e0485fc4ace290779b0 (patch)
treea77e5f9397e5664504c23eadbf1e0508a478fb08 /src/pages
parentProperly redirect images in Libreddit (diff)
downloadlibredirect-ea4126d75e4884eb26921e0485fc4ace290779b0.zip
Stopped custom instances displaying the toggle instance popup
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/popup/popup.js46
1 files changed, 25 insertions, 21 deletions
diff --git a/src/pages/popup/popup.js b/src/pages/popup/popup.js
index 78e50004..88c1433b 100644
--- a/src/pages/popup/popup.js
+++ b/src/pages/popup/popup.js
@@ -87,30 +87,34 @@ browser.storage.local.get(["options", "redirects"], r => {
instance = service[2]
frontend = service[1]
service = service[0]
- divs.instance.innerHTML = instance.replace(/https?:\/{2}/, "")
- let tmp
- let instanceNetwork
- for (const network in config.networks) {
- tmp = r.redirects[frontend][network].indexOf(instance)
- if (tmp > -1) {
- const instanceDiv = document.getElementById("instance-enabled")
- tmp = r.options[frontend][network].enabled.indexOf(instance)
- if (tmp > -1) instanceDiv.checked = true
- else instanceDiv.checked = false
- instanceNetwork = network
- instanceDiv.addEventListener("change", () => {
- browser.storage.local.get("options", r => {
- // Although options would be avaliable in this context, it is fetched again to make sure it is up to date
- let options = r.options
- if (instanceDiv.checked) options[frontend][instanceNetwork].enabled.push(instance)
- else options[frontend][instanceNetwork].enabled.splice(options[frontend][instanceNetwork].enabled.indexOf(instance), 1)
- browser.storage.local.set({ options })
+ let isCustom = false
+ for (const network in config.networks) if (r.options[frontend][network].custom.indexOf(instance) > -1) isCustom = true
+ if (!isCustom) {
+ divs.instance.innerHTML = instance.replace(/https?:\/{2}/, "")
+ let tmp
+ let instanceNetwork
+ for (const network in config.networks) {
+ tmp = r.redirects[frontend][network].indexOf(instance)
+ if (tmp > -1) {
+ const instanceDiv = document.getElementById("instance-enabled")
+ tmp = r.options[frontend][network].enabled.indexOf(instance)
+ if (tmp > -1) instanceDiv.checked = true
+ else instanceDiv.checked = false
+ instanceNetwork = network
+ instanceDiv.addEventListener("change", () => {
+ browser.storage.local.get("options", r => {
+ // Although options would be available in this context, it is fetched again to make sure it is up to date
+ let options = r.options
+ if (instanceDiv.checked) options[frontend][instanceNetwork].enabled.push(instance)
+ else options[frontend][instanceNetwork].enabled.splice(options[frontend][instanceNetwork].enabled.indexOf(instance), 1)
+ browser.storage.local.set({ options })
+ })
})
- })
- break
+ break
+ }
}
+ document.getElementById("instance-div").classList.remove("hide")
}
- document.getElementById("instance-div").classList.remove("hide")
}
divs[service].current.classList.remove("hide")
divs[service].all.classList.add("hide")