DEV Community

Midhun
Midhun

Posted on

Here's how I made a simple Chrome extension for Gmail notifications

Image description
Blue Bell Gmail™ notification tool

I was searching for a simple extension that would allow me to quickly view new e-mails received. I found some of the greatest extensions. But what impressed me the most is their ability to show my Gmail without asking for my password explicitly. Honestly, this was a real shock to me.

These extensions can display my email without even asking for my password, which made me both fearful and curious. I eventually ended up at Gmail's feed API.

Gmail Inbox Feed

The Gmail Inbox Feed will output your Inbox as an XML document. You can use an RSS aggregator to view this, or you can consume the feed with your own app.

GET https://mail.google.com/mail/feed/atom

Solution

  1. A feed atom API call returns unread emails and total unread emails in an inbox that is logged in.

  2. In order to show an unread email when it is opened, the extension will call api and display it in the proper format

  3. Unread email listeners must notify. It is necessary to have a background script when we want to run anything in the background for an extension.

  4. In that case, the feed API is read every minute if there is an unread email update extension badge with a count.

Permission Required

"content_scripts": [
{
"matches": ["*://mail.google.com/*"],
"js": ["contentScript.bundle.js"]
}
]

Demo 🚀

Feel free to contribute on GitHub

Image description

Please comment on your ideas and thoughts, Geeks

Image description

Discussion (0)