diff options
author | 2020-09-22 20:56:48 +0200 | |
---|---|---|
committer | 2020-09-22 19:56:48 +0100 | |
commit | 6f5e4a00588aefdda7a5a1cfe70935870e7e234a (patch) | |
tree | 9e29aa7aa0620a1a4a968ff8739b4b8ba96791a9 /recipes/ex-google-voice/webview.js | |
parent | Updated logos for Outlook/OWA (diff) | |
download | ferdium-recipes-6f5e4a00588aefdda7a5a1cfe70935870e7e234a.tar.gz ferdium-recipes-6f5e4a00588aefdda7a5a1cfe70935870e7e234a.tar.zst ferdium-recipes-6f5e4a00588aefdda7a5a1cfe70935870e7e234a.zip |
Unpack recipes and update recipes icons (#292)
Co-authored-by: Amine Mouafik <amine@mouafik.fr>
Diffstat (limited to 'recipes/ex-google-voice/webview.js')
-rw-r--r-- | recipes/ex-google-voice/webview.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/recipes/ex-google-voice/webview.js b/recipes/ex-google-voice/webview.js new file mode 100644 index 0000000..1a91455 --- /dev/null +++ b/recipes/ex-google-voice/webview.js | |||
@@ -0,0 +1,26 @@ | |||
1 | "use strict"; | ||
2 | |||
3 | module.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 | ||