Menu

1 / 2

Building a Cookie Manager Chrome Extension: What I Learned From the MV3 Transition

DEV Community·SHOTA·6 months ago
#4ZPrv8UX
#chrome#javascript#webdev#cookies#cookie
Reading 0:00
15s threshold

Cookie management extensions are one of the oldest categories in the Chrome Web Store. EditThisCookie has been around since 2011 and still has millions of users. The category is established, the use cases are well-understood, and it's a good study in how to migrate a conceptually simple tool to Manifest V3.

I built CookieJar as an EditThisCookie alternative built natively on MV3. Here's what the development revealed.

The cookies API in MV3

The Chrome cookies API is straightforward. To get all cookies for the current tab:

async function getCookiesForTab ( tabId : number ): Promise < chrome . cookies . Cookie [] > { const [ tab ] = await chrome . tabs . query ({ active : true , currentWindow : true }); if ( ! tab ?. url ) return [];

return chrome . cookies . getAll ({ url : tab . url }); }

Enter fullscreen mode

Exit fullscreen mode

The url parameter scopes the query to cookies accessible to that origin (matching domain and secure flag).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.