From 44d11975596afa72f1ffb67816c40bfd734a8262 Mon Sep 17 00:00:00 2001 From: Edgars Date: Sat, 25 Nov 2023 20:41:24 +0200 Subject: Fix Zoho Mail badge (#466) --- recipes/zoho/package.json | 2 +- recipes/zoho/webview-unsafe.js | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/recipes/zoho/package.json b/recipes/zoho/package.json index b1444d7..c393fe5 100644 --- a/recipes/zoho/package.json +++ b/recipes/zoho/package.json @@ -1,7 +1,7 @@ { "id": "zoho", "name": "Zoho Mail", - "version": "1.4.0", + "version": "1.4.1", "license": "MIT", "config": { "serviceURL": "https://www.zoho.com/mail/login.html", diff --git a/recipes/zoho/webview-unsafe.js b/recipes/zoho/webview-unsafe.js index df5237b..077e8f8 100644 --- a/recipes/zoho/webview-unsafe.js +++ b/recipes/zoho/webview-unsafe.js @@ -1,12 +1,13 @@ -// wait for Ferdium and Zoho Mail to initialize -if ( - Object.prototype.hasOwnProperty.call(window, 'ferdium') && - Object.prototype.hasOwnProperty.call(window.ferdium, 'setBadge') && - Object.prototype.hasOwnProperty.call(window, 'zmNCenter') && - Object.prototype.hasOwnProperty.call(window, 'zmfolAction') -) { - const unreadNotifications = window.zmNCenter.counter.count(); // General Notifications by Zoho (Bell Icon) - const unreadMail = window.zmfolAction.getUnreadViewCount(); // Unread messages count - - window.ferdium.setBadge(unreadMail, unreadNotifications); +// Wait for Ferdium to initialize +if (window.ferdium?.setBadge !== undefined) { + window.ferdium.setBadge( + window.ferdium.safeParseInt(window.zmfolAction?.getUnreadViewCount()) + + window.ferdium.safeParseInt( + document.querySelector('#wms_menu_unreadchats_cnt')?.textContent, + ), + window.ferdium.safeParseInt( + window.zmTopBar?.topBandElements()?.notification?.children + ?.notificationBadge?.textContent, + ), + ); } -- cgit v1.2.3-54-g00ecf