aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/google-voice/webview.js
diff options
context:
space:
mode:
authorLibravatar Vijay A <avijayr@protonmail.com>2021-06-20 09:41:19 +0530
committerLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-06-20 04:13:34 +0000
commit65b68b9b5976a07669aec1fdb69bd17b0ae95e72 (patch)
tree7d3bd222210eb8e16f696a2ca559029eaad64bb3 /recipes/google-voice/webview.js
parentAdded new service: keybase.io (fixes #427) (diff)
downloadferdium-recipes-65b68b9b5976a07669aec1fdb69bd17b0ae95e72.tar.gz
ferdium-recipes-65b68b9b5976a07669aec1fdb69bd17b0ae95e72.tar.zst
ferdium-recipes-65b68b9b5976a07669aec1fdb69bd17b0ae95e72.zip
Renamed 'glowingbear' --> 'glowing-bear' and 'ex-google-voice' --> 'google-voide'.
Diffstat (limited to 'recipes/google-voice/webview.js')
-rw-r--r--recipes/google-voice/webview.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/recipes/google-voice/webview.js b/recipes/google-voice/webview.js
new file mode 100644
index 0000000..1a91455
--- /dev/null
+++ b/recipes/google-voice/webview.js
@@ -0,0 +1,26 @@
1"use strict";
2
3module.exports = Franz => {
4 function parseQuery(query) {
5 const el = document.querySelector(query);
6 return el && parseInt(el.innerHTML) || 0;
7 }
8
9 function getMessages() {
10 const el = document.querySelector('.msgCount');
11 let count;
12
13 if (el) {
14 count = parseInt(el.innerHTML.replace(/[\(\) ]/gi, '')) || 0;
15 } else {
16 const count_messages = parseQuery('gv-nav-tab[tooltip="Messages"] div[aria-label="Unread count"]');
17 const count_calls = parseQuery('gv-nav-tab[tooltip="Calls"] div[aria-label="Unread count"]');
18 const count_voicemails = parseQuery('gv-nav-tab[tooltip="Voicemail"] div[aria-label="Unread count"]');
19 count = count_messages + count_calls + count_voicemails;
20 }
21
22 Franz.setBadge(count);
23 }
24
25 Franz.loop(getMessages);
26}; \ No newline at end of file