« get me outta code hell

interactive-bgm - Browser extension that adds background music based on the site you're browsing
about summary refs log tree commit diff
path: root/extension/popup
diff options
context:
space:
mode:
Diffstat (limited to 'extension/popup')
-rw-r--r--extension/popup/index.html2
-rw-r--r--extension/popup/main.js26
-rw-r--r--extension/popup/style.css2
3 files changed, 23 insertions, 7 deletions
diff --git a/extension/popup/index.html b/extension/popup/index.html
index 9ddbec4..7a9e920 100644
--- a/extension/popup/index.html
+++ b/extension/popup/index.html
@@ -13,6 +13,8 @@
             <h1 id="hostname"></h1>
             <h2>Tracks</h2>
             <ul id="track-list"></ul>
+            <h1>General Settings</h1>
+            <p><label><input id="disable-everywhere" type="checkbox"> Disable everywhere for now?</label></p>
         </div>
         <div class="screen" id="invalid-host-screen">
             <p>Sorry, this page doesn't appear to have a hostname. We can't configure music here.</p>
diff --git a/extension/popup/main.js b/extension/popup/main.js
index ad1475a..6175e36 100644
--- a/extension/popup/main.js
+++ b/extension/popup/main.js
@@ -143,12 +143,26 @@ function loadTrackList(opts) {
 }
 
 Promise.all([
-    browser.tabs.query({active: true, currentWindow: true})
-        .then(([tab]) => {
-            const url = new URL(tab.url);
-            document.getElementById('hostname').appendChild(document.createTextNode(url.hostname));
-            return url.hostname;
-        }),
+    (async function() {
+        const [[tab], {disableEverywhere: disableEverywhereStatus}] = await Promise.all([
+            browser.tabs.query({active: true, currentWindow: true}),
+            browser.storage.sync.get('disableEverywhere')
+        ]);
+
+        const {hostname} = new URL(tab.url);
+        document.getElementById('hostname').appendChild(document.createTextNode(hostname));
+
+        const disableEverywhere = document.getElementById('disable-everywhere');
+
+        disableEverywhere.checked = disableEverywhereStatus;
+
+        disableEverywhere.addEventListener('click', () => {
+            browser.storage.sync.set({disableEverywhere: disableEverywhere.checked})
+                .then(() => browser.runtime.sendMessage({hostname}));
+        });
+
+        return hostname;
+    })(),
     browser.storage.sync.get('siteSettings')
         .then(({siteSettings = {}}) => siteSettings)
 ])
diff --git a/extension/popup/style.css b/extension/popup/style.css
index 147a94e..d4ac7b2 100644
--- a/extension/popup/style.css
+++ b/extension/popup/style.css
@@ -31,7 +31,7 @@ input, button {
     margin-left: 4px;
 }
 
-ul {
+ul, p {
     margin: 4px 0;
 }