diff options
Diffstat (limited to 'recipes/circuit/webview.js')
-rw-r--r-- | recipes/circuit/webview.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/recipes/circuit/webview.js b/recipes/circuit/webview.js new file mode 100644 index 0000000..ab1175f --- /dev/null +++ b/recipes/circuit/webview.js | |||
@@ -0,0 +1,22 @@ | |||
1 | "use strict"; | ||
2 | |||
3 | module.exports = Ferdi => { | ||
4 | const getMessages = function getMessages() { | ||
5 | // Initialize empty vars | ||
6 | var unread = 0; | ||
7 | var match = []; | ||
8 | // Get value of <title> tag where in case of new messages the number of messages appear | ||
9 | const titleValue = document.querySelector('title').text; | ||
10 | // Extract the number from the tag | ||
11 | match = titleValue.match(/\d+/); | ||
12 | // Set unread msgs badge | ||
13 | Ferdi.setBadge(Ferdi.safeParseInt(match[0])); | ||
14 | }; | ||
15 | |||
16 | const loopFunc = () => { | ||
17 | getMessages(); | ||
18 | }; | ||
19 | |||
20 | Ferdi.loop(loopFunc); | ||
21 | |||
22 | }; | ||