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/skype/README.md | 5 +++ recipes/skype/icon.png | Bin 0 -> 74473 bytes recipes/skype/icon.svg | 16 +++++++ recipes/skype/index.js | 11 +++++ recipes/skype/package.json | 13 ++++++ recipes/skype/service.css | 64 +++++++++++++++++++++++++++ recipes/skype/webview.js | 107 +++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 216 insertions(+) create mode 100644 recipes/skype/README.md create mode 100644 recipes/skype/icon.png create mode 100644 recipes/skype/icon.svg create mode 100644 recipes/skype/index.js create mode 100644 recipes/skype/package.json create mode 100644 recipes/skype/service.css create mode 100644 recipes/skype/webview.js (limited to 'recipes/skype') diff --git a/recipes/skype/README.md b/recipes/skype/README.md new file mode 100644 index 0000000..8a0ae7e --- /dev/null +++ b/recipes/skype/README.md @@ -0,0 +1,5 @@ +# Skype for Franz +This is the official Franz recipe for Skype + +### How to create your own Franz recipes: +* [Read the documentation](https://github.com/meetfranz/plugins) diff --git a/recipes/skype/icon.png b/recipes/skype/icon.png new file mode 100644 index 0000000..38d243b Binary files /dev/null and b/recipes/skype/icon.png differ diff --git a/recipes/skype/icon.svg b/recipes/skype/icon.svg new file mode 100644 index 0000000..228db7a --- /dev/null +++ b/recipes/skype/icon.svg @@ -0,0 +1,16 @@ + + + + skype + Created with Sketch. + + + + + + + + + + + \ No newline at end of file diff --git a/recipes/skype/index.js b/recipes/skype/index.js new file mode 100644 index 0000000..f9b8099 --- /dev/null +++ b/recipes/skype/index.js @@ -0,0 +1,11 @@ +"use strict"; + +module.exports = (Franz) => + class Messenger extends Franz { + overrideUserAgent() { + return window.navigator.userAgent.replace( + /(Ferdi|Electron)\/\S+ \([^)]+\)/g, + "" + ); + } + }; diff --git a/recipes/skype/package.json b/recipes/skype/package.json new file mode 100644 index 0000000..9b4e168 --- /dev/null +++ b/recipes/skype/package.json @@ -0,0 +1,13 @@ +{ + "id": "skype", + "name": "Skype", + "version": "1.4.1", + "description": "Skype", + "main": "index.js", + "author": "Stefan Malzner ", + "license": "MIT", + "config": { + "serviceURL": "https://web.skype.com/", + "hasNotificationSound": true + } +} diff --git a/recipes/skype/service.css b/recipes/skype/service.css new file mode 100644 index 0000000..543076f --- /dev/null +++ b/recipes/skype/service.css @@ -0,0 +1,64 @@ +#footer { + display: none; +} +.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; + color: #fff; + 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/skype/webview.js b/recipes/skype/webview.js new file mode 100644 index 0000000..93a3613 --- /dev/null +++ b/recipes/skype/webview.js @@ -0,0 +1,107 @@ +"use strict"; + +const { desktopCapturer, remote: { BrowserWindow } } = 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); + } + }) +} + +module.exports = (Franz, settings) => { + const getMessages = function getMessages() { + let count = 0; + const container = document.querySelector('[role="tablist"] > [title="Chats"] > div'); + + if (container) { + const children = container.children; + + if (children.length === 3) { + const elementContainer = children[children.length - 1]; + + if (elementContainer) { + const element = elementContainer.querySelector('[data-text-as-pseudo-element]'); + count = parseInt(element.dataset.textAsPseudoElement, 10); + } + } + } + + Franz.setBadge(count); + }; + + Franz.injectCSS(path.join(__dirname, 'service.css')); + Franz.loop(getMessages); + document.addEventListener('click', event => { + const link = event.target.closest('a[href^="http"]'); + const button = event.target.closest('button[title^="http"]'); + + if (link || button) { + const url = link ? link.getAttribute('href') : button.getAttribute('title'); + + if (url.includes('views/imgpsh_fullsize_anim')) { + event.preventDefault(); + event.stopPropagation(); + let win = new BrowserWindow({ + width: 800, + height: window.innerHeight, + minWidth: 600, + webPreferences: { + partition: `persist:service-${settings.id}` + } + }); + win.loadURL(url); + } + } + }, true); +}; -- cgit v1.2.3-54-g00ecf