aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/amazon-work-mail/webview.js
diff options
context:
space:
mode:
authorLibravatar Vijay Aravamudhan <vraravam@users.noreply.github.com>2021-09-12 22:01:51 +0530
committerLibravatar Vijay A <avijayr@protonmail.com>2021-09-12 22:06:03 +0530
commit9db43e100a672b6d6932ac68c0fbe503c129138b (patch)
tree4f6a31d25a7345c5d92dbd8b80d30ce7d129944f /recipes/amazon-work-mail/webview.js
parentNew recipe: 'stackoverflow' (#707) (diff)
downloadferdium-recipes-9db43e100a672b6d6932ac68c0fbe503c129138b.tar.gz
ferdium-recipes-9db43e100a672b6d6932ac68c0fbe503c129138b.tar.zst
ferdium-recipes-9db43e100a672b6d6932ac68c0fbe503c129138b.zip
Added a check to verify that the folder name of the recipe matches the recipe id (#708)
Use the recipe-id as master to rename internal folder names
Diffstat (limited to 'recipes/amazon-work-mail/webview.js')
-rw-r--r--recipes/amazon-work-mail/webview.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/recipes/amazon-work-mail/webview.js b/recipes/amazon-work-mail/webview.js
new file mode 100644
index 0000000..944a15c
--- /dev/null
+++ b/recipes/amazon-work-mail/webview.js
@@ -0,0 +1,32 @@
1module.exports = (Ferdi) => {
2 const reload = (EventType) => new Promise((resolve, reject) => {
3 const btn = document.getElementsByClassName('giraffe-hierarchy-node-refresh')[0];
4 const EventObject = document.createEvent('Events');
5 EventObject.initEvent(EventType, true, false);
6
7 if (btn.dispatchEvent(EventObject)) {
8 resolve();
9 } else {
10 reject();
11 }
12 });
13
14 const getUnread = () => {
15 const nodes = document.getElementsByClassName('giraffe-hierarchy-node-counter');
16 let counter = 0;
17
18 for (let i = 0; i < nodes.length; i++) {
19 counter += Ferdi.safeParseInt(nodes[i].innerText);
20 }
21
22 Ferdi.setBadge(counter);
23 };
24
25 if (!window.location.pathname.includes('auth')) {
26 Ferdi.loop(getUnread);
27
28 window.setInterval(() => {
29 reload('click');
30 }, 60000);
31 }
32};