From 00ddef3290732403dc1ca02b1c2ae7a7b6a796c3 Mon Sep 17 00:00:00 2001 From: Francisco Marques Date: Wed, 7 Oct 2020 15:24:54 +0100 Subject: Add recipe for Slite (#312) --- recipes/slite/webview.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 recipes/slite/webview.js (limited to 'recipes/slite/webview.js') diff --git a/recipes/slite/webview.js b/recipes/slite/webview.js new file mode 100644 index 0000000..6e0fa46 --- /dev/null +++ b/recipes/slite/webview.js @@ -0,0 +1,24 @@ +"use strict"; + +var _path = _interopRequireDefault(require("path")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +module.exports = Ferdi => { + const getMessages = function getMessages() { + let direct = 0; + + const notificationButton = document.querySelector( + "#app button[data-test-id='notificationsCount'" + ); + + if (notificationButton) { + const notificationCount = parseInt(notificationButton.innerText); + direct = isNaN(notificationCount) ? 0 : notificationCount; + } + + Ferdi.setBadge(direct); + }; + + Ferdi.loop(getMessages); +}; -- cgit v1.2.3-70-g09d2