diff options
Diffstat (limited to 'uncompressed/hangoutschat/webview.js')
-rw-r--r-- | uncompressed/hangoutschat/webview.js | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/uncompressed/hangoutschat/webview.js b/uncompressed/hangoutschat/webview.js index ea8a1b2..9597f58 100644 --- a/uncompressed/hangoutschat/webview.js +++ b/uncompressed/hangoutschat/webview.js | |||
@@ -1,29 +1,36 @@ | |||
1 | module.exports = (Franz) => { | 1 | module.exports = (Franz) => { |
2 | 2 | ||
3 | // class corresponding to the mute icon | ||
3 | const muteSelector = '.DQy0Rb'; | 4 | const muteSelector = '.DQy0Rb'; |
4 | const directMessageSelector = '.eM5l9e.FVKzAb'; | 5 | |
5 | const indirectMessageSelector = '.PL5Wwe.H7du2 .t5F5nf'; | 6 | // class corresponding to the red badge that is visible for direct messages |
7 | const directMessageSelector = '.SaMfhe.m9MHid'; | ||
8 | |||
9 | // class corresponding to the bold text that is visible for all messages | ||
10 | const allMessageSelector = '.IL9EXe.PL5Wwe.dHI9xe.H7du2'; | ||
6 | 11 | ||
7 | const isMuted = node => !!node.closest('[role="listitem"]').querySelector(muteSelector); | 12 | const isMuted = node => !!node.closest('[role="listitem"]').querySelector(muteSelector); |
8 | 13 | ||
9 | const getMessages = function getMessages() { | 14 | const getMessages = function getMessages() { |
10 | 15 | let allMessageCount = 0; | |
11 | // get unread messages | ||
12 | let directCount = 0; | 16 | let directCount = 0; |
17 | |||
18 | // get unread direct messages | ||
13 | document.querySelectorAll(directMessageSelector).forEach((node) => { | 19 | document.querySelectorAll(directMessageSelector).forEach((node) => { |
14 | // Hangouts Chat overrides the muted indicator when there is a direct mention | 20 | // Hangouts Chat overrides the muted indicator when there is a direct mention |
15 | if (!isMuted(node)) { | 21 | // Check for the width of the badge element |
22 | if (!isMuted(node) && node.clientWidth != 0 ) { | ||
16 | directCount += 1; | 23 | directCount += 1; |
17 | } | 24 | } |
18 | }); | 25 | }); |
19 | 26 | ||
20 | let indirectCount = 0; | 27 | let indirectCount = 0; |
21 | document.querySelectorAll(indirectMessageSelector).forEach((node) => { | 28 | document.querySelectorAll(allMessageSelector).forEach((node) => { |
22 | if (!isMuted(node)) { | 29 | if (!isMuted(node)) { |
23 | indirectCount += 1; | 30 | allMessageCount += 1; |
24 | } | 31 | } |
25 | }); | 32 | }); |
26 | indirectCount -= directCount; | 33 | indirectCount = allMessageCount - directCount; |
27 | 34 | ||
28 | // set Franz badge | 35 | // set Franz badge |
29 | Franz.setBadge(directCount, indirectCount); | 36 | Franz.setBadge(directCount, indirectCount); |