From 2484c63d77e05fff384cc08b6ea46a29a22a62ec Mon Sep 17 00:00:00 2001 From: Markus Hatvan Date: Tue, 5 Oct 2021 16:46:55 +0200 Subject: chore: repo maintenance (#732) --- recipes/messenger/webview.js | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'recipes/messenger/webview.js') diff --git a/recipes/messenger/webview.js b/recipes/messenger/webview.js index 954f843..5b2f2ad 100644 --- a/recipes/messenger/webview.js +++ b/recipes/messenger/webview.js @@ -8,18 +8,23 @@ module.exports = Ferdi => { * Notification case for group chats, workaround by tamas646 * see https://github.com/getferdi/ferdi/issues/1113#issuecomment-783409154 */ - if (isNotification) { + if (isNotification) { count = Ferdi.safeParseInt(/^\((\d+)\)/.exec(document.title)[1]); } else { /* - * Notification case for direct messages, workaround by manavortex - * see https://github.com/getferdi/ferdi/issues/1113#issuecomment-846611765 - */ - count = document.querySelectorAll('._5fx8:not(._569x),._1ht3:not(._569x)').length; + * Notification case for direct messages, workaround by manavortex + * see https://github.com/getferdi/ferdi/issues/1113#issuecomment-846611765 + */ + count = document.querySelectorAll( + '._5fx8:not(._569x),._1ht3:not(._569x)', + ).length; if (count === 0) { - count = document.querySelectorAll('.pq6dq46d.is6700om.qu0x051f.esr5mh6w.e9989ue4.r7d6kgcz.s45kfl79.emlxlaya.bkmhp75w.spb7xbtv.cyypbtt7.fwizqjfa').length; + count = document.querySelectorAll( + '.pq6dq46d.is6700om.qu0x051f.esr5mh6w.e9989ue4.r7d6kgcz.s45kfl79.emlxlaya.bkmhp75w.spb7xbtv.cyypbtt7.fwizqjfa', + ).length; } - if (count === 0) { // might be obsolete, not sure - never ran into this case + if (count === 0) { + // might be obsolete, not sure - never ran into this case count = document.querySelectorAll('[aria-label="Mark as read"]').length; } } @@ -36,19 +41,25 @@ module.exports = Ferdi => { Ferdi.loop(getMessages); - localStorage.setItem('_cs_desktopNotifsEnabled', JSON.stringify({ - __t: new Date().getTime(), - __v: true, - })); + localStorage.setItem( + '_cs_desktopNotifsEnabled', + JSON.stringify({ + __t: new Date().getTime(), + __v: true, + }), + ); if (typeof Ferdi.onNotify === 'function') { Ferdi.onNotify(notification => { if (typeof notification.title !== 'string') { - notification.title = ((notification.title.props || {}).content || [])[0] || 'Messenger'; + notification.title = + ((notification.title.props || {}).content || [])[0] || 'Messenger'; } if (typeof notification.options.body !== 'string') { - notification.options.body = (((notification.options.body || {}).props || {}).content || [])[0] || ''; + notification.options.body = + (((notification.options.body || {}).props || {}).content || [])[0] || + ''; } return notification; -- cgit v1.2.3-70-g09d2