Add an option to not show hidden tabs when opening a new tab in a hidden container
This commit is contained in:
parent
22ec01d565
commit
0cd51bd9dc
4 changed files with 58 additions and 2 deletions
|
@ -119,8 +119,8 @@ const messageHandler = {
|
||||||
// increment the counter of container tabs opened
|
// increment the counter of container tabs opened
|
||||||
this.incrementCountOfContainerTabsOpened();
|
this.incrementCountOfContainerTabsOpened();
|
||||||
}
|
}
|
||||||
|
// Optionally open hidden tabs.
|
||||||
this.unhideContainer(tab.cookieStoreId);
|
this.optionallyUnhideContainer(tab.cookieStoreId);
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.lastCreatedTab = null;
|
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) {
|
async unhideContainer(cookieStoreId) {
|
||||||
if (!this.unhideQueue.includes(cookieStoreId)) {
|
if (!this.unhideQueue.includes(cookieStoreId)) {
|
||||||
this.unhideQueue.push(cookieStoreId);
|
this.unhideQueue.push(cookieStoreId);
|
||||||
|
|
|
@ -62,6 +62,10 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
"options_ui": {
|
||||||
|
"page": "options/options.html"
|
||||||
|
},
|
||||||
|
|
||||||
"web_accessible_resources": [
|
"web_accessible_resources": [
|
||||||
"/img/container-site-d-24.png"
|
"/img/container-site-d-24.png"
|
||||||
]
|
]
|
||||||
|
|
19
src/options/options.html
Normal file
19
src/options/options.html
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<form>
|
||||||
|
<label>Show hidden tabs when a new tab is opened in a hidden container <input type="checkbox" id="showAllTabs" ></label>
|
||||||
|
<button type="submit">Save</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script src="options.js"></script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
24
src/options/options.js
Normal file
24
src/options/options.js
Normal file
|
@ -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);
|
||||||
|
|
Loading…
Add table
Reference in a new issue