diff options
author | 2019-09-28 12:10:25 +0200 | |
---|---|---|
committer | 2019-09-28 12:10:25 +0200 | |
commit | 728d339739b63e9bb59e457e4a84fe9a65b93fc9 (patch) | |
tree | a0fc6180ea26fa9ef397458e8eb6491031d6437d /uncompressed/slack/webview.js | |
parent | Add list of recipes (diff) | |
download | ferdium-recipes-728d339739b63e9bb59e457e4a84fe9a65b93fc9.tar.gz ferdium-recipes-728d339739b63e9bb59e457e4a84fe9a65b93fc9.tar.zst ferdium-recipes-728d339739b63e9bb59e457e4a84fe9a65b93fc9.zip |
Add uncompressed recipes
Diffstat (limited to 'uncompressed/slack/webview.js')
-rw-r--r-- | uncompressed/slack/webview.js | 55 |
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 | |||
3 | var _electron = require("electron"); | ||
4 | |||
5 | var _path = _interopRequireDefault(require("path")); | ||
6 | |||
7 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
8 | |||
9 | const 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 | |||
41 | const SELECTOR_CHANNELS_UNREAD = '.p-channel_sidebar__channel--unread:not(.p-channel_sidebar__channel--muted)'; | ||
42 | |||
43 | module.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 | ||