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/background.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'extension/background.js') diff --git a/extension/background.js b/extension/background.js index 9b7db26..eedbb73 100644 --- a/extension/background.js +++ b/extension/background.js @@ -26,14 +26,20 @@ port.onDisconnect.addListener(() => { }); browser.runtime.onMessage.addListener(({hostname}) => { - browser.storage.sync.get('siteSettings').then(({siteSettings}) => { - const mode = siteSettings[hostname]; - - if (mode) { - console.log('BGM:', mode); - port.postMessage(mode.map(track => ({track, volume: 100}))); - } else { - console.log('No BGM found for ' + hostname); - } - }); + browser.storage.sync.get(['siteSettings', 'disableEverywhere']) + .then(({siteSettings, disableEverywhere}) => { + if (disableEverywhere) { + port.postMessage([]); + return; + } + + const mode = siteSettings[hostname]; + + if (mode) { + console.log('BGM:', mode); + port.postMessage(mode.map(track => ({track, volume: 100}))); + } else { + console.log('No BGM found for ' + hostname); + } + }); }); -- cgit 1.3.0-6-gf8a5