aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/chatwoot/webview.js
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/chatwoot/webview.js')
-rw-r--r--recipes/chatwoot/webview.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/recipes/chatwoot/webview.js b/recipes/chatwoot/webview.js
new file mode 100644
index 0000000..05e33b3
--- /dev/null
+++ b/recipes/chatwoot/webview.js
@@ -0,0 +1,14 @@
1module.exports = (Ferdi) => {
2 const getMessages = function getMessages() {
3 const unreadBadges = document.querySelectorAll("span.unread");
4 const unreadBadgesArray = [...unreadBadges];
5 const unreadMessagesCount = unreadBadgesArray.reduce(
6 (previousValue, currentBadge) =>
7 previousValue + Ferdi.safeParseInt(currentBadge.textContent),
8 0,
9 );
10 Ferdi.setBadge(unreadMessagesCount);
11 };
12
13 Ferdi.loop(getMessages);
14};