feat: redirect disable globally button

This commit is contained in:
gholk 2025-04-20 21:56:45 +08:00
parent 89b96fa5ae
commit 767fad14b2
7 changed files with 51 additions and 5 deletions

@ -1 +1 @@
Subproject commit 7df9158b9dfddab256285d8fb7f342dc8a3a8c1d
Subproject commit 4c5fb04b020eb47f3238971f6f04b096c2dea2c0

View file

@ -0,0 +1,9 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg data-name="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<rect x="1" y="1" width="6" height="6" rx="1"/>
<rect x="1" y="9" width="6" height="6" rx="1"/>
<rect x="9" y="9" width="6" height="6" rx="1"/>
<path fill="context-fill" fill-opacity="context-fill-opacity" d="M14.92 1.62a1 1 0 0 0-0.54-0.54A1 1 0 0 0 14 1h-4a1 1 0 0 0 0 2h1.59l-2.3 2.29a1 1 0 0 0 0 1.42 1 1 0 0 0 1.42 0L13 4.41V6a1 1 0 0 0 2 0V2a1 1 0 0 0-0.08-0.38z"/>
</svg>

After

Width:  |  Height:  |  Size: 677 B

View file

@ -215,7 +215,14 @@ const backgroundLogic = {
}
},
async setRedirectState(cookieStoreId, enable) {
async setRedirectState(cookieStoreId, enable, global) {
if (global) {
const containers = await identityState.getCookieStoreIDuuidMap();
for (const id in containers) {
await this.setRedirectState(id, enable, false);;
}
return;
}
const containerState = await identityState.storageArea.get(cookieStoreId);
try {
containerState.redirectDisable = !enable;

View file

@ -64,7 +64,9 @@ const messageHandler = {
});
break;
case "setRedirectState":
response = backgroundLogic.setRedirectState(m.cookieStoreId, m.state);
response = backgroundLogic.setRedirectState(
m.cookieStoreId, m.state, m.global
);
break;
case "checkIncompatibleAddons":
// TODO

View file

@ -60,6 +60,7 @@ const Logic = {
_previousPanelPath: [],
_panels: {},
_onboardingVariation: null,
_initPromise: null,
async init() {
browser.runtime.sendMessage({
@ -757,6 +758,25 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
Utils.addEnterHandler(document.querySelector("#always-open-in"), () => {
Logic.showPanel(ALWAYS_OPEN_IN_PICKER);
});
const redirectEl = document.querySelector("#disable-redirect-all");
let redirectSwitchStateTo = false;
Logic.initPromise.then(() => {
const identities = Logic.identities();
redirectSwitchStateTo = identities.some(id => id.redirectDisable);
redirectEl.querySelector('.menu-text').textContent = browser.i18n.getMessage(redirectSwitchStateTo ? "enableRedirectAllContainer" : "disableRedirectAllContainer");
});
Utils.addEnterHandler(redirectEl, async () => {
try {
await browser.runtime.sendMessage({
method: "setRedirectState",
state: redirectSwitchStateTo,
global: true
});
window.close();
} catch (e) {
window.close();
}
});
Utils.addEnterHandler(document.querySelector("#sort-containers-link"), async () => {
try {
await browser.runtime.sendMessage({
@ -2423,7 +2443,7 @@ Logic.registerPanel(P_CONTAINERS_ACHIEVEMENT, {
},
});
Logic.init();
Logic.initPromise = Logic.init();
window.addEventListener("resize", function () {
//for overflow menu

View file

@ -1,6 +1,6 @@
{
"manifest_version": 2,
"name": "Firefox Multi-Account Containers",
"name": "Firefox Multi-Account Containers DEV",
"version": "8.2.0",
"incognito": "not_allowed",
"description": "__MSG_extensionDescription__",

View file

@ -149,6 +149,14 @@
</span>
</td>
</tr>
<tr class="menu-item hover-highlight keyboard-nav" id="disable-redirect-all" tabindex="0">
<td>
<img class="menu-icon" alt="" src="/img/disable-redirect.svg" />
<span class="menu-text" data-i18n-message-id="disableRedirectAllContainer"></span>
<span class="menu-arrow">
</span>
</td>
</tr>
</table>
<hr>
<div class="sub-header-wrapper flx-row flx-space-between">