diff options
Diffstat (limited to 'recipes/circuit/webview.js')
-rw-r--r-- | recipes/circuit/webview.js | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/recipes/circuit/webview.js b/recipes/circuit/webview.js index b5e3fd5..8cd2e2f 100644 --- a/recipes/circuit/webview.js +++ b/recipes/circuit/webview.js | |||
@@ -1,23 +1,12 @@ | |||
1 | "use strict"; | ||
2 | |||
3 | module.exports = Ferdi => { | 1 | module.exports = Ferdi => { |
4 | const getMessages = function getMessages() { | 2 | const getMessages = function getMessages() { |
5 | // Initialize empty vars | ||
6 | var match = []; | ||
7 | // 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 |
8 | const titleValue = document.querySelector('title').text; | 4 | const titleValue = document.querySelector('title').text; |
9 | // Extract the number from the tag | 5 | const match = titleValue.match(/\d+/); |
10 | match = titleValue.match(/\d+/); | 6 | const unread = match != null && match.length > 0 ? match[0] : 0; |
11 | unread = match != null && match.length > 0 ? match[0] : 0; | ||
12 | // Set unread msgs badge | ||
13 | 7 | ||
14 | Ferdi.setBadge(Ferdi.safeParseInt(unread)); | 8 | Ferdi.setBadge(Ferdi.safeParseInt(unread)); |
15 | }; | 9 | }; |
16 | 10 | ||
17 | const loopFunc = () => { | 11 | Ferdi.loop(getMessages); |
18 | getMessages(); | ||
19 | }; | ||
20 | |||
21 | Ferdi.loop(loopFunc); | ||
22 | |||
23 | }; | 12 | }; |