-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebview.js
27 lines (23 loc) · 895 Bytes
/
webview.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module.exports = (Franz) => {
const getMessages = function getMessages() {
// Get count of unread messages; must manually navigate to the "E-Mail" tab.
let count = 0;
// getElementsByClassName returns an empty array; don't know why: that class
// name is clearly present several times in the DOM. Long line split for debugging.
let els = document.querySelectorAll('[data-unread-count]');
count = els.length;
let el = els[1];
let val = el.getAttribute('data-unread-count');
if (val != null) {
count = parseInt(val.replace(/[^0-9.]/g, ''), 10);
}
// Just in case we don't end up with a number, set it back to zero (parseInt can return NaN)
if (isNaN(count)) {
count = 0;
}
// set Franz badge
Franz.setBadge(count);
};
// check for new messages every second and update Franz badge
Franz.loop(getMessages);
};