From 8f961451ac9c5cff65af4003ae3bca83bfe8ef36 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Fri, 2 Oct 2020 23:48:17 +0200 Subject: More careful Gmail unread count detection 10a670fe33bd7fab841ddaf4674deb11477f2267 changed the unread count detection to grab the number besides the Inbox link instead of the total number of unread messages in the traditional inbox. However, this detection may fail in there are no unread messages in the inbox and report the number of unread messages from a different category instead. This commit combines the previous and the combined approach by first finding the "Inbox" link as in the previous approach, but it extracts the number of unread messages from the number beside it (instead of the aria-label with the total number of unread messages). --- recipes/gmail/webview.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'recipes/gmail/webview.js') diff --git a/recipes/gmail/webview.js b/recipes/gmail/webview.js index bc6e4a0..a2c712e 100644 --- a/recipes/gmail/webview.js +++ b/recipes/gmail/webview.js @@ -9,9 +9,12 @@ module.exports = (Franz) => { const getMessages = function getMessages() { let count = 0; - if (document.getElementsByClassName('bsU').length > 0) { - if (document.getElementsByClassName('bsU')[0].innerHTML != null) { - count = parseInt(document.getElementsByClassName('bsU')[0].innerHTML.trim(), 10); + const inboxLinks = document.getElementsByClassName('J-Ke n0'); + if (inboxLinks.length > 0) { + const inboxLink = inboxLinks[0]; + const unreadCounts = inboxLink.parentNode.parentNode.getElementsByClassName('bsU'); + if (unreadCounts.length > 0) { + count = parseInt(unreadCounts[0].innerHTML.trim(), 10); } } -- cgit v1.2.3-70-g09d2