aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/wire/webview.js
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/wire/webview.js')
-rw-r--r--recipes/wire/webview.js19
1 files changed, 12 insertions, 7 deletions
diff --git a/recipes/wire/webview.js b/recipes/wire/webview.js
index 55720da..cdb5058 100644
--- a/recipes/wire/webview.js
+++ b/recipes/wire/webview.js
@@ -1,20 +1,25 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const 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(
8 '[data-uie-name="conversation-folder-badge"]',
9 );
8 if (conversationElems) { 10 if (conversationElems) {
9 for (const conversationElem of conversationElems) { 11 for (const conversationElem of conversationElems) {
10 direct += Ferdi.safeParseInt(conversationElem.innerText); 12 direct += Ferdi.safeParseInt(conversationElem.textContent);
11 } 13 }
12 } 14 }
13 15
14 // Count unread pending user requests 16 // Count unread pending user requests
15 const pendingElem = document.querySelector('[data-uie-name="item-pending-requests"]'); 17 const pendingElem = document.querySelector(
18 '[data-uie-name="item-pending-requests"]',
19 );
16 if (pendingElem) { 20 if (pendingElem) {
17 const matches = pendingElem.innerText.match(/^([1-9][0-9]*)/); 21 const matches =
22 pendingElem.textContent && pendingElem.textContent.match(/^([1-9]\d*)/);
18 if (matches && matches.length > 1) { 23 if (matches && matches.length > 1) {
19 indirect += Ferdi.safeParseInt(matches[1]); 24 indirect += Ferdi.safeParseInt(matches[1]);
20 } 25 }
@@ -22,13 +27,13 @@ module.exports = (Ferdi) => {
22 27
23 // Alternative would be to count all messages (unread conversation count + pending) from the header 28 // Alternative would be to count all messages (unread conversation count + pending) from the header
24 // const titleElem = document.querySelector('head title'); 29 // const titleElem = document.querySelector('head title');
25 // const matches = titleElem.innerText.match(/^\(([1-9][0-9]*)\)/); 30 // const matches = titleElem.textContent.match(/^\(([1-9][0-9]*)\)/);
26 // if (matches) { 31 // if (matches) {
27 // direct = matches[1]; 32 // direct = matches[1];
28 // } 33 // }
29 34
30 Ferdi.setBadge(direct, indirect); 35 Ferdi.setBadge(direct, indirect);
31 } 36 };
32 37
33 Ferdi.loop(getMessages); 38 Ferdi.loop(getMessages);
34}; 39};