aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/circuit/webview.js
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/circuit/webview.js')
-rw-r--r--recipes/circuit/webview.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/recipes/circuit/webview.js b/recipes/circuit/webview.js
index 8cd2e2f..c04022d 100644
--- a/recipes/circuit/webview.js
+++ b/recipes/circuit/webview.js
@@ -1,11 +1,16 @@
1module.exports = Ferdi => { 1module.exports = Ferdi => {
2 const getMessages = function getMessages() { 2 const getMessages = () => {
3 // Get value of <title> tag where in case of new messages the number of messages appear 3 // Get value of <title> tag where in case of new messages the number of messages appear
4 const titleValue = document.querySelector('title').text; 4 const title = document.querySelector('title');
5 const match = titleValue.match(/\d+/); 5 if (title) {
6 const unread = match != null && match.length > 0 ? match[0] : 0; 6 const titleValue = title.text;
7 // Extract the number from the tag
8 const match = titleValue.match(/\d+/);
9 const unread = match != null && match.length > 0 ? match[0] : 0;
7 10
8 Ferdi.setBadge(Ferdi.safeParseInt(unread)); 11 // Set unread msgs badge
12 Ferdi.setBadge(Ferdi.safeParseInt(unread));
13 }
9 }; 14 };
10 15
11 Ferdi.loop(getMessages); 16 Ferdi.loop(getMessages);