Skip to content

Instantly share code, notes, and snippets.

@philsnow
Last active July 21, 2025 02:15
Show Gist options
  • Save philsnow/322bea2867d401171ada1c2eb7a38c89 to your computer and use it in GitHub Desktop.
Save philsnow/322bea2867d401171ada1c2eb7a38c89 to your computer and use it in GitHub Desktop.
Another way to manually add another site to Firefox Multi-Account Containers

Another way to manually add another site to Firefox Multi-Account Containers

Multi-Account Containers and Temporary Containers are great extensions for a great browser. I get really frustrated when I can't make them work together the way I want, though.

The most common problem I have is when some site redirects through a bunch of subdomains (usually during login). Because of Temporary Containers, each redirect opens in a new tab+container which doesn't bring cookies from the other container, and the login flow breaks.

If the resulting page leaves you on the subdomain that broke the flow, you can use the menu to add another "always open in container" rule, but if it didn't (because on error the site redirects you to the first subdomain or somewhere else), you can't use that menu. Some people have found workarounds that work for them (like changing network.http.redirection-limit to 0) but I can't get that to work all the time, so I found another way to add arbitrary sites to a container's list of sites without needing to visit those sites beforehand.

Let's say you have a container for www.example.com and you want to add SOMEWHERE.example.com to its list of sites.

Open about:debugging and click "This Firefox" in the top left. Find "Multi-Account Containers" in the list of extensions and click its "Inspect" button:

image of the inspect button

Now fetch the existing record from the extension's localStorage

obj = Object(await browser.storage.local.get("siteContainerMap@@_www.example.com"))

Note that records have a userContextId (this is just the container ID) and an identityMacAddonUUID (this is a UUID that is the same for every record under the same container)

console.log(JSON.stringify(obj, null, 4))
{
    "siteContainerMap@@_www.example.com": {
        "userContextId": "1054",
        "neverAsk": true,
        "identityMacAddonUUID": "03234b3a-855f-4a88-91e2-af8d149fae19"
    }
}

Put the value under the key SOMEWHERE.example.com instead of www.example.com

obj["siteContainerMap@@_SOMEWHERE.example.com"] = obj["siteContainerMap@@_www.example.com"]
delete obj["siteContainerMap@@_www.example.com"]

And then insert the record back into the extension's localStorage

await browser.storage.local.set(obj)

And you're done. Repeat as necessary, then close out the inspector window, buy your friendly local Firefox contributor a beer, and thank them for tirelessly working on bugs like #1670 and #473.

@philsnow
Copy link
Author

philsnow commented Mar 6, 2023

golfing a bit (because I don't write javascript day to day) after needing to do this many times over a single day and:

await ( async (prev, next) => {
  const prevURL = "siteContainerMap@@_" + prev;
  const nextURL = "siteContainerMap@@_" + next;
  await browser.storage.local.set({
    [nextURL]: (await browser.storage.local.get(prevURL))[prevURL]
  });
})("www.example.com", "SOMEWHERE.example.com") 

@oMyqMQ0I70mnbnUk
Copy link

await ( async (prev, next) => {
  const prevURL = "siteContainerMap@@_" + prev;
  const nextURL = "siteContainerMap@@_" + next;
  await browser.storage.local.set({
    [nextURL]: (await browser.storage.local.get(prevURL))[prevURL]
  });
})("www.example.com", "SOMEWHERE.example.com") 

this caused the "manage site list" button to stop working in my firefox multi-account containers extension. and it did not add the address to the container list.

@srwsolutions
Copy link

srwsolutions commented Jul 20, 2025

There is another way that always works, but it's a bit tedious. You take the dns name of the site you are trying to add to a container and you put it in your "hosts" file pointing to any IP address that will bring up a web page (I use the IP address of my router). Then you enter the dns name in a new browser tab and the site you assigned in the hosts file comes up. Now you can add the the dns name to a container of your choice just like normal. When you are done, remove the entry from the hosts file and clear the dns cache (on Windows you do this from an admin command prompt with the command: ipconfig /flushdns)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment