aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/chatwoot/webview.js
diff options
context:
space:
mode:
authorLibravatar Maxime Marty-Dessus <maxime.martydessus@gmail.com>2021-11-04 18:05:00 +0100
committerLibravatar GitHub <noreply@github.com>2021-11-04 22:35:00 +0530
commit5598d4b3bfc2956a6ccd16ceb1fad9e67ccff10e (patch)
tree3eecb19127b9e850133116f3212ec460bd00e738 /recipes/chatwoot/webview.js
parentAdd Confluence recipe (#758) (diff)
downloadferdium-recipes-5598d4b3bfc2956a6ccd16ceb1fad9e67ccff10e.tar.gz
ferdium-recipes-5598d4b3bfc2956a6ccd16ceb1fad9e67ccff10e.tar.zst
ferdium-recipes-5598d4b3bfc2956a6ccd16ceb1fad9e67ccff10e.zip
Add recipe for Chatwoot (#760)
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};