aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/gmail
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2020-10-02 23:48:17 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2020-10-03 12:25:29 +0200
commit8f961451ac9c5cff65af4003ae3bca83bfe8ef36 (patch)
tree83950f95705e2c03a1006649da562c2989073869 /recipes/gmail
parentUpdate user agent for OWA and Outlook (#302) (diff)
downloadferdium-recipes-8f961451ac9c5cff65af4003ae3bca83bfe8ef36.tar.gz
ferdium-recipes-8f961451ac9c5cff65af4003ae3bca83bfe8ef36.tar.zst
ferdium-recipes-8f961451ac9c5cff65af4003ae3bca83bfe8ef36.zip
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).
Diffstat (limited to 'recipes/gmail')
-rw-r--r--recipes/gmail/package.json2
-rw-r--r--recipes/gmail/webview.js9
2 files changed, 7 insertions, 4 deletions
diff --git a/recipes/gmail/package.json b/recipes/gmail/package.json
index 02aa3ab..2fd48d9 100644
--- a/recipes/gmail/package.json
+++ b/recipes/gmail/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "gmail", 2 "id": "gmail",
3 "name": "Gmail", 3 "name": "Gmail",
4 "version": "1.3.4", 4 "version": "1.3.5",
5 "description": "Gmail", 5 "description": "Gmail",
6 "main": "index.js", 6 "main": "index.js",
7 "author": "Stefan Malzner <stefan@adlk.io>", 7 "author": "Stefan Malzner <stefan@adlk.io>",
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) => {
9 const getMessages = function getMessages() { 9 const getMessages = function getMessages() {
10 let count = 0; 10 let count = 0;
11 11
12 if (document.getElementsByClassName('bsU').length > 0) { 12 const inboxLinks = document.getElementsByClassName('J-Ke n0');
13 if (document.getElementsByClassName('bsU')[0].innerHTML != null) { 13 if (inboxLinks.length > 0) {
14 count = parseInt(document.getElementsByClassName('bsU')[0].innerHTML.trim(), 10); 14 const inboxLink = inboxLinks[0];
15 const unreadCounts = inboxLink.parentNode.parentNode.getElementsByClassName('bsU');
16 if (unreadCounts.length > 0) {
17 count = parseInt(unreadCounts[0].innerHTML.trim(), 10);
15 } 18 }
16 } 19 }
17 20