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/webview.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 recipes/messenger/webview.js (limited to 'recipes/messenger/webview.js') 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