blob: 58d18bb73ed16af2f619f8cfbf6bd5e836fd6400 (
plain) (
blame)
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
|
'use strict';
module.exports = Franz => {
function getMessages() {
const badges = document.getElementsByClassName('mx_RoomSublist2_badgeContainer');
// Number of messages from People
let direct_count = 0;
if (badges.length > 0 && badges[0].children.length > 0) {
direct_count = parseInt(badges[0].textContent)
}
// Number of messages from Rooms
let indirect_count = 0;
if (badges.length > 1 && badges[1].children.length > 0) {
indirect_count = parseInt(badges[1].textContent)
}
// set Franz badge
Franz.setBadge(direct_count, indirect_count);
}
// check for new messages every second and update Franz badge
Franz.loop(getMessages);
};
|