From 18d91850bff013bd60cf9d95f4b981ea0ec4da65 Mon Sep 17 00:00:00 2001 From: Simon Szustkowski Date: Wed, 16 Feb 2022 12:43:41 +0100 Subject: Added recipe for FreshRSS (#825) --- recipes/freshrss/README.md | 3 +++ recipes/freshrss/icon.svg | 13 +++++++++++++ recipes/freshrss/index.js | 5 +++++ recipes/freshrss/package.json | 9 +++++++++ recipes/freshrss/webview.js | 25 +++++++++++++++++++++++++ 5 files changed, 55 insertions(+) create mode 100644 recipes/freshrss/README.md create mode 100644 recipes/freshrss/icon.svg create mode 100644 recipes/freshrss/index.js create mode 100644 recipes/freshrss/package.json create mode 100644 recipes/freshrss/webview.js (limited to 'recipes/freshrss') diff --git a/recipes/freshrss/README.md b/recipes/freshrss/README.md new file mode 100644 index 0000000..4b9b17c --- /dev/null +++ b/recipes/freshrss/README.md @@ -0,0 +1,3 @@ +# FreshRSS for Ferdi + +Unofficial Ferdi recipe for [FeshRSS](https://freshrss.org/) \ No newline at end of file diff --git a/recipes/freshrss/icon.svg b/recipes/freshrss/icon.svg new file mode 100644 index 0000000..a252050 --- /dev/null +++ b/recipes/freshrss/icon.svg @@ -0,0 +1,13 @@ + + Logo FreshRSS + + + + + + + + + + + diff --git a/recipes/freshrss/index.js b/recipes/freshrss/index.js new file mode 100644 index 0000000..f8a6e85 --- /dev/null +++ b/recipes/freshrss/index.js @@ -0,0 +1,5 @@ +"use strict"; + +// just pass through ferdi + +module.exports = Ferdi => Ferdi; \ No newline at end of file diff --git a/recipes/freshrss/package.json b/recipes/freshrss/package.json new file mode 100644 index 0000000..64d44db --- /dev/null +++ b/recipes/freshrss/package.json @@ -0,0 +1,9 @@ +{ + "id": "freshrss", + "name": "FreshRSS", + "version": "1.0.1", + "license": "MIT", + "config": { + "hasCustomUrl": true + } +} 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 @@ +"use strict"; + +module.exports = Ferdi => { + const getMessages = function getMessages() { + // Initialize empty vars + var unread = 0; + var match = []; + // Define RegExp to replace occasionally   + var re = new RegExp(String.fromCodePoint(160), "g"); + // Get value of tag where in case of new feed elements the number of elements appear + const titleValue = document.querySelector('title').text.replace(re, ""); + // Extract the number from the tag + match = titleValue.match(/[\d\s]+/); + // Some logic to handle the match groups + unread = match != null && match.length > 0 ? match[0] : 0; + // Set unread msgs badge + Ferdi.setBadge(Number.parseInt(unread, 10)); + }; + + const loopFunc = () => { + getMessages(); + }; + + Ferdi.loop(loopFunc); +}; -- cgit v1.2.3-70-g09d2