From 728d339739b63e9bb59e457e4a84fe9a65b93fc9 Mon Sep 17 00:00:00 2001 From: vantezzen Date: Sat, 28 Sep 2019 12:10:25 +0200 Subject: Add uncompressed recipes --- uncompressed/messenger/webview.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 uncompressed/messenger/webview.js (limited to 'uncompressed/messenger/webview.js') diff --git a/uncompressed/messenger/webview.js b/uncompressed/messenger/webview.js new file mode 100644 index 0000000..ba7ae31 --- /dev/null +++ b/uncompressed/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-54-g00ecf