diff options
Diffstat (limited to 'recipes/zoom/webview.js')
-rw-r--r-- | recipes/zoom/webview.js | 67 |
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 @@ | |||
1 | const _path = _interopRequireDefault(require('path')); | ||
2 | |||
3 | function _interopRequireDefault(obj) { | ||
4 | return obj && obj.__esModule ? obj : { default: obj }; | ||
5 | } | ||
6 | |||
7 | module.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 | }; | ||