From 37485190b18ccd01d01e2bfe68960b32d8ed357a Mon Sep 17 00:00:00 2001 From: deadmeu Date: Mon, 29 Nov 2021 01:58:16 +1100 Subject: Add RingCentral recipe (#776) --- recipes/circuit/webview.js | 1 - recipes/proton-mail/webview.js | 4 ++-- recipes/ringcentral/icon.svg | 1 + recipes/ringcentral/index.js | 1 + recipes/ringcentral/package.json | 15 +++++++++++++++ recipes/ringcentral/webview.js | 19 +++++++++++++++++++ 6 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 recipes/ringcentral/icon.svg create mode 100644 recipes/ringcentral/index.js create mode 100644 recipes/ringcentral/package.json create mode 100644 recipes/ringcentral/webview.js (limited to 'recipes') diff --git a/recipes/circuit/webview.js b/recipes/circuit/webview.js index ab1175f..ce74eef 100644 --- a/recipes/circuit/webview.js +++ b/recipes/circuit/webview.js @@ -3,7 +3,6 @@ module.exports = Ferdi => { const getMessages = function getMessages() { // Initialize empty vars - var unread = 0; var match = []; // Get value of tag where in case of new messages the number of messages appear const titleValue = document.querySelector('title').text; diff --git a/recipes/proton-mail/webview.js b/recipes/proton-mail/webview.js index 89e5dab..455a0c4 100644 --- a/recipes/proton-mail/webview.js +++ b/recipes/proton-mail/webview.js @@ -2,10 +2,10 @@ module.exports = Ferdi => { const getMessages = () => { let unreadCount = 0; // Loop over all displayed counters and take the highest one (from the "All Mail" folder) - document.querySelectorAll('.navigation-counter-item').forEach(counterElement => { + for (const counterElement of document.querySelectorAll('.navigation-counter-item')) { const unreadCounter = Ferdi.safeParseInt(counterElement.textContent); unreadCount = Math.max(unreadCount, unreadCounter); - }); + } Ferdi.setBadge(unreadCount); }; diff --git a/recipes/ringcentral/icon.svg b/recipes/ringcentral/icon.svg new file mode 100644 index 0000000..e30813e --- /dev/null +++ b/recipes/ringcentral/icon.svg @@ -0,0 +1 @@ +<svg width="1024" height="1024" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><g fill-rule="nonzero" fill="none"><path d="M25 2a5 5 0 0 1 5 5v18a5 5 0 0 1-5 5H7a5 5 0 0 1-5-5V7a5 5 0 0 1 5-5h18Z" fill="#FFF"/><path d="M24 0H8a8 8 0 0 0-8 8v16a8 8 0 0 0 8 8h16a8 8 0 0 0 8-8V8a8 8 0 0 0-8-8Zm0 3a5 5 0 0 1 5 5v16a5 5 0 0 1-5 5H8a5 5 0 0 1-5-5V8a5 5 0 0 1 5-5h16Z" fill="#FF7A00"/><path d="M11.092 24.672a.434.434 0 0 0 .322-.124.437.437 0 0 0 .125-.321v-12.54a.351.351 0 0 1 .395-.397h8.13a.35.35 0 0 1 .386.397V15.6a.349.349 0 0 1-.386.397h-3.662a.35.35 0 0 0-.403.397v1.735c-.007.395.03.79.112 1.176.085.35.232.681.434.979l2.527 3.965a.898.898 0 0 0 .842.422h3.296c.166 0 .274-.045.324-.137a.325.325 0 0 0-.05-.334l-2.506-4.047c-.116-.166-.073-.297.125-.397l1.758-.792a2.945 2.945 0 0 0 1.376-1.141c.305-.541.456-1.155.436-1.776v-5.75c0-.974-.252-1.714-.756-2.218-.503-.503-1.243-.755-2.218-.755h-11.4c-.954 0-1.688.252-2.202.755-.514.504-.771 1.244-.771 2.219v13.928a.436.436 0 0 0 .123.321.435.435 0 0 0 .322.124h3.321Z" fill="#0684BC"/></g></svg> \ No newline at end of file diff --git a/recipes/ringcentral/index.js b/recipes/ringcentral/index.js new file mode 100644 index 0000000..23607bd --- /dev/null +++ b/recipes/ringcentral/index.js @@ -0,0 +1 @@ +module.exports = Ferdi => Ferdi; diff --git a/recipes/ringcentral/package.json b/recipes/ringcentral/package.json new file mode 100644 index 0000000..0c8ecab --- /dev/null +++ b/recipes/ringcentral/package.json @@ -0,0 +1,15 @@ +{ + "id": "ringcentral", + "name": "RingCentral", + "version": "1.0.0", + "license": "MIT", + "repository": "https://github.com/deadmeu/ferdi-ringcentral", + "aliases": [ + "Glip" + ], + "config": { + "serviceURL": "https://app.ringcentral.com/", + "hasNotificationSound": true, + "hasIndirectMessages": true + } +} diff --git a/recipes/ringcentral/webview.js b/recipes/ringcentral/webview.js new file mode 100644 index 0000000..ba4f50c --- /dev/null +++ b/recipes/ringcentral/webview.js @@ -0,0 +1,19 @@ +module.exports = Ferdi => { + const getMessages = () => { + let directCount = 0; + let indirectCount = 0; + + const messageCountElement = document.querySelector('#Message-umi'); + if (messageCountElement) { + directCount = Ferdi.safeParseInt(messageCountElement.textContent); + } + + const unreadChats = document.querySelectorAll('.has-unread'); + // unreadChats includes direct messages - do not count them + indirectCount = unreadChats.length - directCount; + + Ferdi.setBadge(directCount, indirectCount); + }; + + Ferdi.loop(getMessages); +}; -- cgit v1.2.3-54-g00ecf