aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/freshrss/webview.js
diff options
context:
space:
mode:
authorLibravatar Simon Szustkowski <mail@simonszu.de>2022-02-16 12:43:41 +0100
committerLibravatar GitHub <noreply@github.com>2022-02-16 12:43:41 +0100
commit18d91850bff013bd60cf9d95f4b981ea0ec4da65 (patch)
tree11085595fe2dc177c33cf02813a0a93946f14a41 /recipes/freshrss/webview.js
parentAdd Zoho Projects recipe (#830) (diff)
downloadferdium-recipes-18d91850bff013bd60cf9d95f4b981ea0ec4da65.tar.gz
ferdium-recipes-18d91850bff013bd60cf9d95f4b981ea0ec4da65.tar.zst
ferdium-recipes-18d91850bff013bd60cf9d95f4b981ea0ec4da65.zip
Added recipe for FreshRSS (#825)
Diffstat (limited to 'recipes/freshrss/webview.js')
-rw-r--r--recipes/freshrss/webview.js25
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
3module.exports = Ferdi => {
4 const getMessages = function getMessages() {
5 // Initialize empty vars
6 var unread = 0;
7 var match = [];
8 // Define RegExp to replace occasionally &nbsp
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};