diff options
author | Bennett <hello@vantezzen.io> | 2020-09-22 20:56:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-22 19:56:48 +0100 |
commit | 6f5e4a00588aefdda7a5a1cfe70935870e7e234a (patch) | |
tree | 9e29aa7aa0620a1a4a968ff8739b4b8ba96791a9 /uncompressed/msteams/webview.js | |
parent | Updated logos for Outlook/OWA (diff) | |
download | ferdium-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 'uncompressed/msteams/webview.js')
-rw-r--r-- | uncompressed/msteams/webview.js | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/uncompressed/msteams/webview.js b/uncompressed/msteams/webview.js deleted file mode 100644 index 7823c63..0000000 --- a/uncompressed/msteams/webview.js +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | "use strict"; | ||
2 | |||
3 | const { desktopCapturer } = require('electron'); | ||
4 | const path = require('path'); | ||
5 | |||
6 | window.navigator.mediaDevices.getDisplayMedia = () => { | ||
7 | return new Promise(async (resolve, reject) => { | ||
8 | try { | ||
9 | const sources = await desktopCapturer.getSources({ types: ['screen', 'window'] }); | ||
10 | |||
11 | const selectionElem = document.createElement('div'); | ||
12 | selectionElem.classList = 'desktop-capturer-selection'; | ||
13 | selectionElem.innerHTML = ` | ||
14 | <div class="desktop-capturer-selection__scroller"> | ||
15 | <ul class="desktop-capturer-selection__list"> | ||
16 | ${sources.map(({ id, name, thumbnail, display_id, appIcon }) => ` | ||
17 | <li class="desktop-capturer-selection__item"> | ||
18 | <button class="desktop-capturer-selection__btn" data-id="${id}" title="${name}"> | ||
19 | <img class="desktop-capturer-selection__thumbnail" src="${thumbnail.toDataURL()}" /> | ||
20 | <span class="desktop-capturer-selection__name">${name}</span> | ||
21 | </button> | ||
22 | </li> | ||
23 | `).join('')} | ||
24 | </ul> | ||
25 | </div> | ||
26 | `; | ||
27 | document.body.appendChild(selectionElem); | ||
28 | |||
29 | document.querySelectorAll('.desktop-capturer-selection__btn') | ||
30 | .forEach(button => { | ||
31 | button.addEventListener('click', async () => { | ||
32 | try { | ||
33 | const id = button.getAttribute('data-id'); | ||
34 | const source = sources.find(source => source.id === id); | ||
35 | if (!source) { | ||
36 | throw new Error(`Source with id ${id} does not exist`); | ||
37 | } | ||
38 | |||
39 | const stream = await window.navigator.mediaDevices.getUserMedia({ | ||
40 | audio: false, | ||
41 | video: { | ||
42 | mandatory: { | ||
43 | chromeMediaSource: 'desktop', | ||
44 | chromeMediaSourceId: source.id | ||
45 | } | ||
46 | } | ||
47 | }); | ||
48 | resolve(stream); | ||
49 | |||
50 | selectionElem.remove(); | ||
51 | } catch (err) { | ||
52 | reject(err); | ||
53 | } | ||
54 | }); | ||
55 | }); | ||
56 | } catch (err) { | ||
57 | reject(err); | ||
58 | } | ||
59 | }) | ||
60 | } | ||
61 | |||
62 | window.electronSafeIpc = { | ||
63 | send: () => null, | ||
64 | on: () => null | ||
65 | }; | ||
66 | window.desktop = undefined; | ||
67 | |||
68 | module.exports = Franz => { | ||
69 | const getMessages = () => { | ||
70 | let messages = 0; | ||
71 | const badge = document.querySelector('.activity-badge.dot-activity-badge .activity-badge'); | ||
72 | |||
73 | if (badge) { | ||
74 | const value = parseInt(badge.innerHTML, 10); | ||
75 | |||
76 | if (!isNaN(value)) { | ||
77 | messages = value; | ||
78 | } | ||
79 | } | ||
80 | const indirectMessages = document.querySelectorAll("[class*=channel-anchor][class*=ts-unread-channel]").length; | ||
81 | |||
82 | Franz.setBadge(messages, indirectMessages); | ||
83 | }; | ||
84 | |||
85 | Franz.injectCSS(path.join(__dirname, 'service.css')); | ||
86 | Franz.loop(getMessages); | ||
87 | }; | ||