From 2e7b17768f679cd94352d0f544e8f95966f3c894 Mon Sep 17 00:00:00 2001 From: JP Roemer Date: Mon, 3 Oct 2022 18:07:01 +0200 Subject: Add Cinny.in recipe --- recipes/cinny/icon.svg | 14 ++++++++++++++ recipes/cinny/index.js | 1 + recipes/cinny/package.json | 17 +++++++++++++++++ recipes/cinny/webview.js | 22 ++++++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 recipes/cinny/icon.svg create mode 100644 recipes/cinny/index.js create mode 100644 recipes/cinny/package.json create mode 100644 recipes/cinny/webview.js (limited to 'recipes') diff --git a/recipes/cinny/icon.svg b/recipes/cinny/icon.svg new file mode 100644 index 0000000..241eb5c --- /dev/null +++ b/recipes/cinny/icon.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/recipes/cinny/index.js b/recipes/cinny/index.js new file mode 100644 index 0000000..dd41f72 --- /dev/null +++ b/recipes/cinny/index.js @@ -0,0 +1 @@ +module.exports = Ferdium => Ferdium; diff --git a/recipes/cinny/package.json b/recipes/cinny/package.json new file mode 100644 index 0000000..5250882 --- /dev/null +++ b/recipes/cinny/package.json @@ -0,0 +1,17 @@ +{ + "id": "cinny", + "name": "Cinny", + "version": "1.0.0", + "license": "MIT", + "aliases": [ + "Matrix" + ], + "config": { + "serviceURL": "https://app.cinny.in/", + "hasCustomUrl": true, + "message": "Cinny's default URL is https://app.cinny.in/", + "hasNotificationSound": true, + "hasDirectMessages": true, + "hasIndirectMessages": true + } +} diff --git a/recipes/cinny/webview.js b/recipes/cinny/webview.js new file mode 100644 index 0000000..f4fd306 --- /dev/null +++ b/recipes/cinny/webview.js @@ -0,0 +1,22 @@ +module.exports = Ferdium => { + function getMessages() { + // Number of messages from rooms which has "All Messages" notifications enabled or when mentionned in a room with "Mentions & Keyword" notifications level. + let directCount = 0; + // Number of messages for rooms which has "Mentions & Keyword" notifications level set which does not directly mention you. + let indirectCount = 0; + + // Retrieves notification badges + const badges = document.querySelectorAll('.sidebar .notification-badge'); + for (const badge of badges) { + if (badge.childNodes.length === 0) { + indirectCount++; + } else { + directCount += Ferdium.safeParseInt(badge.childNodes[0].textContent); + } + } + + // Set Ferdium badge + Ferdium.setBadge(directCount, indirectCount); + } + Ferdium.loop(getMessages); +}; -- cgit v1.2.3-54-g00ecf