blob: 5ccd0d22687e5a388b8cd10f736ce0a48ec0e0f8 (
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
45
46
47
48
49
50
51
|
"use strict";
const {
ipcRenderer
} = require('electron');
const getTeamIcon = function getTeamIcon() {
console.log('getTeamIcon');
const manifestElement = document.querySelector('link[rel="manifest"]');
if (manifestElement == null) {
return;
}
const manifestUrl = manifestElement.getAttribute('href');
console.log(manifestUrl);
if (manifestUrl == null) {
return;
}
const xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (this.readyState != 4 || this.status != 200) {
return;
}
const response = JSON.parse(this.responseText);
if (response.icons.length >= 1) {
ipcRenderer.sendToHost('avatar', `${window.location.protocol}//${window.location.host}${response.icons[0].src}`);
}
};
xmlhttp.open('GET', manifestUrl, true);
xmlhttp.send();
};
module.exports = Franz => {
const getMessages = function getMessages() {
const directMessages = Math.round(document.querySelectorAll('.unread.unread-mention, .badge--unread').length / 2);
const indirectMessages = Math.round(document.querySelectorAll('.unread:not(.unread-mention), .sidebar-item--unread').length / 2);
Franz.setBadge(directMessages, indirectMessages);
};
Franz.loop(getMessages);
setTimeout(() => {
getTeamIcon();
}, 4000);
};
|