From 6f5e4a00588aefdda7a5a1cfe70935870e7e234a Mon Sep 17 00:00:00 2001 From: Bennett Date: Tue, 22 Sep 2020 20:56:48 +0200 Subject: Unpack recipes and update recipes icons (#292) Co-authored-by: Amine Mouafik --- recipes/msteams/icon.png | Bin 0 -> 36329 bytes recipes/msteams/icon.svg | 1 + recipes/msteams/index.js | 7 ++++ recipes/msteams/package.json | 15 ++++++++ recipes/msteams/service.css | 63 +++++++++++++++++++++++++++++++ recipes/msteams/webview.js | 87 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 173 insertions(+) create mode 100644 recipes/msteams/icon.png create mode 100644 recipes/msteams/icon.svg create mode 100644 recipes/msteams/index.js create mode 100644 recipes/msteams/package.json create mode 100644 recipes/msteams/service.css create mode 100644 recipes/msteams/webview.js (limited to 'recipes/msteams') diff --git a/recipes/msteams/icon.png b/recipes/msteams/icon.png new file mode 100644 index 0000000..f136dc4 Binary files /dev/null and b/recipes/msteams/icon.png differ diff --git a/recipes/msteams/icon.svg b/recipes/msteams/icon.svg new file mode 100644 index 0000000..6279612 --- /dev/null +++ b/recipes/msteams/icon.svg @@ -0,0 +1 @@ +OfficeCore10_32x_24x_20x_16x_01-22-2019 \ No newline at end of file diff --git a/recipes/msteams/index.js b/recipes/msteams/index.js new file mode 100644 index 0000000..918b7b3 --- /dev/null +++ b/recipes/msteams/index.js @@ -0,0 +1,7 @@ +"use strict"; + +module.exports = Franz => class MicrosoftTeams extends Franz { + overrideUserAgent() { + return window.navigator.userAgent.replace(/(Ferdi|Electron)\/\S+ \([^)]+\)/g, ''); + } +}; \ No newline at end of file diff --git a/recipes/msteams/package.json b/recipes/msteams/package.json new file mode 100644 index 0000000..4b3579a --- /dev/null +++ b/recipes/msteams/package.json @@ -0,0 +1,15 @@ +{ + "id": "msteams", + "name": "Microsoft Teams", + "version": "1.3.3", + "description": "Microsoft Teams", + "main": "index.js", + "author": "Stefan Malzner ", + "license": "MIT", + "config": { + "serviceURL": "https://teams.microsoft.com", + "hasNotificationSound": true, + "hasDirectMessages": true, + "hasIndirectMessages": true + } +} diff --git a/recipes/msteams/service.css b/recipes/msteams/service.css new file mode 100644 index 0000000..fdaeac6 --- /dev/null +++ b/recipes/msteams/service.css @@ -0,0 +1,63 @@ +notification-banner { + display: none !important; +} +.desktop-capturer-selection { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100vh; + background: rgba(30,30,30,.75); + color: #fff; + z-index: 10000000; + display: flex; + align-items: center; + justify-content: center; +} +.desktop-capturer-selection__scroller { + width: 100%; + max-height: 100vh; + overflow-y: auto; +} +.desktop-capturer-selection__list { + max-width: calc(100% - 100px); + margin: 50px; + padding: 0; + display: flex; + flex-wrap: wrap; + list-style: none; + overflow: hidden; + justify-content: center; +} +.desktop-capturer-selection__item { + display: flex; + margin: 4px; +} +.desktop-capturer-selection__btn { + display: flex; + flex-direction: column; + align-items: stretch; + width: 145px; + margin: 0; + border: 0; + border-radius: 3px; + padding: 4px; + background: #252626; + text-align: left; + transition: background-color .15s, box-shadow .15s; +} +.desktop-capturer-selection__btn:hover, +.desktop-capturer-selection__btn:focus { + background: rgba(98,100,167,.8); +} +.desktop-capturer-selection__thumbnail { + width: 100%; + height: 81px; + object-fit: cover; +} +.desktop-capturer-selection__name { + margin: 6px 0 6px; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} \ No newline at end of file diff --git a/recipes/msteams/webview.js b/recipes/msteams/webview.js new file mode 100644 index 0000000..7823c63 --- /dev/null +++ b/recipes/msteams/webview.js @@ -0,0 +1,87 @@ +"use strict"; + +const { desktopCapturer } = require('electron'); +const path = require('path'); + +window.navigator.mediaDevices.getDisplayMedia = () => { + return new Promise(async (resolve, reject) => { + try { + const sources = await desktopCapturer.getSources({ types: ['screen', 'window'] }); + + const selectionElem = document.createElement('div'); + selectionElem.classList = 'desktop-capturer-selection'; + selectionElem.innerHTML = ` +
+
    + ${sources.map(({ id, name, thumbnail, display_id, appIcon }) => ` +
  • + +
  • + `).join('')} +
+
+ `; + document.body.appendChild(selectionElem); + + document.querySelectorAll('.desktop-capturer-selection__btn') + .forEach(button => { + button.addEventListener('click', async () => { + try { + const id = button.getAttribute('data-id'); + const source = sources.find(source => source.id === id); + if (!source) { + throw new Error(`Source with id ${id} does not exist`); + } + + const stream = await window.navigator.mediaDevices.getUserMedia({ + audio: false, + video: { + mandatory: { + chromeMediaSource: 'desktop', + chromeMediaSourceId: source.id + } + } + }); + resolve(stream); + + selectionElem.remove(); + } catch (err) { + reject(err); + } + }); + }); + } catch (err) { + reject(err); + } + }) +} + +window.electronSafeIpc = { + send: () => null, + on: () => null +}; +window.desktop = undefined; + +module.exports = Franz => { + const getMessages = () => { + let messages = 0; + const badge = document.querySelector('.activity-badge.dot-activity-badge .activity-badge'); + + if (badge) { + const value = parseInt(badge.innerHTML, 10); + + if (!isNaN(value)) { + messages = value; + } + } + const indirectMessages = document.querySelectorAll("[class*=channel-anchor][class*=ts-unread-channel]").length; + + Franz.setBadge(messages, indirectMessages); + }; + + Franz.injectCSS(path.join(__dirname, 'service.css')); + Franz.loop(getMessages); +}; -- cgit v1.2.3-54-g00ecf