From 647b506874e55b8ba5df43f87eca08d11f1cbb9f Mon Sep 17 00:00:00 2001 From: Andres Date: Thu, 14 Dec 2023 18:45:12 -0600 Subject: Adds Spaces and Chat badges to countImportant (#479) --- package.json | 8 ++++---- recipes/gmail/package.json | 2 +- recipes/gmail/webview.js | 12 ++++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 9b3e468..f9960d5 100644 --- a/package.json +++ b/package.json @@ -5,12 +5,12 @@ "doc": "docs" }, "engines": { - "node": "20.9.0", - "pnpm": "8.10.0" + "node": "^20.9.0", + "pnpm": "^8.10.0" }, "volta": { - "node": "20.9.0", - "pnpm": "8.10.0" + "node": "^20.9.0", + "pnpm": "^8.10.0" }, "engine-strict": true, "packageManager": "pnpm@8.10.0", diff --git a/recipes/gmail/package.json b/recipes/gmail/package.json index ffb7757..adaa88f 100644 --- a/recipes/gmail/package.json +++ b/recipes/gmail/package.json @@ -1,7 +1,7 @@ { "id": "gmail", "name": "Gmail", - "version": "1.6.0", + "version": "1.6.1", "license": "MIT", "config": { "serviceURL": "https://mail.google.com" diff --git a/recipes/gmail/webview.js b/recipes/gmail/webview.js index dead877..6db2eec 100644 --- a/recipes/gmail/webview.js +++ b/recipes/gmail/webview.js @@ -18,6 +18,8 @@ module.exports = Ferdium => { let countImportant = 0; let countNonImportant = 0; const inboxLinks = document.querySelectorAll('.J-Ke.n0'); + const spaceAndChatBadges = document.querySelectorAll('span.XU.aH6'); + if (inboxLinks.length > 0) { const { parentNode } = inboxLinks[0]; if (parentNode) { @@ -41,6 +43,16 @@ module.exports = Ferdium => { } } } + + if (spaceAndChatBadges.length > 0) { + const arr = [...spaceAndChatBadges]; + const spaceAndChatCount = arr.reduce( + (acc, e) => Ferdium.safeParseInt(e.getInnerHTML()) + acc, + 0, + ); + countImportant += spaceAndChatCount; + } + Ferdium.setBadge(countImportant, countNonImportant); }; -- cgit v1.2.3-54-g00ecf