aboutsummaryrefslogtreecommitdiffstats
path: root/uncompressed
diff options
context:
space:
mode:
authorLibravatar Gautam Singh <5769869+gautamsi@users.noreply.github.com>2020-04-20 01:59:46 +0530
committerLibravatar GitHub <noreply@github.com>2020-04-19 20:29:46 +0000
commitca864ed334debad62a2a358249a84438ea87d633 (patch)
tree0ccf80824b2d1fe8cbc2508f28c372073e484901 /uncompressed
parentMerge pull request #115 from getferdi/fix/user-agents (diff)
downloadferdium-recipes-ca864ed334debad62a2a358249a84438ea87d633.tar.gz
ferdium-recipes-ca864ed334debad62a2a358249a84438ea87d633.tar.zst
ferdium-recipes-ca864ed334debad62a2a358249a84438ea87d633.zip
Update Microsoft Teams to allow Desktop Sharing (#116)
Diffstat (limited to 'uncompressed')
-rw-r--r--uncompressed/msteams/index.js3
-rw-r--r--uncompressed/msteams/package.json2
-rw-r--r--uncompressed/msteams/service.css60
-rw-r--r--uncompressed/msteams/webview.js59
4 files changed, 120 insertions, 4 deletions
diff --git a/uncompressed/msteams/index.js b/uncompressed/msteams/index.js
index b85bf33..918b7b3 100644
--- a/uncompressed/msteams/index.js
+++ b/uncompressed/msteams/index.js
@@ -2,7 +2,6 @@
2 2
3module.exports = Franz => class MicrosoftTeams extends Franz { 3module.exports = Franz => class MicrosoftTeams extends Franz {
4 overrideUserAgent() { 4 overrideUserAgent() {
5 return window.navigator.userAgent.replace(/(Ferdi|Electron)\/\S+ \([^)]+\)/g, '').replace(/(Chrome\/)([^ ]*)/g, '$163.0.3239.84'); 5 return window.navigator.userAgent.replace(/(Ferdi|Electron)\/\S+ \([^)]+\)/g, '');
6 } 6 }
7
8}; \ No newline at end of file 7}; \ No newline at end of file
diff --git a/uncompressed/msteams/package.json b/uncompressed/msteams/package.json
index 85993a8..240d059 100644
--- a/uncompressed/msteams/package.json
+++ b/uncompressed/msteams/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "msteams", 2 "id": "msteams",
3 "name": "Microsoft Teams", 3 "name": "Microsoft Teams",
4 "version": "1.2.0", 4 "version": "1.3.0",
5 "description": "Microsoft Teams", 5 "description": "Microsoft Teams",
6 "main": "index.js", 6 "main": "index.js",
7 "author": "Stefan Malzner <stefan@adlk.io>", 7 "author": "Stefan Malzner <stefan@adlk.io>",
diff --git a/uncompressed/msteams/service.css b/uncompressed/msteams/service.css
index 533004f..fdaeac6 100644
--- a/uncompressed/msteams/service.css
+++ b/uncompressed/msteams/service.css
@@ -1,3 +1,63 @@
1notification-banner { 1notification-banner {
2 display: none !important; 2 display: none !important;
3} 3}
4.desktop-capturer-selection {
5 position: fixed;
6 top: 0;
7 left: 0;
8 width: 100%;
9 height: 100vh;
10 background: rgba(30,30,30,.75);
11 color: #fff;
12 z-index: 10000000;
13 display: flex;
14 align-items: center;
15 justify-content: center;
16}
17.desktop-capturer-selection__scroller {
18 width: 100%;
19 max-height: 100vh;
20 overflow-y: auto;
21}
22.desktop-capturer-selection__list {
23 max-width: calc(100% - 100px);
24 margin: 50px;
25 padding: 0;
26 display: flex;
27 flex-wrap: wrap;
28 list-style: none;
29 overflow: hidden;
30 justify-content: center;
31}
32.desktop-capturer-selection__item {
33 display: flex;
34 margin: 4px;
35}
36.desktop-capturer-selection__btn {
37 display: flex;
38 flex-direction: column;
39 align-items: stretch;
40 width: 145px;
41 margin: 0;
42 border: 0;
43 border-radius: 3px;
44 padding: 4px;
45 background: #252626;
46 text-align: left;
47 transition: background-color .15s, box-shadow .15s;
48}
49.desktop-capturer-selection__btn:hover,
50.desktop-capturer-selection__btn:focus {
51 background: rgba(98,100,167,.8);
52}
53.desktop-capturer-selection__thumbnail {
54 width: 100%;
55 height: 81px;
56 object-fit: cover;
57}
58.desktop-capturer-selection__name {
59 margin: 6px 0 6px;
60 white-space: nowrap;
61 text-overflow: ellipsis;
62 overflow: hidden;
63} \ No newline at end of file
diff --git a/uncompressed/msteams/webview.js b/uncompressed/msteams/webview.js
index d614097..0fd5253 100644
--- a/uncompressed/msteams/webview.js
+++ b/uncompressed/msteams/webview.js
@@ -1,7 +1,64 @@
1"use strict"; 1"use strict";
2 2
3const { desktopCapturer } = require('electron');
3const path = require('path'); 4const path = require('path');
4 5
6window.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
5window.electronSafeIpc = { 62window.electronSafeIpc = {
6 send: () => null, 63 send: () => null,
7 on: () => null 64 on: () => null
@@ -26,4 +83,4 @@ module.exports = Franz => {
26 83
27 Franz.injectCSS(path.join(__dirname, 'service.css')); 84 Franz.injectCSS(path.join(__dirname, 'service.css'));
28 Franz.loop(getMessages); 85 Franz.loop(getMessages);
29}; \ No newline at end of file 86};