From 340c1de476fabb3b634e0cd85ba55c47410a3111 Mon Sep 17 00:00:00 2001 From: survfate Date: Thu, 29 Jun 2023 01:40:01 +0700 Subject: Add new badge count logic & new logo for Zalo --- recipes/zalo/darkmode.css | 0 recipes/zalo/icon.svg | 11 +++++++++- recipes/zalo/package.json | 2 +- recipes/zalo/webview.js | 56 +++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 recipes/zalo/darkmode.css (limited to 'recipes/zalo') diff --git a/recipes/zalo/darkmode.css b/recipes/zalo/darkmode.css new file mode 100644 index 0000000..e69de29 diff --git a/recipes/zalo/icon.svg b/recipes/zalo/icon.svg index aac9549..071b0cc 100644 --- a/recipes/zalo/icon.svg +++ b/recipes/zalo/icon.svg @@ -1 +1,10 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/recipes/zalo/package.json b/recipes/zalo/package.json index a8f859f..41b60cd 100644 --- a/recipes/zalo/package.json +++ b/recipes/zalo/package.json @@ -1,7 +1,7 @@ { "id": "zalo", "name": "Zalo", - "version": "1.3.0", + "version": "1.4.0", "license": "MIT", "config": { "serviceURL": "https://chat.zalo.me/", diff --git a/recipes/zalo/webview.js b/recipes/zalo/webview.js index 785cb9a..8e4c3cd 100644 --- a/recipes/zalo/webview.js +++ b/recipes/zalo/webview.js @@ -1,8 +1,56 @@ module.exports = Ferdium => { const getMessages = () => { - const notificationBadge = document.querySelectorAll('.tab-red-dot').length; - Ferdium.setBadge(notificationBadge); - }; + let count = 0; + const unreadRed = document.querySelector('.unread-red'); + if (unreadRed !== null) { + switch (unreadRed.classList[1]) { + case 'fa-num1': + count = 1; + break; + case 'fa-num2': + count = 2; + break; + case 'fa-num3': + count = 3; + break; + case 'fa-num4': + count = 4; + break; + case 'fa-num5': + count = 5; + break; + default: { + // fa-num5plus + const convUnread = document.querySelectorAll('.conv-unread:not(.func-unread__muted)'); + if (convUnread.length === 0) + count = 6; // 5+ + else + for (const convUnreadItem of convUnread) { + switch (convUnreadItem.classList[1]) { + case 'fa-1_24_Line': + count = count + 1; + break; + case 'fa-2_24_Line': + count = count + 2; + break; + case 'fa-3_24_Line': + count = count + 3; + break; + case 'fa-4_24_Line': + count = count + 4; + break; + case 'fa-5_24_Line': + count = count + 5; + break; + default: // fa-5plus_24_Line + count = count + 6; + } + } + } + } + } + Ferdium.setBadge(count); + }; Ferdium.loop(getMessages); -}; +}; \ No newline at end of file -- cgit v1.2.3-70-g09d2