diff options
author | 2021-05-19 22:40:12 +0530 | |
---|---|---|
committer | 2021-05-19 22:41:15 +0530 | |
commit | cb706c0c901b39bcd12f2a5ef407e59e669c0d43 (patch) | |
tree | 2093514786822203a5c5b345f53310b7af0bc860 /recipes/aws-workmail/webview.js | |
parent | Added new recipe: snapdrop (fixes #512) (diff) | |
download | ferdium-recipes-cb706c0c901b39bcd12f2a5ef407e59e669c0d43.tar.gz ferdium-recipes-cb706c0c901b39bcd12f2a5ef407e59e669c0d43.tar.zst ferdium-recipes-cb706c0c901b39bcd12f2a5ef407e59e669c0d43.zip |
Added new recipe: amazon-workmail (fixes #491)
Diffstat (limited to 'recipes/aws-workmail/webview.js')
-rw-r--r-- | recipes/aws-workmail/webview.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/recipes/aws-workmail/webview.js b/recipes/aws-workmail/webview.js new file mode 100644 index 0000000..a979903 --- /dev/null +++ b/recipes/aws-workmail/webview.js | |||
@@ -0,0 +1,35 @@ | |||
1 | module.exports = (Franz, options) => { | ||
2 | const reload = (EventType) => { | ||
3 | return new Promise((resolve, reject) => { | ||
4 | const btn = document.getElementsByClassName('giraffe-hierarchy-node-refresh')[0]; | ||
5 | const EventObject = document.createEvent('Events'); | ||
6 | EventObject.initEvent(EventType, true, false); | ||
7 | |||
8 | if (btn.dispatchEvent(EventObject)) { | ||
9 | resolve(); | ||
10 | } else { | ||
11 | reject(); | ||
12 | } | ||
13 | }); | ||
14 | }; | ||
15 | |||
16 | const getUnread = () => { | ||
17 | const nodes = document.getElementsByClassName('giraffe-hierarchy-node-counter'); | ||
18 | let counter = 0; | ||
19 | |||
20 | for (var i = 0; i < nodes.length; i++) { | ||
21 | let node = parseInt(nodes[i].innerText); | ||
22 | counter += (node > 0) ? node : 0; | ||
23 | } | ||
24 | |||
25 | Franz.setBadge(counter); | ||
26 | }; | ||
27 | |||
28 | if (!window.location.pathname.includes('auth')) { | ||
29 | Franz.loop(getUnread); | ||
30 | |||
31 | window.setInterval(function() { | ||
32 | reload('click'); | ||
33 | }, 60000); | ||
34 | } | ||
35 | }; | ||