diff options
author | Kristóf Marussy <kristof@marussy.com> | 2021-09-19 01:19:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-19 01:19:11 +0200 |
commit | 6ec6fef9017ee9d8fc436e48448d47b1fda8a820 (patch) | |
tree | 1839f85efb4e45b441e509d2fc12a28a05877e47 /recipes/rocketchat | |
parent | Fix images opening in browser instead of in Discord (#712) (diff) | |
parent | also fix privileged API access for googlemeet (diff) | |
download | ferdium-recipes-6ec6fef9017ee9d8fc436e48448d47b1fda8a820.tar.gz ferdium-recipes-6ec6fef9017ee9d8fc436e48448d47b1fda8a820.tar.zst ferdium-recipes-6ec6fef9017ee9d8fc436e48448d47b1fda8a820.zip |
Merge pull request #713 from kris7t/fix-api-access
fix: privileged API access
Diffstat (limited to 'recipes/rocketchat')
-rw-r--r-- | recipes/rocketchat/package.json | 2 | ||||
-rw-r--r-- | recipes/rocketchat/webview.js | 67 |
2 files changed, 35 insertions, 34 deletions
diff --git a/recipes/rocketchat/package.json b/recipes/rocketchat/package.json index 3b807bf..f2c6374 100644 --- a/recipes/rocketchat/package.json +++ b/recipes/rocketchat/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "rocketchat", | 2 | "id": "rocketchat", |
3 | "name": "Rocket.Chat", | 3 | "name": "Rocket.Chat", |
4 | "version": "1.2.0", | 4 | "version": "1.2.1", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://{teamId}.rocket.chat", | 7 | "serviceURL": "https://{teamId}.rocket.chat", |
diff --git a/recipes/rocketchat/webview.js b/recipes/rocketchat/webview.js index 4240935..159adea 100644 --- a/recipes/rocketchat/webview.js +++ b/recipes/rocketchat/webview.js | |||
@@ -1,36 +1,3 @@ | |||
1 | const getTeamIcon = function getTeamIcon() { | ||
2 | const manifestElement = document.querySelector('link[rel="manifest"]'); | ||
3 | |||
4 | if (manifestElement == null) { | ||
5 | return; | ||
6 | } | ||
7 | |||
8 | const manifestUrl = manifestElement.getAttribute('href'); | ||
9 | |||
10 | if (manifestUrl == null) { | ||
11 | return; | ||
12 | } | ||
13 | |||
14 | const xmlhttp = new XMLHttpRequest(); | ||
15 | |||
16 | xmlhttp.onreadystatechange = function () { | ||
17 | if (this.readyState != 4 || this.status != 200) { | ||
18 | return; | ||
19 | } | ||
20 | |||
21 | const response = JSON.parse(this.responseText); | ||
22 | |||
23 | if (response.icons.length >= 1) { | ||
24 | Ferdi.ipcRenderer.sendToHost( | ||
25 | 'avatar', | ||
26 | `${window.location.protocol}//${window.location.host}${response.icons[0].src}`, | ||
27 | ); | ||
28 | } | ||
29 | }; | ||
30 | |||
31 | xmlhttp.open('GET', manifestUrl, true); | ||
32 | xmlhttp.send(); | ||
33 | }; | ||
34 | 1 | ||
35 | module.exports = Ferdi => { | 2 | module.exports = Ferdi => { |
36 | const getMessages = function getMessages() { | 3 | const getMessages = function getMessages() { |
@@ -51,6 +18,40 @@ module.exports = Ferdi => { | |||
51 | 18 | ||
52 | Ferdi.loop(getMessages); | 19 | Ferdi.loop(getMessages); |
53 | 20 | ||
21 | const getTeamIcon = function getTeamIcon() { | ||
22 | const manifestElement = document.querySelector('link[rel="manifest"]'); | ||
23 | |||
24 | if (manifestElement == null) { | ||
25 | return; | ||
26 | } | ||
27 | |||
28 | const manifestUrl = manifestElement.getAttribute('href'); | ||
29 | |||
30 | if (manifestUrl == null) { | ||
31 | return; | ||
32 | } | ||
33 | |||
34 | const xmlhttp = new XMLHttpRequest(); | ||
35 | |||
36 | xmlhttp.onreadystatechange = function () { | ||
37 | if (this.readyState != 4 || this.status != 200) { | ||
38 | return; | ||
39 | } | ||
40 | |||
41 | const response = JSON.parse(this.responseText); | ||
42 | |||
43 | if (response.icons.length >= 1) { | ||
44 | Ferdi.ipcRenderer.sendToHost( | ||
45 | 'avatar', | ||
46 | `${window.location.protocol}//${window.location.host}${response.icons[0].src}`, | ||
47 | ); | ||
48 | } | ||
49 | }; | ||
50 | |||
51 | xmlhttp.open('GET', manifestUrl, true); | ||
52 | xmlhttp.send(); | ||
53 | }; | ||
54 | |||
54 | setTimeout(() => { | 55 | setTimeout(() => { |
55 | getTeamIcon(); | 56 | getTeamIcon(); |
56 | }, 4000); | 57 | }, 4000); |