| 1 | // This function is used in background.js |
| 2 | export async function getAllCookies(name: string, url: string) { |
| 3 | // @ts-expect-error: browser may not be defined in all environments |
| 4 | const browserAPI = typeof browser !== "undefined" ? browser : chrome; |
| 5 | const stores = await browserAPI.cookies.getAllCookieStores(); |
| 6 | const cookies: chrome.cookies.Cookie[] = []; |
| 7 | for (const store of stores) { |
| 8 | const cookieOfStore = await browserAPI.cookies.getAll({ name, url, storeId: store.id }); |
| 9 | cookies.push(...cookieOfStore); |
| 10 | } |
| 11 | return cookies; |
| 12 | } |
| 13 | |
| 14 | export enum Browser { |
| 15 | Chrome = "chrome", |