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/messenger/README.md | 5 +++++ recipes/messenger/icon.png | Bin 0 -> 196186 bytes recipes/messenger/icon.svg | 23 +++++++++++++++++++++++ recipes/messenger/index.js | 11 +++++++++++ recipes/messenger/package.json | 13 +++++++++++++ recipes/messenger/webview.js | 34 ++++++++++++++++++++++++++++++++++ 6 files changed, 86 insertions(+) create mode 100644 recipes/messenger/README.md create mode 100644 recipes/messenger/icon.png create mode 100644 recipes/messenger/icon.svg create mode 100644 recipes/messenger/index.js create mode 100644 recipes/messenger/package.json create mode 100644 recipes/messenger/webview.js (limited to 'recipes/messenger') diff --git a/recipes/messenger/README.md b/recipes/messenger/README.md new file mode 100644 index 0000000..cbe1f4d --- /dev/null +++ b/recipes/messenger/README.md @@ -0,0 +1,5 @@ +# Messenger for Franz +This is the official Franz recipe for Messenger + +### How to create your own Franz recipes: +* [Read the documentation](https://github.com/meetfranz/plugins) diff --git a/recipes/messenger/icon.png b/recipes/messenger/icon.png new file mode 100644 index 0000000..5403253 Binary files /dev/null and b/recipes/messenger/icon.png differ diff --git a/recipes/messenger/icon.svg b/recipes/messenger/icon.svg new file mode 100644 index 0000000..c861e9a --- /dev/null +++ b/recipes/messenger/icon.svg @@ -0,0 +1,23 @@ + + + + messenger + Created with Sketch. + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/recipes/messenger/index.js b/recipes/messenger/index.js new file mode 100644 index 0000000..f9b8099 --- /dev/null +++ b/recipes/messenger/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/messenger/package.json b/recipes/messenger/package.json new file mode 100644 index 0000000..b26d37d --- /dev/null +++ b/recipes/messenger/package.json @@ -0,0 +1,13 @@ +{ + "id": "messenger", + "name": "Messenger", + "version": "1.1.0", + "description": "Facebook Messenger", + "main": "index.js", + "author": "Stefan Malzner ", + "license": "MIT", + "config": { + "serviceURL": "https://messenger.com", + "hasNotificationSound": true + } +} diff --git a/recipes/messenger/webview.js b/recipes/messenger/webview.js new file mode 100644 index 0000000..ba7ae31 --- /dev/null +++ b/recipes/messenger/webview.js @@ -0,0 +1,34 @@ +"use strict"; + +module.exports = Franz => { + const getMessages = function getMessages() { + let count = document.querySelectorAll('._5fx8:not(._569x),._1ht3:not(._569x)').length; + const messageRequestsElement = document.querySelector('._5nxf'); + + if (messageRequestsElement) { + count += parseInt(messageRequestsElement.innerHTML, 10); + } + + Franz.setBadge(count); + }; + + Franz.loop(getMessages); + localStorage.setItem('_cs_desktopNotifsEnabled', JSON.stringify({ + __t: new Date().getTime(), + __v: true + })); + + if (typeof Franz.onNotify === 'function') { + Franz.onNotify(notification => { + if (typeof notification.title !== 'string') { + notification.title = ((notification.title.props || {}).content || [])[0] || 'Messenger'; + } + + if (typeof notification.options.body !== 'string') { + notification.options.body = (((notification.options.body || {}).props || {}).content || [])[0] || ''; + } + + return notification; + }); + } +}; \ No newline at end of file -- cgit v1.2.3-70-g09d2