Skip to content

Instantly share code, notes, and snippets.

@dotproto
Created August 14, 2025 16:44
Show Gist options
  • Select an option

  • Save dotproto/05362e0402bf02eb12e70cebd71f7018 to your computer and use it in GitHub Desktop.

Select an option

Save dotproto/05362e0402bf02eb12e70cebd71f7018 to your computer and use it in GitHub Desktop.
Clear all cookies URLs matching a regular expression in a given cookie store
(async () => {
const stores = await browser.cookies.getAllCookieStores();
const store = stores.at(1);
const exp = /(firefox|mozilla).(org|com|auth0.com)/;
const allCookies = await browser.cookies.getAll({storeId: s.id});
console.log("All cookies:", allCookies);
const filteredCookies = allCookies.filter(c => c.domain.match(exp));
const removeCookies = filteredCookies.map(cookie => {
return {
name: cookie.name,
url: `https://${cookie.domain}${cookie.path}`,
storeId: cookie.storeId
}
});
console.log("Cookies to remove:", removeCookies);
const removed = await Promise.all(removeCookies.map(cookie => browser.cookies.remove(cookie)));
console.log("Cookies removed:", removed);
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment