blob: 6dc736a2972ba44b8c87b025680215caad4ab07b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
module.exports = Ferdium => {
// Regular expression for (*) or (1), will extract the asterisk or the number
const titleRegEx = /^\(([\d*])\)/;
const getMessages = function unreadCount() {
let directCount = 0;
let indirectCount = 0;
const matchArr = document.title.match(titleRegEx);
if (matchArr) {
if (matchArr[1] === '*') {
indirectCount = 1;
} else {
directCount = Number(matchArr[1]);
}
}
Ferdium.setBadge(directCount, indirectCount);
};
Ferdium.loop(getMessages);
};
|