diff options
Diffstat (limited to 'recipes/hangoutschat')
-rw-r--r-- | recipes/hangoutschat/index.js | 3 | ||||
-rw-r--r-- | recipes/hangoutschat/webview.js | 20 |
2 files changed, 17 insertions, 6 deletions
diff --git a/recipes/hangoutschat/index.js b/recipes/hangoutschat/index.js index 6bed9d7..bd7fbe7 100644 --- a/recipes/hangoutschat/index.js +++ b/recipes/hangoutschat/index.js | |||
@@ -1,2 +1 @@ | |||
1 | module.exports = Ferdi => class HangoutsChat extends Ferdi { | module.exports = Ferdi => class HangoutsChat extends Ferdi {}; | |
2 | }; | ||
diff --git a/recipes/hangoutschat/webview.js b/recipes/hangoutschat/webview.js index c8aa952..e2e5912 100644 --- a/recipes/hangoutschat/webview.js +++ b/recipes/hangoutschat/webview.js | |||
@@ -1,4 +1,4 @@ | |||
1 | module.exports = (Ferdi) => { | 1 | module.exports = Ferdi => { |
2 | // class corresponding to the red badge that is visible for direct messages | 2 | // class corresponding to the red badge that is visible for direct messages |
3 | const directMessageSelector = 'div.V6.CL.su.ahD.X9.Y2 span.akt span.XU'; | 3 | const directMessageSelector = 'div.V6.CL.su.ahD.X9.Y2 span.akt span.XU'; |
4 | 4 | ||
@@ -7,10 +7,21 @@ module.exports = (Ferdi) => { | |||
7 | 7 | ||
8 | const getMessages = () => { | 8 | const getMessages = () => { |
9 | // get unread direct messages | 9 | // get unread direct messages |
10 | const directCount = Number(document.querySelector(directMessageSelector).innerText); | 10 | let directCount; |
11 | let indirectCount; | ||
12 | |||
13 | const directCountSelector = document.querySelector(directMessageSelector); | ||
14 | if (directCountSelector) { | ||
15 | directCount = Number(directCountSelector.textContent); | ||
16 | } | ||
11 | 17 | ||
12 | // get unread indirect messages | 18 | // get unread indirect messages |
13 | const indirectCount = Number(document.querySelector(indirectMessageSelector).innerText); | 19 | const indirectCountSelector = document.querySelector( |
20 | indirectMessageSelector, | ||
21 | ); | ||
22 | if (indirectCountSelector) { | ||
23 | indirectCount = Number(indirectCountSelector.textContent); | ||
24 | } | ||
14 | 25 | ||
15 | // set Ferdi badge | 26 | // set Ferdi badge |
16 | Ferdi.setBadge(directCount, indirectCount); | 27 | Ferdi.setBadge(directCount, indirectCount); |
@@ -18,7 +29,8 @@ module.exports = (Ferdi) => { | |||
18 | 29 | ||
19 | Ferdi.loop(getMessages); | 30 | Ferdi.loop(getMessages); |
20 | 31 | ||
21 | document.addEventListener('click', (e) => { | 32 | document.addEventListener('click', e => { |
33 | // @ts-ignore | ||
22 | const { tagName, target, href } = e.target; | 34 | const { tagName, target, href } = e.target; |
23 | 35 | ||
24 | if (tagName === 'A' && target === '_blank') { | 36 | if (tagName === 'A' && target === '_blank') { |