blob: 0ac258cc0aefadbc55ad21f8daf98a898a63ff95 (
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
|
module.exports = Ferdi => {
const getMessages = () => {
let directUnreadCount = 0;
let indirectUnreadCount = 0;
if (location.pathname.match(/\/owa/)) {
// classic app
directUnreadCount = Ferdi.safeParseInt(jQuery("span[title*='Inbox'] + div > span").first().text());
} else {
// new app
const foldersElement = document.querySelector('div[role=tree]:nth-child(3)');
if (foldersElement) {
const allScreenReaders = foldersElement.querySelectorAll('span.screenReaderOnly');
for (const child of allScreenReaders) {
if (child.previousSibling) {
directUnreadCount += Ferdi.safeParseInt(child.previousSibling.innerText);
}
}
}
const groupsElement = document.querySelector('div[role=tree]:nth-child(4)');
if (groupsElement) {
const allScreenReaders = groupsElement.querySelectorAll('span.screenReaderOnly');
for (const child of allScreenReaders) {
if (child.previousSibling) {
indirectUnreadCount += Ferdi.safeParseInt(child.previousSibling.innerText);
}
}
}
}
Ferdi.setBadge(directUnreadCount, indirectUnreadCount);
}
Ferdi.loop(getMessages);
};
|