diff options
Diffstat (limited to 'recipes/campuswire')
-rw-r--r-- | recipes/campuswire/webview.js | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/recipes/campuswire/webview.js b/recipes/campuswire/webview.js index 9837030..418ac9d 100644 --- a/recipes/campuswire/webview.js +++ b/recipes/campuswire/webview.js | |||
@@ -1,10 +1,12 @@ | |||
1 | module.exports = Ferdi => { | 1 | module.exports = Ferdi => { |
2 | const getMessages = () => { | 2 | const getMessages = () => { |
3 | let count = document.querySelectorAll('._5fx8:not(._569x),._1ht3:not(._569x)').length; | 3 | let count = document.querySelectorAll( |
4 | '._5fx8:not(._569x),._1ht3:not(._569x)', | ||
5 | ).length; | ||
4 | const messageRequestsElement = document.querySelector('._5nxf'); | 6 | const messageRequestsElement = document.querySelector('._5nxf'); |
5 | 7 | ||
6 | if (messageRequestsElement) { | 8 | if (messageRequestsElement) { |
7 | count += Ferdi.safeParseInt(messageRequestsElement.innerHTML); | 9 | count += Ferdi.safeParseInt(messageRequestsElement.textContent); |
8 | } | 10 | } |
9 | 11 | ||
10 | Ferdi.setBadge(count); | 12 | Ferdi.setBadge(count); |
@@ -12,19 +14,25 @@ module.exports = Ferdi => { | |||
12 | 14 | ||
13 | Ferdi.loop(getMessages); | 15 | Ferdi.loop(getMessages); |
14 | 16 | ||
15 | localStorage.setItem('_cs_desktopNotifsEnabled', JSON.stringify({ | 17 | localStorage.setItem( |
16 | __t: new Date().getTime(), | 18 | '_cs_desktopNotifsEnabled', |
17 | __v: true, | 19 | JSON.stringify({ |
18 | })); | 20 | __t: Date.now(), |
21 | __v: true, | ||
22 | }), | ||
23 | ); | ||
19 | 24 | ||
20 | if (typeof Ferdi.onNotify === 'function') { | 25 | if (typeof Ferdi.onNotify === 'function') { |
21 | Ferdi.onNotify(notification => { | 26 | Ferdi.onNotify(notification => { |
22 | if (typeof notification.title !== 'string') { | 27 | if (typeof notification.title !== 'string') { |
23 | notification.title = ((notification.title.props || {}).content || [])[0] || 'Campuswire'; | 28 | notification.title = |
29 | ((notification.title.props || {}).content || [])[0] || 'Campuswire'; | ||
24 | } | 30 | } |
25 | 31 | ||
26 | if (typeof notification.options.body !== 'string') { | 32 | if (typeof notification.options.body !== 'string') { |
27 | notification.options.body = (((notification.options.body || {}).props || {}).content || [])[0] || ''; | 33 | notification.options.body = |
34 | (((notification.options.body || {}).props || {}).content || [])[0] || | ||
35 | ''; | ||
28 | } | 36 | } |
29 | 37 | ||
30 | return notification; | 38 | return notification; |