blob: ed09ef7d01b5a8e878935a406bbeca91aff70701 (
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
32
33
34
35
36
37
38
|
module.exports = Ferdi => {
const 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.textContent) {
count = Ferdi.safeParseInt(unreadBadge.textContent);
}
if (count > 0) {
if (
!room
.querySelector('img.sc-gqjmRU')
.getAttribute('src')
.includes('avatar')
) {
if (unreadBadgeHasMention) {
directCount++;
} else {
indirectCount++;
}
} else {
directCount++;
}
}
});
Ferdi.setBadge(directCount, indirectCount);
};
Ferdi.loop(getMessages);
};
|