blob: cc408343e4bf99d9c268000eaecfc3c9ecc5fdba (
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
26
27
28
29
30
31
|
module.exports = (Ferdi) => {
function getMessages() {
let directCount = 0;
let indirectCount = 0;
const roomInfoContainer = document.querySelectorAll('li.sc-dnqmqq');
Array.prototype.forEach.call(roomInfoContainer, (room) => {
let count = 0;
const unreadBadge = room.querySelector('span.sc-kAzzGY');
const unreadBadgeHasMention = room.querySelector('li._unreadBadge.sc-cSHVUG');
if (unreadBadge && unreadBadge.innerText) {
count = Ferdi.safeParseInt(unreadBadge.innerText);
}
if (count > 0) {
if (room.querySelector('img.sc-gqjmRU').getAttribute('src').indexOf('avatar') < 0) {
if (unreadBadgeHasMention) {
directCount++;
} else {
indirectCount++;
}
} else {
directCount++;
}
}
});
Ferdi.setBadge(directCount, indirectCount);
}
Ferdi.loop(getMessages);
};
|