diff options
Diffstat (limited to 'recipes/wire')
-rw-r--r-- | recipes/wire/webview.js | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/recipes/wire/webview.js b/recipes/wire/webview.js index 57baadc..efd37f3 100644 --- a/recipes/wire/webview.js +++ b/recipes/wire/webview.js | |||
@@ -1,38 +1,37 @@ | |||
1 | module.exports = (Ferdi) => { | 1 | module.exports = (Ferdi) => { |
2 | function getMessages() { | 2 | function getMessages() { |
3 | let direct = 0; | 3 | let direct = 0; |
4 | let indirect = 0; | 4 | let indirect = 0; |
5 | 5 | ||
6 | // Count how many people/groups have texted you | 6 | // Count how many people/groups have texted you |
7 | const conversationElems = document.querySelectorAll('[data-uie-name="conversation-folder-badge"]'); | 7 | const conversationElems = document.querySelectorAll('[data-uie-name="conversation-folder-badge"]'); |
8 | if (conversationElems) { | 8 | if (conversationElems) { |
9 | for (const conversationElem of conversationElems) { | 9 | for (const conversationElem of conversationElems) { |
10 | const count = parseInt(conversationElem.innerText); | 10 | const count = parseInt(conversationElem.innerText); |
11 | if (count) { | 11 | if (count) { |
12 | direct += count; | 12 | direct += count; |
13 | } | 13 | } |
14 | } | 14 | } |
15 | } | 15 | } |
16 | 16 | ||
17 | // Count unread pending user requests | 17 | // Count unread pending user requests |
18 | const pendingElem = document.querySelector('[data-uie-name="item-pending-requests"]'); | 18 | const pendingElem = document.querySelector('[data-uie-name="item-pending-requests"]'); |
19 | if (pendingElem) { | 19 | if (pendingElem) { |
20 | const matches = pendingElem.innerText.match(/^([1-9][0-9]*)/); | 20 | const matches = pendingElem.innerText.match(/^([1-9][0-9]*)/); |
21 | if (matches && matches.length > 0) { | 21 | if (matches && matches.length > 0) { |
22 | indirect += parseInt(matches[1]); | 22 | indirect += parseInt(matches[1]); |
23 | } | 23 | } |
24 | } | 24 | } |
25 | 25 | ||
26 | // Alternative would be to count all messages (unread conversation count + pending) from the header | 26 | // Alternative would be to count all messages (unread conversation count + pending) from the header |
27 | // const titleElem = document.querySelector('head title'); | 27 | // const titleElem = document.querySelector('head title'); |
28 | // const matches = titleElem.innerText.match(/^\(([1-9][0-9]*)\)/); | 28 | // const matches = titleElem.innerText.match(/^\(([1-9][0-9]*)\)/); |
29 | // if (matches) { | 29 | // if (matches) { |
30 | // direct = matches[1]; | 30 | // direct = matches[1]; |
31 | // } | 31 | // } |
32 | 32 | ||
33 | Ferdi.setBadge(direct, indirect); | 33 | Ferdi.setBadge(direct, indirect); |
34 | } | 34 | } |
35 | |||
36 | Ferdi.loop(getMessages); | ||
37 | 35 | ||
36 | Ferdi.loop(getMessages); | ||
38 | }; | 37 | }; |