diff options
Diffstat (limited to 'recipes/amazon-work-mail')
-rw-r--r-- | recipes/amazon-work-mail/webview.js | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/recipes/amazon-work-mail/webview.js b/recipes/amazon-work-mail/webview.js index 944a15c..44f3058 100644 --- a/recipes/amazon-work-mail/webview.js +++ b/recipes/amazon-work-mail/webview.js | |||
@@ -1,6 +1,6 @@ | |||
1 | module.exports = (Ferdi) => { | 1 | const reload = EventType => |
2 | const reload = (EventType) => new Promise((resolve, reject) => { | 2 | new Promise((resolve, reject) => { |
3 | const btn = document.getElementsByClassName('giraffe-hierarchy-node-refresh')[0]; | 3 | const btn = document.querySelectorAll('.giraffe-hierarchy-node-refresh')[0]; |
4 | const EventObject = document.createEvent('Events'); | 4 | const EventObject = document.createEvent('Events'); |
5 | EventObject.initEvent(EventType, true, false); | 5 | EventObject.initEvent(EventType, true, false); |
6 | 6 | ||
@@ -11,12 +11,13 @@ module.exports = (Ferdi) => { | |||
11 | } | 11 | } |
12 | }); | 12 | }); |
13 | 13 | ||
14 | module.exports = Ferdi => { | ||
14 | const getUnread = () => { | 15 | const getUnread = () => { |
15 | const nodes = document.getElementsByClassName('giraffe-hierarchy-node-counter'); | 16 | const nodes = document.querySelectorAll('.giraffe-hierarchy-node-counter'); |
16 | let counter = 0; | 17 | let counter = 0; |
17 | 18 | ||
18 | for (let i = 0; i < nodes.length; i++) { | 19 | for (const node of nodes) { |
19 | counter += Ferdi.safeParseInt(nodes[i].innerText); | 20 | counter += Ferdi.safeParseInt(node.textContent); |
20 | } | 21 | } |
21 | 22 | ||
22 | Ferdi.setBadge(counter); | 23 | Ferdi.setBadge(counter); |
@@ -27,6 +28,6 @@ module.exports = (Ferdi) => { | |||
27 | 28 | ||
28 | window.setInterval(() => { | 29 | window.setInterval(() => { |
29 | reload('click'); | 30 | reload('click'); |
30 | }, 60000); | 31 | }, 60_000); |
31 | } | 32 | } |
32 | }; | 33 | }; |