async function setupContainer()

in src/background.js [273:304]


async function setupContainer () {
  // Use existing Facebook container, or create one

  const info = await browser.runtime.getBrowserInfo();
  if (parseInt(info.version) < 67) {
    FACEBOOK_CONTAINER_DETAILS.color = "blue";
    FACEBOOK_CONTAINER_DETAILS.icon = "briefcase";
  }

  const contexts = await browser.contextualIdentities.query({name: FACEBOOK_CONTAINER_DETAILS.name});
  if (contexts.length > 0) {
    const facebookContext = contexts[0];
    facebookCookieStoreId = facebookContext.cookieStoreId;
    // Make existing Facebook container the "fence" icon if needed
    if (facebookContext.color !== FACEBOOK_CONTAINER_DETAILS.color ||
        facebookContext.icon !== FACEBOOK_CONTAINER_DETAILS.icon
    ) {
      await browser.contextualIdentities.update(
        facebookCookieStoreId,
        { color: FACEBOOK_CONTAINER_DETAILS.color, icon: FACEBOOK_CONTAINER_DETAILS.icon }
      );
    }
  } else {
    const context = await browser.contextualIdentities.create(FACEBOOK_CONTAINER_DETAILS);
    facebookCookieStoreId = context.cookieStoreId;
  }
  // Initialize domainsAddedToFacebookContainer if needed
  const fbcStorage = await browser.storage.local.get();
  if (!fbcStorage.domainsAddedToFacebookContainer) {
    await browser.storage.local.set({"domainsAddedToFacebookContainer": []});
  }
}