From 19c290a58c3e6973697d48b3490575cadbbf1b92 Mon Sep 17 00:00:00 2001 From: Ian Sealy Date: Tue, 10 Nov 2020 16:47:09 +0000 Subject: Habitica: Add notification count. --- recipes/habitica/webview.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'recipes/habitica') diff --git a/recipes/habitica/webview.js b/recipes/habitica/webview.js index 17daa35..66633cb 100755 --- a/recipes/habitica/webview.js +++ b/recipes/habitica/webview.js @@ -1,3 +1,17 @@ "use strict"; -module.exports = Franz => Franz; +module.exports = (Franz) => { + const getMessages = () => { + let count = 0; + let element = document.querySelector(".message-count"); + if (element) { + count = Number(element.innerText); + if (Number.isNaN(count)) { + count = 0; + } + } + Franz.setBadge(count); + }; + + Franz.loop(getMessages); +}; -- cgit v1.2.3-70-g09d2