aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/zoom/webview.js
diff options
context:
space:
mode:
authorLibravatar pesader <65264536+pesader@users.noreply.github.com>2022-02-16 08:31:29 -0300
committerLibravatar GitHub <noreply@github.com>2022-02-16 12:31:29 +0100
commit1d23d2b2c9ad0e815b40220559aef82048ff7fda (patch)
tree9d44bcdcd866776578e6ad16bba3e1aa86eab87d /recipes/zoom/webview.js
parentdocs: add pesader as a contributor for code (#832) (diff)
downloadferdium-recipes-1d23d2b2c9ad0e815b40220559aef82048ff7fda.tar.gz
ferdium-recipes-1d23d2b2c9ad0e815b40220559aef82048ff7fda.tar.zst
ferdium-recipes-1d23d2b2c9ad0e815b40220559aef82048ff7fda.zip
Add Zoom recipe (#827)
Diffstat (limited to 'recipes/zoom/webview.js')
-rw-r--r--recipes/zoom/webview.js67
1 files changed, 67 insertions, 0 deletions
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 @@
1const _path = _interopRequireDefault(require('path'));
2
3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
6
7module.exports = (Ferdi, settings) => {
8 const getMessages = () => {
9 let directCount = 0;
10 const directCountPerServer = document.querySelectorAll(
11 '[class*="lowerBadge-"] [class*="numberBadge-"]',
12 );
13
14 for (const directCountBadge of directCountPerServer) {
15 directCount += Ferdi.safeParseInt(directCountBadge.textContent);
16 }
17
18 const indirectCountPerServer = document.querySelectorAll(
19 '[class*="modeUnread-"]',
20 ).length;
21
22 Ferdi.setBadge(directCount, indirectCountPerServer);
23 };
24
25 Ferdi.loop(getMessages);
26
27 Ferdi.injectCSS(_path.default.join(__dirname, 'service.css'));
28
29 // TODO: This whole block is duplicated between the 'discord' and 'skype' recipes - reuse
30 document.addEventListener(
31 'click',
32 event => {
33 const link = event.target.closest('a[href^="http"]');
34 const button = event.target.closest('button[title^="http"]');
35
36 if (link || button) {
37 const url = link
38 ? link.getAttribute('href')
39 : button.getAttribute('title');
40
41 if (url.includes('views/imgpsh_fullsize_anim')) {
42 event.preventDefault();
43 event.stopPropagation();
44 // 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)
45 // TODO: Can we change the slack recipe to add a clickHandler for screensharing/video calls? (https://github.com/getferdi/ferdi/issues/1697)
46 let win = new Ferdi.BrowserWindow({
47 width: 800,
48 height: window.innerHeight,
49 minWidth: 600,
50 webPreferences: {
51 partition: `persist:service-${settings.id}`,
52 nativeWindowOpen: true,
53 // TODO: Aren't these needed here?
54 // contextIsolation: false,
55 // enableRemoteModule: true,
56 },
57 });
58 win.loadURL(url);
59 win.on('closed', () => {
60 win = null;
61 });
62 }
63 }
64 },
65 true,
66 );
67};