aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/workplace/webview.js
diff options
context:
space:
mode:
authorLibravatar Bennett <hello@vantezzen.io>2020-09-22 20:56:48 +0200
committerLibravatar GitHub <noreply@github.com>2020-09-22 19:56:48 +0100
commit6f5e4a00588aefdda7a5a1cfe70935870e7e234a (patch)
tree9e29aa7aa0620a1a4a968ff8739b4b8ba96791a9 /recipes/workplace/webview.js
parentUpdated logos for Outlook/OWA (diff)
downloadferdium-recipes-6f5e4a00588aefdda7a5a1cfe70935870e7e234a.tar.gz
ferdium-recipes-6f5e4a00588aefdda7a5a1cfe70935870e7e234a.tar.zst
ferdium-recipes-6f5e4a00588aefdda7a5a1cfe70935870e7e234a.zip
Unpack recipes and update recipes icons (#292)
Co-authored-by: Amine Mouafik <amine@mouafik.fr>
Diffstat (limited to 'recipes/workplace/webview.js')
-rw-r--r--recipes/workplace/webview.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/recipes/workplace/webview.js b/recipes/workplace/webview.js
new file mode 100644
index 0000000..a26515e
--- /dev/null
+++ b/recipes/workplace/webview.js
@@ -0,0 +1,51 @@
1"use strict";
2
3const path = require('path');
4
5module.exports = Franz => {
6 const getMessages = () => {
7 let direct = 0;
8 let indirect = 0;
9 const chatsElement = document.querySelector('#chats');
10 const notifications = document.querySelector('#notifications span span');
11
12 if (notifications) {
13 indirect = parseInt(notifications.innerText, 10);
14 }
15
16 if (chatsElement) {
17 if (!chatsElement.hasAttribute('aria-current')) {
18 const chatMessages = chatsElement.querySelector('span');
19
20 if (chatMessages) {
21 direct = parseInt(chatMessages.innerText, 10);
22 }
23 } else {
24 direct = document.querySelectorAll('[data-pagelet="WorkGalahadChannel"] .uiList [role="gridcell"] [role="button"] .oxk9n0fw').length;
25 }
26 }
27
28 Franz.setBadge(direct, indirect);
29 };
30
31 Franz.injectCSS(path.join(__dirname, 'workplace.css'));
32 Franz.loop(getMessages);
33 localStorage._cs_desktopNotifsEnabled = JSON.stringify({
34 __t: new Date().getTime(),
35 __v: true
36 });
37
38 if (typeof Franz.onNotify === 'function') {
39 Franz.onNotify(notification => {
40 if (typeof notification.title !== 'string') {
41 notification.title = ((notification.title.props || {}).content || [])[0] || 'Work Chat';
42 }
43
44 if (typeof notification.options.body !== 'string') {
45 notification.options.body = (((notification.options.body || {}).props || {}).content || [])[0] || '';
46 }
47
48 return notification;
49 });
50 }
51}; \ No newline at end of file