aboutsummaryrefslogtreecommitdiffstats
path: root/recipes
diff options
context:
space:
mode:
authorLibravatar Joseph Hale <47901316+thehale@users.noreply.github.com>2023-05-23 14:43:25 -0700
committerLibravatar GitHub <noreply@github.com>2023-05-23 22:43:25 +0100
commiteef3b310e7081c4a636bb29739fb99cb917d4974 (patch)
tree0b678650325fd106c6e48b875108ba5c6d65ec8a /recipes
parentfix(github): Include "new notifications" in direct total (#371) (diff)
downloadferdium-recipes-eef3b310e7081c4a636bb29739fb99cb917d4974.tar.gz
ferdium-recipes-eef3b310e7081c4a636bb29739fb99cb917d4974.tar.zst
ferdium-recipes-eef3b310e7081c4a636bb29739fb99cb917d4974.zip
feat(tt-rss): Optionally limit notifications to a Category. (#370)
Diffstat (limited to 'recipes')
-rw-r--r--recipes/tt-rss/README.md38
-rw-r--r--recipes/tt-rss/package.json2
-rw-r--r--recipes/tt-rss/webview.js43
3 files changed, 72 insertions, 11 deletions
diff --git a/recipes/tt-rss/README.md b/recipes/tt-rss/README.md
index d0ef122..a4866d4 100644
--- a/recipes/tt-rss/README.md
+++ b/recipes/tt-rss/README.md
@@ -1,3 +1,39 @@
1# Tiny Tiny RSS for Ferdium 1# Tiny Tiny RSS for Ferdium
2 2
3Support for [Tiny Tiny RSS](https://tt-rss.org/) 3Interact with [Tiny Tiny RSS](https://tt-rss.org/) inside of Ferdium!
4
5## Usage
6
71. Search for "RSS" in Ferdium's **Available Services**
82. Enter the URL of your Tiny Tiny RSS server
93. Save the service and log in!
10
11## Configuration
12
13### `ferdiumNotificationLabel`
14
15You can limit notifications from Tiny Tiny RSS to new articles in a specific
16Category using the custom `ferdiumNotificationLabel` query parameter as part of
17your server URL.
18
19```
20https://ttrss.example.com/tt-rss/?ferdiumNotificationLabel=CATEGORY_NAME
21```
22
23For example, if I wanted to only see notifications from a Category titled
24`Software - Updates`, I would use one of the following query parameters:
25
26```
27?ferdiumNotificationLabel=Software - Updates
28```
29**OR**
30```
31?ferdiumNotificationLabel=Software%20-%20Updates
32```
33
34The second option is the better/safer approach to take, but the first also works
35because Ferdium will escape the spaces for you (at least as of version 6.2.7).
36
37NOTE: When using the `ferdiumNotificationLabel` configuration, all other unread
38articles in other categories are reported as [**indirect**
39messages](https://github.com/ferdium/ferdium-recipes/blob/main/docs/frontend_api.md#setbadgedirectmessages-indirectmessages). \ No newline at end of file
diff --git a/recipes/tt-rss/package.json b/recipes/tt-rss/package.json
index 2b3a305..a2fff77 100644
--- a/recipes/tt-rss/package.json
+++ b/recipes/tt-rss/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "tt-rss", 2 "id": "tt-rss",
3 "name": "Tiny Tiny RSS", 3 "name": "Tiny Tiny RSS",
4 "version": "1.1.0", 4 "version": "1.2.0",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "hasCustomUrl": true 7 "hasCustomUrl": true
diff --git a/recipes/tt-rss/webview.js b/recipes/tt-rss/webview.js
index 3e3a0d3..7d90615 100644
--- a/recipes/tt-rss/webview.js
+++ b/recipes/tt-rss/webview.js
@@ -1,16 +1,41 @@
1"use strict"; 1"use strict";
2 2
3module.exports = Ferdium => { 3module.exports = Ferdium => {
4 const _notificationCategory = new URL(window.location.href).searchParams.get("ferdiumNotificationCategory");
5
4 const getMessages = function getMessages() { 6 const getMessages = function getMessages() {
5 // Initialize empty vars 7 if (_notificationCategory) {
6 var unread = 0; 8 countMessagesUnderCategory(_notificationCategory);
7 var match = []; 9 } else {
8 // Extract the number from the title 10 countMessages();
9 match = document.title.match(/^\((\d+)\) Tiny Tiny RSS$/); 11 }
10 // Some logic to handle the match groups 12 };
11 unread = match != null && match.length > 0 ? match[1] : 0; 13
12 // Set unread msgs badge 14 const countMessagesUnderCategory = (notificationCategory) => {
13 Ferdium.setBadge(Number.parseInt(unread, 10)); 15 var elements = document.querySelectorAll(".dijitTreeIsRoot")
16 var directMessages = 0;
17 var indirectMessages = 0;
18 for (var element of elements) {
19 var label = element.querySelectorAll(".dijitTreeLabel")[0];
20 var unreadNode = element.querySelectorAll(".unread")[0];
21 var unreadAmount = Ferdium.safeParseInt(unreadNode.textContent);
22 if (label.textContent === notificationCategory) {
23 directMessages += unreadAmount;
24 } else {
25 indirectMessages += unreadAmount;
26 }
27 }
28 Ferdium.setBadge(directMessages, indirectMessages);
29 };
30
31 const _countMessagesFromTitle = () => {
32 var match = document.title.match(/^\((\d+)\) Tiny Tiny RSS$/);
33 var count = match != null && match.length > 0 ? match[1] : 0;
34 return Ferdium.safeParseInt(count);
35 }
36
37 const countMessages = () => {
38 Ferdium.setBadge(_countMessagesFromTitle());
14 }; 39 };
15 40
16 const loopFunc = () => { 41 const loopFunc = () => {