diff options
Diffstat (limited to 'recipes/messenger')
-rw-r--r-- | recipes/messenger/webview.js | 37 |
1 files changed, 24 insertions, 13 deletions
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 => { | |||
8 | * Notification case for group chats, workaround by tamas646 | 8 | * Notification case for group chats, workaround by tamas646 |
9 | * see https://github.com/getferdi/ferdi/issues/1113#issuecomment-783409154 | 9 | * see https://github.com/getferdi/ferdi/issues/1113#issuecomment-783409154 |
10 | */ | 10 | */ |
11 | if (isNotification) { | 11 | if (isNotification) { |
12 | count = Ferdi.safeParseInt(/^\((\d+)\)/.exec(document.title)[1]); | 12 | count = Ferdi.safeParseInt(/^\((\d+)\)/.exec(document.title)[1]); |
13 | } else { | 13 | } else { |
14 | /* | 14 | /* |
15 | * Notification case for direct messages, workaround by manavortex | 15 | * Notification case for direct messages, workaround by manavortex |
16 | * see https://github.com/getferdi/ferdi/issues/1113#issuecomment-846611765 | 16 | * see https://github.com/getferdi/ferdi/issues/1113#issuecomment-846611765 |
17 | */ | 17 | */ |
18 | count = document.querySelectorAll('._5fx8:not(._569x),._1ht3:not(._569x)').length; | 18 | count = document.querySelectorAll( |
19 | '._5fx8:not(._569x),._1ht3:not(._569x)', | ||
20 | ).length; | ||
19 | if (count === 0) { | 21 | if (count === 0) { |
20 | count = document.querySelectorAll('.pq6dq46d.is6700om.qu0x051f.esr5mh6w.e9989ue4.r7d6kgcz.s45kfl79.emlxlaya.bkmhp75w.spb7xbtv.cyypbtt7.fwizqjfa').length; | 22 | count = document.querySelectorAll( |
23 | '.pq6dq46d.is6700om.qu0x051f.esr5mh6w.e9989ue4.r7d6kgcz.s45kfl79.emlxlaya.bkmhp75w.spb7xbtv.cyypbtt7.fwizqjfa', | ||
24 | ).length; | ||
21 | } | 25 | } |
22 | if (count === 0) { // might be obsolete, not sure - never ran into this case | 26 | if (count === 0) { |
27 | // might be obsolete, not sure - never ran into this case | ||
23 | count = document.querySelectorAll('[aria-label="Mark as read"]').length; | 28 | count = document.querySelectorAll('[aria-label="Mark as read"]').length; |
24 | } | 29 | } |
25 | } | 30 | } |
@@ -36,19 +41,25 @@ module.exports = Ferdi => { | |||
36 | 41 | ||
37 | Ferdi.loop(getMessages); | 42 | Ferdi.loop(getMessages); |
38 | 43 | ||
39 | localStorage.setItem('_cs_desktopNotifsEnabled', JSON.stringify({ | 44 | localStorage.setItem( |
40 | __t: new Date().getTime(), | 45 | '_cs_desktopNotifsEnabled', |
41 | __v: true, | 46 | JSON.stringify({ |
42 | })); | 47 | __t: new Date().getTime(), |
48 | __v: true, | ||
49 | }), | ||
50 | ); | ||
43 | 51 | ||
44 | if (typeof Ferdi.onNotify === 'function') { | 52 | if (typeof Ferdi.onNotify === 'function') { |
45 | Ferdi.onNotify(notification => { | 53 | Ferdi.onNotify(notification => { |
46 | if (typeof notification.title !== 'string') { | 54 | if (typeof notification.title !== 'string') { |
47 | notification.title = ((notification.title.props || {}).content || [])[0] || 'Messenger'; | 55 | notification.title = |
56 | ((notification.title.props || {}).content || [])[0] || 'Messenger'; | ||
48 | } | 57 | } |
49 | 58 | ||
50 | if (typeof notification.options.body !== 'string') { | 59 | if (typeof notification.options.body !== 'string') { |
51 | notification.options.body = (((notification.options.body || {}).props || {}).content || [])[0] || ''; | 60 | notification.options.body = |
61 | (((notification.options.body || {}).props || {}).content || [])[0] || | ||
62 | ''; | ||
52 | } | 63 | } |
53 | 64 | ||
54 | return notification; | 65 | return notification; |