diff options
author | 2021-11-24 13:05:44 +0100 | |
---|---|---|
committer | 2021-11-24 17:35:44 +0530 | |
commit | 02b108d4a6c684034b003b94d0979fee03f6b31a (patch) | |
tree | c16b88e18077ceb80588eb1369d672887cf82018 /recipes/circuit/webview.js | |
parent | refactor: Use 'Ferdi.safeParseInt' (diff) | |
download | ferdium-recipes-02b108d4a6c684034b003b94d0979fee03f6b31a.tar.gz ferdium-recipes-02b108d4a6c684034b003b94d0979fee03f6b31a.tar.zst ferdium-recipes-02b108d4a6c684034b003b94d0979fee03f6b31a.zip |
Added recipe for Circuit (#771)
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 | }; | ||