From 1d23d2b2c9ad0e815b40220559aef82048ff7fda Mon Sep 17 00:00:00 2001 From: pesader <65264536+pesader@users.noreply.github.com> Date: Wed, 16 Feb 2022 08:31:29 -0300 Subject: Add Zoom recipe (#827) --- recipes/zoom/icon.svg | 1 + recipes/zoom/index.js | 2 ++ recipes/zoom/package.json | 10 +++++++ recipes/zoom/service.css | 3 +++ recipes/zoom/webview.js | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 83 insertions(+) create mode 100644 recipes/zoom/icon.svg create mode 100644 recipes/zoom/index.js create mode 100644 recipes/zoom/package.json create mode 100644 recipes/zoom/service.css create mode 100644 recipes/zoom/webview.js (limited to 'recipes/zoom') diff --git a/recipes/zoom/icon.svg b/recipes/zoom/icon.svg new file mode 100644 index 0000000..f859f62 --- /dev/null +++ b/recipes/zoom/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/recipes/zoom/index.js b/recipes/zoom/index.js new file mode 100644 index 0000000..fcaa5c9 --- /dev/null +++ b/recipes/zoom/index.js @@ -0,0 +1,2 @@ +"use strict"; +module.exports = Ferdi => Ferdi diff --git a/recipes/zoom/package.json b/recipes/zoom/package.json new file mode 100644 index 0000000..ecaf20c --- /dev/null +++ b/recipes/zoom/package.json @@ -0,0 +1,10 @@ +{ + "id": "zoom", + "name": "Zoom", + "version": "1.0.0", + "license": "MIT", + "config": { + "serviceURL": "https://zoom.us/join", + "hasNotificationSound": true + } +} diff --git a/recipes/zoom/service.css b/recipes/zoom/service.css new file mode 100644 index 0000000..a16a615 --- /dev/null +++ b/recipes/zoom/service.css @@ -0,0 +1,3 @@ +.notice { + display: none; +} diff --git a/recipes/zoom/webview.js b/recipes/zoom/webview.js new file mode 100644 index 0000000..9ad54e8 --- /dev/null +++ b/recipes/zoom/webview.js @@ -0,0 +1,67 @@ +const _path = _interopRequireDefault(require('path')); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; +} + +module.exports = (Ferdi, settings) => { + const getMessages = () => { + let directCount = 0; + const directCountPerServer = document.querySelectorAll( + '[class*="lowerBadge-"] [class*="numberBadge-"]', + ); + + for (const directCountBadge of directCountPerServer) { + directCount += Ferdi.safeParseInt(directCountBadge.textContent); + } + + const indirectCountPerServer = document.querySelectorAll( + '[class*="modeUnread-"]', + ).length; + + Ferdi.setBadge(directCount, indirectCountPerServer); + }; + + Ferdi.loop(getMessages); + + Ferdi.injectCSS(_path.default.join(__dirname, 'service.css')); + + // TODO: This whole block is duplicated between the 'discord' and 'skype' recipes - reuse + document.addEventListener( + 'click', + event => { + const link = event.target.closest('a[href^="http"]'); + const button = event.target.closest('button[title^="http"]'); + + if (link || button) { + const url = link + ? link.getAttribute('href') + : button.getAttribute('title'); + + if (url.includes('views/imgpsh_fullsize_anim')) { + event.preventDefault(); + event.stopPropagation(); + // TODO: Can we send an ipc event 'open-browser-window' to open the child window? (see the slack recipe for how to send an ipc message) + // TODO: Can we change the slack recipe to add a clickHandler for screensharing/video calls? (https://github.com/getferdi/ferdi/issues/1697) + let win = new Ferdi.BrowserWindow({ + width: 800, + height: window.innerHeight, + minWidth: 600, + webPreferences: { + partition: `persist:service-${settings.id}`, + nativeWindowOpen: true, + // TODO: Aren't these needed here? + // contextIsolation: false, + // enableRemoteModule: true, + }, + }); + win.loadURL(url); + win.on('closed', () => { + win = null; + }); + } + } + }, + true, + ); +}; -- cgit v1.2.3-70-g09d2