Skip to content

Commit

Permalink
Dont wipe cookies for URLs that are MAC assigned
Browse files Browse the repository at this point in the history
  • Loading branch information
stoically authored and Perflyst committed May 1, 2018
1 parent b5ed2e8 commit f150d0f
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,32 @@ async function clearGoogleCookies () {
containers.push({
cookieStoreId: "firefox-default"
});
containers.map(container => {
const storeId = container.cookieStoreId;
if (storeId === googleCookieStoreId) {
// Don't clear cookies in the Google Container

let macAssignments = [];
if (macAddonEnabled) {
const promises = GOOGLE_DOMAINS.map(async googleDomain => {
const assigned = await getMACAssignment(`https://${googleDomain}/`);
return assigned ? googleDomain : null;
});
macAssignments = await Promise.all(promises);
}

GOOGLE_DOMAINS.map(async googleDomain => {
const googleCookieUrl = `https://${googleDomain}/`;

// dont clear cookies for googleDomain if mac assigned (with or without www.)
if (macAddonEnabled &&
(macAssignments.includes(googleDomain) ||
macAssignments.includes(`www.${googleDomain}`))) {
return;
}

GOOGLE_DOMAINS.map(async googleDomain => {
const googleCookieUrl = `https://${googleDomain}/`;
containers.map(async container => {
const storeId = container.cookieStoreId;
if (storeId === googleCookieStoreId) {
// Don't clear cookies in the Google Container
return;
}

const cookies = await browser.cookies.getAll({
domain: googleDomain,
Expand Down Expand Up @@ -159,7 +176,7 @@ async function setupContainer () {
name: GOOGLE_CONTAINER_NAME,
color: GOOGLE_CONTAINER_COLOR,
icon: GOOGLE_CONTAINER_ICON
})
});
googleCookieStoreId = context.cookieStoreId;
}
}
Expand Down

0 comments on commit f150d0f

Please sign in to comment.