From 6f5e4a00588aefdda7a5a1cfe70935870e7e234a Mon Sep 17 00:00:00 2001 From: Bennett Date: Tue, 22 Sep 2020 20:56:48 +0200 Subject: Unpack recipes and update recipes icons (#292) Co-authored-by: Amine Mouafik --- recipes/element/README.md | 2 ++ recipes/element/icon.png | Bin 0 -> 26967 bytes recipes/element/icon.svg | 6 ++++++ recipes/element/index.js | 3 +++ recipes/element/package.json | 18 ++++++++++++++++++ recipes/element/webview.js | 25 +++++++++++++++++++++++++ 6 files changed, 54 insertions(+) create mode 100644 recipes/element/README.md create mode 100644 recipes/element/icon.png create mode 100644 recipes/element/icon.svg create mode 100644 recipes/element/index.js create mode 100644 recipes/element/package.json create mode 100644 recipes/element/webview.js (limited to 'recipes/element') diff --git a/recipes/element/README.md b/recipes/element/README.md new file mode 100644 index 0000000..221864f --- /dev/null +++ b/recipes/element/README.md @@ -0,0 +1,2 @@ +# Element for Franz and Ferdi +This is a Franz and Ferdi recipe/plugin for Element diff --git a/recipes/element/icon.png b/recipes/element/icon.png new file mode 100644 index 0000000..58d2a9f Binary files /dev/null and b/recipes/element/icon.png differ diff --git a/recipes/element/icon.svg b/recipes/element/icon.svg new file mode 100644 index 0000000..b30aafe --- /dev/null +++ b/recipes/element/icon.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/recipes/element/index.js b/recipes/element/index.js new file mode 100644 index 0000000..17daa35 --- /dev/null +++ b/recipes/element/index.js @@ -0,0 +1,3 @@ +"use strict"; + +module.exports = Franz => Franz; diff --git a/recipes/element/package.json b/recipes/element/package.json new file mode 100644 index 0000000..3b2f59f --- /dev/null +++ b/recipes/element/package.json @@ -0,0 +1,18 @@ +{ + "id": "element", + "name": "Element", + "version": "1.0.2", + "description": "Decentralized, encrypted chat & collaboration powered by [matrix]", + "main": "index.js", + "author": "Sylvain Cecchetto , Omove <61330514+omove@users.noreply.github.com>, Achim Leitner <1033549+fjl5@users.noreply.github.com>", + "license": "MIT", + "config": { + "serviceURL": "https://app.element.io", + "hasTeamID": false, + "hasCustomUrl": true, + "message": "Element's default URL is https://app.element.io/", + "urlInputSuffix": false, + "hasNotificationSound": true, + "hasIndirectMessages": true + } +} diff --git a/recipes/element/webview.js b/recipes/element/webview.js new file mode 100644 index 0000000..aab6038 --- /dev/null +++ b/recipes/element/webview.js @@ -0,0 +1,25 @@ +'use strict'; + +module.exports = Franz => { + function getMessages() { + const badges = document.getElementsByClassName('mx_RoomSublist_badgeContainer'); + + // Number of messages from People + let direct_count = 0; + if (badges.length > 0 && badges[0].children.length > 0) { + direct_count = parseInt(badges[0].textContent) + } + + // Number of messages from Rooms + let indirect_count = 0; + if (badges.length > 1 && badges[1].children.length > 0) { + indirect_count = parseInt(badges[1].textContent) + } + + // set Franz badge + Franz.setBadge(direct_count, indirect_count); + } + + // check for new messages every second and update Franz badge + Franz.loop(getMessages); +}; -- cgit v1.2.3-70-g09d2