aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/popup
diff options
context:
space:
mode:
authorHygna <hygna@proton.me>2022-09-27 20:59:25 +0100
committerHygna <hygna@proton.me>2022-09-27 20:59:25 +0100
commit5d48d60e96179f112d40d105e76f80f9cc51175b (patch)
tree6f71fd866f3d0077b14b76a0fee2de2d9aa5e312 /src/pages/popup
parentChanges (diff)
downloadlibredirect-5d48d60e96179f112d40d105e76f80f9cc51175b.zip
Started converting storage format
Diffstat (limited to 'src/pages/popup')
-rw-r--r--src/pages/popup/popup.ejs6
-rw-r--r--src/pages/popup/popup.js33
2 files changed, 17 insertions, 22 deletions
diff --git a/src/pages/popup/popup.ejs b/src/pages/popup/popup.ejs
index 5b3bb026..e862e0cb 100644
--- a/src/pages/popup/popup.ejs
+++ b/src/pages/popup/popup.ejs
@@ -8,13 +8,13 @@
</head>
<body dir="auto">
<div class="current_site">
- <%- include('src/pages/widgets/switches', {config: {networks, services}}) -%>
+ <%- include('src/pages/widgets/switches', {services: services}) -%>
<div id="current_site_divider">
<hr>
</div>
</div>
<div class="all_sites">
- <%- include('src/pages/widgets/switches', {config: {networks, services}}) -%>
+ <%- include('src/pages/widgets/switches', {services: services}) -%>
</div>
<hr>
<div class="some-block" id="change_instance_div"><a class="title button prevent" id="change_instance">
@@ -27,7 +27,7 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path>
</svg></a></div>
- <div class="some-block" id="unify_div" title="Unify cookies across all selected instances"><a class="title button prevent" id="unify">
+ <div class="some-block" id="unify_div" title="Unify preferences across all selected instances"><a class="title button prevent" id="unify">
<h4 data-localise="__MSG_unifySettings__">Unify Settings</h4>
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor">
<path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path>
diff --git a/src/pages/popup/popup.js b/src/pages/popup/popup.js
index c28f2d94..098ae01a 100644
--- a/src/pages/popup/popup.js
+++ b/src/pages/popup/popup.js
@@ -56,27 +56,18 @@ await setDivs()
const currentSiteIsFrontend = document.getElementById("current_site_divider")
-function getEnabled() {
- return new Promise(async resolve => {
- for (const service in config.services) {
- browser.storage.local.get(`${service}Enabled`, r => {
- divs[service].toggle.all.checked = r[service + "Enabled"]
- divs[service].toggle.current.checked = r[service + "Enabled"]
- })
- }
- resolve()
- })
-}
-
-browser.storage.local.get("popupServices", r => {
+browser.storage.local.get("options", r => {
browser.tabs.query({ active: true, currentWindow: true }, async tabs => {
for (const service in config.services) {
- if (!r.popupServices.includes(service)) allSites.getElementsByClassName(service)[0].classList.add("hide")
+ if (!r.options.popupServices.includes(service)) allSites.getElementsByClassName(service)[0].classList.add("hide")
else allSites.getElementsByClassName(service)[0].classList.remove("hide")
currSite.getElementsByClassName(service)[0].classList.add("hide")
}
- await getEnabled()
+ for (const service in config.services) {
+ divs[service].toggle.all.checked = r.options[service].enabled
+ divs[service].toggle.current.checked = r.options[service].enabled
+ }
let url
try {
@@ -113,13 +104,17 @@ browser.storage.local.get("popupServices", r => {
for (const service in config.services) {
divs[service].toggle.all.addEventListener("change", () => {
- browser.storage.local.set({
- [service + "Enabled"]: divs[service].toggle.all.checked,
+ browser.storage.local.get("options", r => {
+ let options = r.options
+ options[service].enabled = divs[service].toggle.all.checked
+ browser.storage.local.set({ options })
})
})
divs[service].toggle.current.addEventListener("change", () => {
- browser.storage.local.set({
- [service + "Enabled"]: divs[service].toggle.current.checked,
+ browser.storage.local.get("options", r => {
+ let options = r.options
+ options[service].enabled = divs[service].toggle.current.checked
+ browser.storage.local.set({ options })
})
})
}