blob: e0d638d2c28e1bc92b61e7fd4eea467e9a86476a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
module.exports = Ferdium => {
const getMessages = () => {
const elements = document.querySelectorAll('.unread');
let count = 0;
for (const element of elements) {
if (
Ferdium.safeParseInt(
element.textContent && element.textContent.replace(/[^\d.]/g, ''),
) > 0
) {
count++; // count 1 per channel with messages
}
}
Ferdium.setBadge(count);
};
Ferdium.loop(getMessages);
};
|