The URL whose cookies should be read
A promise resolving to the matching cookies (empty on failure)
const cookies = await getCookies("https://shop.es-drei.de");
console.log(cookies.find((c) => c.name === "currency")?.value); // "2"
export async function getCookies(url: string): Promise<chrome.cookies.Cookie[]> {
if (!isCookiesApiAvailable()) {
logger.warn("chrome.cookies unavailable; cannot read cookies", { url });
return [];
}
try {
return await chrome.cookies.getAll({ url });
} catch (error: unknown) {
logger.warn("Failed to read cookies", { url, error });
return [];
}
}
Reads every cookie the jar holds for the given URL. Useful for verifying that session cookies are being stored/updated across requests. Returns an empty array when the API is unavailable or the read fails.