diff --git a/src/js/background/messageHandler.js b/src/js/background/messageHandler.js index 1971953..42b6cd2 100644 --- a/src/js/background/messageHandler.js +++ b/src/js/background/messageHandler.js @@ -119,8 +119,8 @@ const messageHandler = { // increment the counter of container tabs opened this.incrementCountOfContainerTabsOpened(); } - - this.unhideContainer(tab.cookieStoreId); + // Optionally open hidden tabs. + this.optionallyUnhideContainer(tab.cookieStoreId); } setTimeout(() => { this.lastCreatedTab = null; @@ -146,6 +146,15 @@ const messageHandler = { } }, + async optionallyUnhideContainer(cookieStoreId) { + const key = "showAllTabs"; + // Use true if not set in the storage yet. Will show all hidden tabs as default. + const showAllTabs = await browser.storage.local.get({[key]: true}); + if (showAllTabs.showAllTabs) { + this.unhideContainer(cookieStoreId); + } + }, + async unhideContainer(cookieStoreId) { if (!this.unhideQueue.includes(cookieStoreId)) { this.unhideQueue.push(cookieStoreId); diff --git a/src/manifest.json b/src/manifest.json index d5350e2..d3c58e6 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -62,6 +62,10 @@ } ], + "options_ui": { + "page": "options/options.html" + }, + "web_accessible_resources": [ "/img/container-site-d-24.png" ] diff --git a/src/options/options.html b/src/options/options.html new file mode 100644 index 0000000..4d67d15 --- /dev/null +++ b/src/options/options.html @@ -0,0 +1,19 @@ + + + + + + + + + +
+ + +
+ + + + + + diff --git a/src/options/options.js b/src/options/options.js new file mode 100644 index 0000000..cea5552 --- /dev/null +++ b/src/options/options.js @@ -0,0 +1,24 @@ +function saveOptions(e) { + e.preventDefault(); + browser.storage.local.set({ + showAllTabs : document.querySelector("#showAllTabs").checked + }); +} + +function restoreOptions() { + + function setShowAllTabs(result) { + document.querySelector("#showAllTabs").checked = result.showAllTabs; + } + + function onError(error) { + console.log(`Error: ${error}`); + } + var key = "showAllTabs"; + var showAllTabs = browser.storage.local.get({[key]: true}); + showAllTabs.then(setShowAllTabs, onError); +} + +document.addEventListener("DOMContentLoaded", restoreOptions); +document.querySelector("form").addEventListener("submit", saveOptions); +