From 65b68b9b5976a07669aec1fdb69bd17b0ae95e72 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Sun, 20 Jun 2021 09:41:19 +0530 Subject: Renamed 'glowingbear' --> 'glowing-bear' and 'ex-google-voice' --> 'google-voide'. --- recipes/google-voice/webview.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 recipes/google-voice/webview.js (limited to 'recipes/google-voice/webview.js') 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 @@ +"use strict"; + +module.exports = Franz => { + function parseQuery(query) { + const el = document.querySelector(query); + return el && parseInt(el.innerHTML) || 0; + } + + function getMessages() { + const el = document.querySelector('.msgCount'); + let count; + + if (el) { + count = parseInt(el.innerHTML.replace(/[\(\) ]/gi, '')) || 0; + } else { + const count_messages = parseQuery('gv-nav-tab[tooltip="Messages"] div[aria-label="Unread count"]'); + const count_calls = parseQuery('gv-nav-tab[tooltip="Calls"] div[aria-label="Unread count"]'); + const count_voicemails = parseQuery('gv-nav-tab[tooltip="Voicemail"] div[aria-label="Unread count"]'); + count = count_messages + count_calls + count_voicemails; + } + + Franz.setBadge(count); + } + + Franz.loop(getMessages); +}; \ No newline at end of file -- cgit v1.2.3-70-g09d2