aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/wire/webview.js
diff options
context:
space:
mode:
authorLibravatar Vijay A <avijayr@protonmail.com>2021-07-31 15:28:23 +0530
committerLibravatar Vijay A <avijayr@protonmail.com>2021-07-31 15:28:23 +0530
commit97697e3d069972844b2912a93022f4a4904a40d6 (patch)
tree53faff30fbac9d72042f593dfe1c547809f4f121 /recipes/wire/webview.js
parentAllow any url in the custom-service to allow for sites like 'http://translate... (diff)
downloadferdium-recipes-97697e3d069972844b2912a93022f4a4904a40d6.tar.gz
ferdium-recipes-97697e3d069972844b2912a93022f4a4904a40d6.tar.zst
ferdium-recipes-97697e3d069972844b2912a93022f4a4904a40d6.zip
Fixed eslintrc as root for this folder; Reformatted all files.
Diffstat (limited to 'recipes/wire/webview.js')
-rw-r--r--recipes/wire/webview.js61
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 @@
1module.exports = (Ferdi) => { 1module.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};