diff options
Diffstat (limited to 'recipes/freshrss/webview.js')
-rw-r--r-- | recipes/freshrss/webview.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/recipes/freshrss/webview.js b/recipes/freshrss/webview.js new file mode 100644 index 0000000..75da933 --- /dev/null +++ b/recipes/freshrss/webview.js | |||
@@ -0,0 +1,25 @@ | |||
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 | // Define RegExp to replace occasionally   | ||
9 | var re = new RegExp(String.fromCodePoint(160), "g"); | ||
10 | // Get value of <title> tag where in case of new feed elements the number of elements appear | ||
11 | const titleValue = document.querySelector('title').text.replace(re, ""); | ||
12 | // Extract the number from the tag | ||
13 | match = titleValue.match(/[\d\s]+/); | ||
14 | // Some logic to handle the match groups | ||
15 | unread = match != null && match.length > 0 ? match[0] : 0; | ||
16 | // Set unread msgs badge | ||
17 | Ferdi.setBadge(Number.parseInt(unread, 10)); | ||
18 | }; | ||
19 | |||
20 | const loopFunc = () => { | ||
21 | getMessages(); | ||
22 | }; | ||
23 | |||
24 | Ferdi.loop(loopFunc); | ||
25 | }; | ||