Skip to content

Instantly share code, notes, and snippets.

@flanger001
Last active August 7, 2023 16:40
Show Gist options
  • Save flanger001/8fedc4ebddb8627a6994eeca0bb39d4a to your computer and use it in GitHub Desktop.
Save flanger001/8fedc4ebddb8627a6994eeca0bb39d4a to your computer and use it in GitHub Desktop.
If you use Firefox Multi-Account Containers with Firefox sync, sometimes you will get a number of extra containers, even thousands of them. Run this in the devtools console in the Firefox containers section `about:preferences#containers`. Add your own container tags on line 48.
let removeContainers = (...containers) => {
let items, isValid, removeButtons;
items = document.querySelectorAll("#browserContainersGroupPane richlistitem");
isValid = (el) => typeof (el) != "undefined" || el != null;
removeButtons = [];
items.forEach((el, idx) =>
{
const hbox_1 = el.getElementsByTagName("hbox").item(0);
if (isValid(hbox_1))
{
const label = hbox_1.getElementsByTagName("label").item(0);
if (isValid(label))
{
if (label.textContent.slice(0, 3) === "tmp" || containers.includes(label.textContent))
{
let containersContent = "tmp";
if (containers.length > 0) {
containersContent = `${containers.join(', ')}, or tmp`
}
console.log(`Element ${idx} is ${containersContent}`);
const containerListItem = el.getElementsByClassName("container-buttons").item(0);
const buttons = containerListItem.getElementsByTagName("button")
Array.prototype.forEach.call(buttons, (button, _bidx) =>
{
if (button.getAttribute("data-l10n-id") === "containers-remove-button")
{
removeButtons.push(button.getAttribute("value"));
}
})
}
}
}
})
removeButtons.forEach((button) =>
{
let el = document.querySelector(`button[value="${button}"][data-l10n-id="containers-remove-button"]`);
el.click();
console.log(`Removed id ${button}`)
});
}
removeContainers()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment