From cbe12928f46fbea07364f46d0b15497e97ff4207 Mon Sep 17 00:00:00 2001 From: Florrie Date: Fri, 22 Mar 2019 21:20:05 -0300 Subject: "Disable everywhere for now" setting --- extension/popup/index.html | 2 ++ extension/popup/main.js | 26 ++++++++++++++++++++------ extension/popup/style.css | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) (limited to 'extension/popup') 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 @@

Tracks

+

General Settings

+

Sorry, this page doesn't appear to have a hostname. We can't configure music here.

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; } -- cgit 1.3.0-6-gf8a5