blob: 0c7f5c23d4c861e0b4ee318b30b3d21a2d80486a (
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
|
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
const _path = _interopRequireDefault(require('path'));
module.exports = Ferdium => {
const getMessages = () => {
let direct = 0;
const notificationWrapper = document.querySelector(
'.notifications .notification-wrapper',
);
if (notificationWrapper) {
const directSelector = notificationWrapper.querySelectorAll(
'.notification[object_type="chat"], .notification[object_type="room"]',
);
direct = directSelector ? Ferdium.safeParseInt(directSelector.length) : 0;
}
let indirect = 0;
for (const counter of document.querySelectorAll(
'.app-navigation-entry__counter',
)) {
const entryCounter = counter
? Ferdium.safeParseInt(counter.textContent)
: 0;
indirect += entryCounter;
}
if (document.title.startsWith('*')) {
indirect += 1;
}
Ferdium.setBadge(direct, indirect);
};
Ferdium.loop(getMessages);
Ferdium.injectCSS(_path.default.join(__dirname, 'service.css'));
};
|