blob: 63f002fd8ac0d61ac7bd7b3276b6aec8b4a36ac1 (
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 = function getMessages() {
// get new msg count
let count = 0;
const counters = document.querySelectorAll('[class*=FriendMessageCount]');
[].filter.call(counters, countValue => {
if (countValue) {
count += Ferdi.safeParseInt(countValue.innerHTML);
}
});
const indirectMessages = document.querySelectorAll('[class*=ChatUnreadMessageIndicator]').length;
Ferdi.setBadge(count, indirectMessages);
// force scroll to bottom of chat window
const chatBoxes = document.querySelectorAll('.chat_dialog');
if (chatBoxes) {
const chatBox = [].filter.call(chatBoxes, chat => chat.style.display !== 'none');
if (chatBox[0]) {
const chatWindow = chatBox[0].querySelector('.chat_dialog_scroll');
chatWindow.scrollTop = chatWindow.scrollHeight;
}
}
};
Ferdi.loop(getMessages);
document.addEventListener('click', event => {
const link = event.target.closest('a[href^="http"]');
if (link && link.getAttribute('target') === '_top') {
const url = link.getAttribute('href');
event.preventDefault();
event.stopPropagation();
Ferdi.ipcRenderer.sendToHost('new-window', url);
}
}, true);
};
|