Add option to disable the page action
This commit is contained in:
parent
83b2606e58
commit
4e75945198
6 changed files with 55 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"extensionDescription": {
|
||||
"message": "Multi-Account Containers helps you keep all the parts of your online life contained in different tabs. Custom labels and color-coded tabs help keep different activities — like online shopping, travel planning, or checking work email — separate.",
|
||||
"description": "Description of the extension. DO NOT TRANSLATE \"Multi-Account Containers\"."
|
||||
"message": "Multi-Account Containers helps you keep all the parts of your online life contained in different tabs. Custom labels and color-coded tabs help keep different activities — like online shopping, travel planning, or checking work email — separate.",
|
||||
"description": "Description of the extension. DO NOT TRANSLATE \"Multi-Account Containers\"."
|
||||
},
|
||||
"openInNewTabTitle": {
|
||||
"message": "Open New Tab in…",
|
||||
|
@ -27,10 +27,10 @@
|
|||
"message": "Always Open Site in Container"
|
||||
},
|
||||
"openANewTabIn": {
|
||||
"message" : "Open a New Tab in…"
|
||||
"message": "Open a New Tab in…"
|
||||
},
|
||||
"openNewTabInThisContainer": {
|
||||
"message" : "Open New Tab in this Container"
|
||||
"message": "Open New Tab in this Container"
|
||||
},
|
||||
"openTabs": {
|
||||
"message": "Open Tabs"
|
||||
|
@ -48,7 +48,7 @@
|
|||
"message": "A simple and secure way to manage your online life"
|
||||
},
|
||||
"onboarding-1-sec-description": {
|
||||
"message" : "Use containers to organize tasks, manage accounts, and store sensitive data."
|
||||
"message": "Use containers to organize tasks, manage accounts, and store sensitive data."
|
||||
},
|
||||
"onboarding-2-header": {
|
||||
"message": "Put containers to work for you."
|
||||
|
@ -203,6 +203,9 @@
|
|||
"keyboardShortCuts": {
|
||||
"message": "Keyboard Shortcuts:"
|
||||
},
|
||||
"pageActionDescription": {
|
||||
"message": "Show the \"Always open this in a container\" button in the URL bar"
|
||||
},
|
||||
"onboarding": {
|
||||
"message": "Onboarding"
|
||||
},
|
||||
|
@ -243,7 +246,7 @@
|
|||
"message": "Container to open with Keyboard Shortcut $keyId$",
|
||||
"placeholders": {
|
||||
"keyId": {
|
||||
"content": "$1"
|
||||
"content": "$1"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -51,6 +51,11 @@ window.assignManager = {
|
|||
return !!syncEnabled;
|
||||
},
|
||||
|
||||
async getPageActionEnabled() {
|
||||
const { pageActionEnabled } = await browser.storage.local.get({ pageActionEnabled: true });
|
||||
return !!pageActionEnabled;
|
||||
},
|
||||
|
||||
async getReplaceTabEnabled() {
|
||||
const { replaceTabEnabled } = await browser.storage.local.get("replaceTabEnabled");
|
||||
return !!replaceTabEnabled;
|
||||
|
@ -431,6 +436,19 @@ window.assignManager = {
|
|||
}
|
||||
},
|
||||
|
||||
async resetPageAction() {
|
||||
const pageActionEnabled = await this.storageArea.getPageActionEnabled();
|
||||
const tabs = await browser.tabs.query({});
|
||||
const res = tabs.map((tab) => {
|
||||
if (pageActionEnabled) {
|
||||
return browser.pageAction.show(tab.id);
|
||||
} else {
|
||||
return browser.pageAction.hide(tab.id);
|
||||
}
|
||||
});
|
||||
await Promise.all(res);
|
||||
},
|
||||
|
||||
contextualIdentityCreated(changeInfo) {
|
||||
browser.contextMenus.create({
|
||||
parentId: assignManager.OPEN_IN_CONTAINER,
|
||||
|
|
|
@ -23,6 +23,9 @@ const messageHandler = {
|
|||
case "resetBookmarksContext":
|
||||
response = assignManager.resetBookmarksMenuItem();
|
||||
break;
|
||||
case "resetPageAction":
|
||||
response = assignManager.resetPageAction();
|
||||
break;
|
||||
case "deleteContainer":
|
||||
response = backgroundLogic.deleteContainer(m.message.userContextId);
|
||||
break;
|
||||
|
@ -180,6 +183,17 @@ const messageHandler = {
|
|||
});
|
||||
}, {urls: ["<all_urls>"], types: ["main_frame"]});
|
||||
|
||||
browser.tabs.onUpdated.addListener((tabId) => {
|
||||
// check if the page action is enabled right away to avoid flashing
|
||||
browser.storage.local.get({ pageActionEnabled: true }).then(({ pageActionEnabled }) => {
|
||||
if (pageActionEnabled) {
|
||||
browser.pageAction.show(tabId);
|
||||
}
|
||||
}).catch(e => {
|
||||
throw e;
|
||||
});
|
||||
}, { properties: ["status"] });
|
||||
|
||||
browser.tabs.onCreated.addListener((tab) => {
|
||||
// lets remember the last tab created so we can close it if it looks like a redirect
|
||||
this.lastCreatedTab = tab;
|
||||
|
|
|
@ -25,15 +25,23 @@ async function enableDisableReplaceTab() {
|
|||
await browser.storage.local.set({replaceTabEnabled: !!checkbox.checked});
|
||||
}
|
||||
|
||||
async function enableDisablePageAction() {
|
||||
const checkbox = document.querySelector("#pageActionCheck");
|
||||
await browser.storage.local.set({pageActionEnabled: !!checkbox.checked});
|
||||
await browser.runtime.sendMessage({ method: "resetPageAction" });
|
||||
}
|
||||
|
||||
async function setupOptions() {
|
||||
const hasPermission = await browser.permissions.contains({permissions: ["bookmarks"]});
|
||||
const { syncEnabled } = await browser.storage.local.get("syncEnabled");
|
||||
const { replaceTabEnabled } = await browser.storage.local.get("replaceTabEnabled");
|
||||
const { pageActionEnabled } = await browser.storage.local.get({ pageActionEnabled: true });
|
||||
if (hasPermission) {
|
||||
document.querySelector("#bookmarksPermissions").checked = true;
|
||||
}
|
||||
document.querySelector("#syncCheck").checked = !!syncEnabled;
|
||||
document.querySelector("#replaceTabCheck").checked = !!replaceTabEnabled;
|
||||
document.querySelector("#pageActionCheck").checked = !!pageActionEnabled;
|
||||
setupContainerShortcutSelects();
|
||||
}
|
||||
|
||||
|
@ -82,6 +90,7 @@ document.addEventListener("DOMContentLoaded", setupOptions);
|
|||
document.querySelector("#bookmarksPermissions").addEventListener( "change", requestPermissions);
|
||||
document.querySelector("#syncCheck").addEventListener( "change", enableDisableSync);
|
||||
document.querySelector("#replaceTabCheck").addEventListener( "change", enableDisableReplaceTab);
|
||||
document.querySelector("#pageActionCheck").addEventListener( "change", enableDisablePageAction);
|
||||
document.querySelector("button").addEventListener("click", resetOnboarding);
|
||||
|
||||
for (let i=0; i < NUMBER_OF_KEYBOARD_SHORTCUTS; i++) {
|
||||
|
|
|
@ -121,8 +121,7 @@
|
|||
"default_icon": "img/container-openin-16.svg",
|
||||
"default_title": "Always open this in a Container",
|
||||
"default_popup": "pageActionPopup.html",
|
||||
"pinned": false,
|
||||
"show_matches": ["*://*/*"]
|
||||
"pinned": false
|
||||
},
|
||||
"background": {
|
||||
"page": "js/background/index.html"
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
<span data-i18n-message-id="replaceTab"></span>
|
||||
</label>
|
||||
<p><em data-i18n-message-id="replaceTabDescription"></em></p>
|
||||
<label>
|
||||
<input type="checkbox" id="pageActionCheck">
|
||||
<span data-i18n-message-id="pageActionDescription"></span>
|
||||
</label>
|
||||
<h3 data-i18n-message-id="keyboardShortCuts"></h3>
|
||||
<p><em data-i18n-message-id="editWhichContainer"></em></p>
|
||||
<p><label>
|
||||
|
|
Loading…
Add table
Reference in a new issue