blob: f1b5f0d0daa8202da3bf26062959020ca4093dc2 (
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
39
40
41
42
43
44
|
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
const _path = _interopRequireDefault(require('path'));
module.exports = Ferdium => {
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 = Ferdium.safeParseInt(unreadBadge.textContent);
}
if (count > 0) {
if (
room
.querySelector('img.sc-gqjmRU')
.getAttribute('src')
.includes('avatar')
) {
directCount += 1;
} else if (unreadBadgeHasMention) {
directCount += 1;
} else {
indirectCount += 1;
}
}
});
Ferdium.setBadge(directCount, indirectCount);
};
Ferdium.loop(getMessages);
Ferdium.injectCSS(_path.default.join(__dirname, 'service.css'));
};
|