diff options
Diffstat (limited to 'recipes/circuit')
-rw-r--r-- | recipes/circuit/index.js | 1 | ||||
-rw-r--r-- | recipes/circuit/webview.js | 15 |
2 files changed, 10 insertions, 6 deletions
diff --git a/recipes/circuit/index.js b/recipes/circuit/index.js index fbbcd9a..23607bd 100644 --- a/recipes/circuit/index.js +++ b/recipes/circuit/index.js | |||
@@ -1,2 +1 @@ | |||
1 | // just pass through Ferdi | ||
2 | module.exports = Ferdi => Ferdi; | module.exports = Ferdi => Ferdi; | |
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 @@ | |||
1 | module.exports = Ferdi => { | 1 | module.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); |