aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/gmail/webview.js
diff options
context:
space:
mode:
authorLibravatar Bennett <hello@vantezzen.io>2020-09-22 20:56:48 +0200
committerLibravatar GitHub <noreply@github.com>2020-09-22 19:56:48 +0100
commit6f5e4a00588aefdda7a5a1cfe70935870e7e234a (patch)
tree9e29aa7aa0620a1a4a968ff8739b4b8ba96791a9 /recipes/gmail/webview.js
parentUpdated logos for Outlook/OWA (diff)
downloadferdium-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/gmail/webview.js')
-rw-r--r--recipes/gmail/webview.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/recipes/gmail/webview.js b/recipes/gmail/webview.js
new file mode 100644
index 0000000..95d28e7
--- /dev/null
+++ b/recipes/gmail/webview.js
@@ -0,0 +1,31 @@
1const path = require("path");
2
3module.exports = (Franz) => {
4 // if the user is on gmail's landing page, go to the login page.
5 if (location.hostname == 'www.google.com' && location.href.includes("gmail/about/")) {
6 location.href = 'https://accounts.google.com/AccountChooser?service=mail&continue=https://mail.google.com/mail/';
7 }
8
9 const getMessages = function getMessages() {
10 let count = 0;
11
12 if (document.getElementsByClassName('J-Ke n0').length > 0) {
13 if (document.getElementsByClassName('J-Ke n0')[0].getAttribute('aria-label') != null) {
14 count = parseInt(document.getElementsByClassName('J-Ke n0')[0].getAttribute('aria-label').replace(/[^0-9.]/g, ''), 10);
15 }
16 }
17
18 // Just incase we don't end up with a number, set it back to zero (parseInt can return NaN)
19 count = parseInt(count, 10);
20 if (isNaN(count)) {
21 count = 0;
22 }
23
24 // set Franz badge
25 Franz.setBadge(count);
26 };
27
28 Franz.injectCSS(path.join(__dirname, 'service.css'));
29 // check for new messages every second and update Franz badge
30 Franz.loop(getMessages);
31};