diff options
author | 2021-11-04 18:05:00 +0100 | |
---|---|---|
committer | 2021-11-04 22:35:00 +0530 | |
commit | 5598d4b3bfc2956a6ccd16ceb1fad9e67ccff10e (patch) | |
tree | 3eecb19127b9e850133116f3212ec460bd00e738 /recipes/chatwoot/webview.js | |
parent | Add Confluence recipe (#758) (diff) | |
download | ferdium-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.js | 14 |
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 @@ | |||
1 | module.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 | }; | ||