diff options
Diffstat (limited to 'uncompressed/rocketchat/webview.js')
-rw-r--r-- | uncompressed/rocketchat/webview.js | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/uncompressed/rocketchat/webview.js b/uncompressed/rocketchat/webview.js deleted file mode 100644 index 5ccd0d2..0000000 --- a/uncompressed/rocketchat/webview.js +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | "use strict"; | ||
2 | |||
3 | const { | ||
4 | ipcRenderer | ||
5 | } = require('electron'); | ||
6 | |||
7 | const getTeamIcon = function getTeamIcon() { | ||
8 | console.log('getTeamIcon'); | ||
9 | const manifestElement = document.querySelector('link[rel="manifest"]'); | ||
10 | |||
11 | if (manifestElement == null) { | ||
12 | return; | ||
13 | } | ||
14 | |||
15 | const manifestUrl = manifestElement.getAttribute('href'); | ||
16 | console.log(manifestUrl); | ||
17 | |||
18 | if (manifestUrl == null) { | ||
19 | return; | ||
20 | } | ||
21 | |||
22 | const xmlhttp = new XMLHttpRequest(); | ||
23 | |||
24 | xmlhttp.onreadystatechange = function () { | ||
25 | if (this.readyState != 4 || this.status != 200) { | ||
26 | return; | ||
27 | } | ||
28 | |||
29 | const response = JSON.parse(this.responseText); | ||
30 | |||
31 | if (response.icons.length >= 1) { | ||
32 | ipcRenderer.sendToHost('avatar', `${window.location.protocol}//${window.location.host}${response.icons[0].src}`); | ||
33 | } | ||
34 | }; | ||
35 | |||
36 | xmlhttp.open('GET', manifestUrl, true); | ||
37 | xmlhttp.send(); | ||
38 | }; | ||
39 | |||
40 | module.exports = Franz => { | ||
41 | const getMessages = function getMessages() { | ||
42 | const directMessages = Math.round(document.querySelectorAll('.unread.unread-mention, .badge--unread').length / 2); | ||
43 | const indirectMessages = Math.round(document.querySelectorAll('.unread:not(.unread-mention), .sidebar-item--unread').length / 2); | ||
44 | Franz.setBadge(directMessages, indirectMessages); | ||
45 | }; | ||
46 | |||
47 | Franz.loop(getMessages); | ||
48 | setTimeout(() => { | ||
49 | getTeamIcon(); | ||
50 | }, 4000); | ||
51 | }; \ No newline at end of file | ||