Use a different l10n string for sites opened in no container

https://github.com/mozilla/multi-account-containers/pull/2391
This commit is contained in:
BPower0036 2022-08-08 07:54:20 +00:00 committed by GitHub
parent fe05b1b3d8
commit 27d7e22add
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,22 +12,39 @@ async function load() {
denySubmit(redirectUrl);
});
document.getElementById("deny-no-container").addEventListener("click", (e) => {
e.preventDefault();
denySubmit(redirectUrl);
});
const container = await browser.contextualIdentities.get(cookieStoreId);
const currentContainer = currentCookieStoreId ? await browser.contextualIdentities.get(currentCookieStoreId) : null;
const currentContainerName = currentContainer ? currentContainer.name : "";
const currentContainerName = currentContainer ? setDenyButton(currentContainer.name) : setDenyButton("");
document.querySelectorAll("[data-message-id]").forEach(el => {
const elementData = el.dataset;
const containerName = elementData.messageArg === "container-name" ? container.name : currentContainerName;
el.textContent = browser.i18n.getMessage(elementData.messageId, containerName);
});
document.getElementById("confirm").addEventListener("click", (e) => {
e.preventDefault();
confirmSubmit(redirectUrl, cookieStoreId);
});
}
function setDenyButton(currentContainerName) {
const buttonDeny = document.getElementById("deny");
const buttonDenyNoContainer = document.getElementById("deny-no-container");
if (currentContainerName) {
buttonDenyNoContainer.style.display = "none";
return currentContainerName;
}
buttonDeny.style.display = "none";
return;
}
function appendFavicon(pageUrl, redirectUrlElement) {
const origin = new URL(pageUrl).origin;
const favIconElement = Utils.createFavIconElement(`${origin}/favicon.ico`);