Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2168 Use a different l10n string for sites opened in no container #2391

Merged
merged 1 commit into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/confirm-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,21 @@ <h1 class="title-text" data-i18n-message-id="openThisSiteConfirmation"></h1>
</label>
<br />
<div class="button-container">
<button id="deny" class="button" data-message-id="openInContainer" data-message-arg="current-container-name"></button>
<button id="confirm" class="button primary" autofocus data-message-id="openInContainer" data-message-arg="container-name"></button>
<button id="deny"
class="button"
data-message-id="openInContainer"
data-message-arg="current-container-name">
</button>
<button id="deny-no-container"
class="button"
data-message-id="openInNoContainer">
groovecoder marked this conversation as resolved.
Show resolved Hide resolved
</button>
<button id="confirm"
class="button primary"
autofocus
data-message-id="openInContainer"
data-message-arg="container-name">
</button>
</div>
</form>
</main>
Expand Down
21 changes: 19 additions & 2 deletions src/js/confirm-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down