diff options
author | Kristóf Marussy <kristof@marussy.com> | 2021-09-19 00:41:52 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2021-09-19 00:57:47 +0200 |
commit | c5d2a889d4cb44f995d74051f83628b505383093 (patch) | |
tree | b1bab2b6d7f99ab00b0ca9860079f71472ac79ae /recipes/slack/webview.js | |
parent | Fix images opening in browser instead of in Discord (#712) (diff) | |
download | ferdium-recipes-c5d2a889d4cb44f995d74051f83628b505383093.tar.gz ferdium-recipes-c5d2a889d4cb44f995d74051f83628b505383093.tar.zst ferdium-recipes-c5d2a889d4cb44f995d74051f83628b505383093.zip |
fix: privileged API access
Privileged browser APIs should be accessed from webview.js via the Ferdi
parameter to the exported function.
If any service is broken (e.g., screen sharing), then most likely we
have to fix recipe.js or screenshare.js
Diffstat (limited to 'recipes/slack/webview.js')
-rw-r--r-- | recipes/slack/webview.js | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/recipes/slack/webview.js b/recipes/slack/webview.js index 1a12e80..3064e79 100644 --- a/recipes/slack/webview.js +++ b/recipes/slack/webview.js | |||
@@ -2,37 +2,6 @@ const _path = _interopRequireDefault(require('path')); | |||
2 | 2 | ||
3 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | 3 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
4 | 4 | ||
5 | const getTeamIcon = function getTeamIcon(count = 0) { | ||
6 | let countTeamIconCheck = count; | ||
7 | let bgUrl = null; | ||
8 | const teamMenu = document.querySelector('#team-menu-trigger, .p-ia__sidebar_header__team_name'); | ||
9 | |||
10 | if (teamMenu) { | ||
11 | teamMenu.click(); | ||
12 | const icon = document.querySelector('.c-team_icon'); | ||
13 | |||
14 | if (icon) { | ||
15 | bgUrl = window.getComputedStyle(icon, null).getPropertyValue('background-image'); | ||
16 | bgUrl = /^url\((['"]?)(.*)\1\)$/.exec(bgUrl); | ||
17 | bgUrl = bgUrl ? bgUrl[2] : ''; | ||
18 | } | ||
19 | |||
20 | setTimeout(() => { | ||
21 | document.querySelector('.ReactModal__Overlay').click(); | ||
22 | }, 10); | ||
23 | } | ||
24 | |||
25 | countTeamIconCheck += 1; | ||
26 | |||
27 | if (bgUrl) { | ||
28 | Ferdi.ipcRenderer.sendToHost('avatar', bgUrl); | ||
29 | } else if (countTeamIconCheck <= 5) { | ||
30 | setTimeout(() => { | ||
31 | getTeamIcon(countTeamIconCheck + 1); | ||
32 | }, 2000); | ||
33 | } | ||
34 | }; | ||
35 | |||
36 | const SELECTOR_CHANNELS_UNREAD = '.p-channel_sidebar__channel--unread:not(.p-channel_sidebar__channel--muted)'; | 5 | const SELECTOR_CHANNELS_UNREAD = '.p-channel_sidebar__channel--unread:not(.p-channel_sidebar__channel--muted)'; |
37 | 6 | ||
38 | module.exports = Ferdi => { | 7 | module.exports = Ferdi => { |
@@ -44,6 +13,37 @@ module.exports = Ferdi => { | |||
44 | 13 | ||
45 | Ferdi.loop(getMessages); | 14 | Ferdi.loop(getMessages); |
46 | 15 | ||
16 | const getTeamIcon = function getTeamIcon(count = 0) { | ||
17 | let countTeamIconCheck = count; | ||
18 | let bgUrl = null; | ||
19 | const teamMenu = document.querySelector('#team-menu-trigger, .p-ia__sidebar_header__team_name'); | ||
20 | |||
21 | if (teamMenu) { | ||
22 | teamMenu.click(); | ||
23 | const icon = document.querySelector('.c-team_icon'); | ||
24 | |||
25 | if (icon) { | ||
26 | bgUrl = window.getComputedStyle(icon, null).getPropertyValue('background-image'); | ||
27 | bgUrl = /^url\((['"]?)(.*)\1\)$/.exec(bgUrl); | ||
28 | bgUrl = bgUrl ? bgUrl[2] : ''; | ||
29 | } | ||
30 | |||
31 | setTimeout(() => { | ||
32 | document.querySelector('.ReactModal__Overlay').click(); | ||
33 | }, 10); | ||
34 | } | ||
35 | |||
36 | countTeamIconCheck += 1; | ||
37 | |||
38 | if (bgUrl) { | ||
39 | Ferdi.ipcRenderer.sendToHost('avatar', bgUrl); | ||
40 | } else if (countTeamIconCheck <= 5) { | ||
41 | setTimeout(() => { | ||
42 | getTeamIcon(countTeamIconCheck + 1); | ||
43 | }, 2000); | ||
44 | } | ||
45 | }; | ||
46 | |||
47 | setTimeout(() => { | 47 | setTimeout(() => { |
48 | getTeamIcon(); | 48 | getTeamIcon(); |
49 | }, 4000); | 49 | }, 4000); |