aboutsummaryrefslogtreecommitdiffstats
path: root/uncompressed/ex-google-voice/webview.js
diff options
context:
space:
mode:
authorLibravatar vantezzen <hello@vantezzen.io>2019-09-28 12:10:25 +0200
committerLibravatar vantezzen <hello@vantezzen.io>2019-09-28 12:10:25 +0200
commit728d339739b63e9bb59e457e4a84fe9a65b93fc9 (patch)
treea0fc6180ea26fa9ef397458e8eb6491031d6437d /uncompressed/ex-google-voice/webview.js
parentAdd list of recipes (diff)
downloadferdium-recipes-728d339739b63e9bb59e457e4a84fe9a65b93fc9.tar.gz
ferdium-recipes-728d339739b63e9bb59e457e4a84fe9a65b93fc9.tar.zst
ferdium-recipes-728d339739b63e9bb59e457e4a84fe9a65b93fc9.zip
Add uncompressed recipes
Diffstat (limited to 'uncompressed/ex-google-voice/webview.js')
-rw-r--r--uncompressed/ex-google-voice/webview.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/uncompressed/ex-google-voice/webview.js b/uncompressed/ex-google-voice/webview.js
new file mode 100644
index 0000000..1a91455
--- /dev/null
+++ b/uncompressed/ex-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