diff options
author | Vijay A <vraravam@users.noreply.github.com> | 2021-12-03 04:35:58 +0530 |
---|---|---|
committer | Vijay A <vraravam@users.noreply.github.com> | 2021-12-03 04:35:58 +0530 |
commit | 10b057dd86897704c51a328239780bc5fed0f273 (patch) | |
tree | 396bdf865f48559c64be6d701dd8647c9e0430fa /recipes/circuit/webview.js | |
parent | Stop clearing storage data on unload in WhatsApp recipe (#778) (diff) | |
download | ferdium-recipes-10b057dd86897704c51a328239780bc5fed0f273.tar.gz ferdium-recipes-10b057dd86897704c51a328239780bc5fed0f273.tar.zst ferdium-recipes-10b057dd86897704c51a328239780bc5fed0f273.zip |
fix: fix javascript error in 'circuit' recipe
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 | }; |