aboutsummaryrefslogtreecommitdiffstats
path: root/uncompressed/slack/webview.js
diff options
context:
space:
mode:
Diffstat (limited to 'uncompressed/slack/webview.js')
-rw-r--r--uncompressed/slack/webview.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/uncompressed/slack/webview.js b/uncompressed/slack/webview.js
new file mode 100644
index 0000000..98c6136
--- /dev/null
+++ b/uncompressed/slack/webview.js
@@ -0,0 +1,55 @@
1"use strict";
2
3var _electron = require("electron");
4
5var _path = _interopRequireDefault(require("path"));
6
7function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
9const getTeamIcon = function getTeamIcon(count = 0) {
10 let countTeamIconCheck = count;
11 let bgUrl = null;
12 const teamMenu = document.querySelector('#team_menu');
13
14 if (teamMenu) {
15 teamMenu.click();
16 const icon = document.querySelector('.team_icon');
17
18 if (icon) {
19 bgUrl = window.getComputedStyle(icon, null).getPropertyValue('background-image');
20 bgUrl = /^url\((['"]?)(.*)\1\)$/.exec(bgUrl);
21 bgUrl = bgUrl ? bgUrl[2] : '';
22 }
23
24 setTimeout(() => {
25 document.querySelector('.team_menu').remove();
26 document.querySelector('#msg_input .ql-editor').focus();
27 }, 10);
28 }
29
30 countTeamIconCheck += 1;
31
32 if (bgUrl) {
33 _electron.ipcRenderer.sendToHost('avatar', bgUrl);
34 } else if (countTeamIconCheck <= 5) {
35 setTimeout(() => {
36 getTeamIcon(countTeamIconCheck + 1);
37 }, 2000);
38 }
39};
40
41const SELECTOR_CHANNELS_UNREAD = '.p-channel_sidebar__channel--unread:not(.p-channel_sidebar__channel--muted)';
42
43module.exports = Franz => {
44 const getMessages = () => {
45 const directMessages = document.querySelectorAll(`${SELECTOR_CHANNELS_UNREAD} .p-channel_sidebar__badge`).length;
46 const allMessages = document.querySelectorAll(SELECTOR_CHANNELS_UNREAD).length - directMessages;
47 Franz.setBadge(directMessages, allMessages);
48 };
49
50 Franz.loop(getMessages);
51 setTimeout(() => {
52 getTeamIcon();
53 }, 4000);
54 Franz.injectCSS(_path.default.join(__dirname, 'service.css'));
55}; \ No newline at end of file