aberonni / gmail-app-badge-notification

Show badge notifications in the taskbar when using Gmail as an app
21 stars 11 forks source link

Use document.title instead of network polling #12

Closed developit closed 2 years ago

developit commented 2 years ago

I was noticing a decent bit of bandwidth/cpu being consumed by this extension due to the 1-second interval in use.

This PR switches to a solution that intercepts Gmail setting document.title =, then detects the presence of Inbox (123) - to determine the number of unread messages. One perk of this approach is that it is instant.

As another perk, this fixes #5.

aberonni commented 2 years ago

Hey, thanks for the contribution! I actually used to use a similar approach but I switched to using the atom feed because parsing the HTML / window wasn't as reliable ie. it often had too much lag between an email coming in and the badge actually updating.

That said, I'm sorry to hear that the extension is heavy on bandwidth / CPU. Maybe introducing an option to regulate how often the polling is done might be a good way to mitigate that. I won't be working on that anytime soon given that personally I'm not using the extension anymore but I'll happily review a PR that does that.