aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2021-09-19 00:41:52 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2021-09-19 00:57:47 +0200
commitc5d2a889d4cb44f995d74051f83628b505383093 (patch)
treeb1bab2b6d7f99ab00b0ca9860079f71472ac79ae
parentFix images opening in browser instead of in Discord (#712) (diff)
downloadferdium-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
-rw-r--r--all.json18
-rw-r--r--recipes/android-messages/package.json2
-rw-r--r--recipes/android-messages/webview.js10
-rw-r--r--recipes/devRant/package.json2
-rw-r--r--recipes/devRant/webview.js10
-rw-r--r--recipes/discord/package.json2
-rw-r--r--recipes/discord/webview.js58
-rw-r--r--recipes/lastpass/package.json2
-rw-r--r--recipes/lastpass/webview.js10
-rw-r--r--recipes/msteams/package.json2
-rw-r--r--recipes/msteams/webview.js10
-rw-r--r--recipes/rocketchat/package.json2
-rw-r--r--recipes/rocketchat/webview.js67
-rw-r--r--recipes/slack/package.json2
-rw-r--r--recipes/slack/webview.js62
-rw-r--r--recipes/tweetdeck/package.json2
-rw-r--r--recipes/tweetdeck/webview.js10
-rw-r--r--recipes/whatsapp/package.json2
-rw-r--r--recipes/whatsapp/webview.js10
19 files changed, 113 insertions, 170 deletions
diff --git a/all.json b/all.json
index 87bb41d..f02c35d 100644
--- a/all.json
+++ b/all.json
@@ -42,7 +42,7 @@
42 "featured": false, 42 "featured": false,
43 "id": "android-messages", 43 "id": "android-messages",
44 "name": "Android Messages", 44 "name": "Android Messages",
45 "version": "2.2.1", 45 "version": "2.2.2",
46 "icons": { 46 "icons": {
47 "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/android-messages/icon.svg" 47 "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/android-messages/icon.svg"
48 } 48 }
@@ -270,7 +270,7 @@
270 "featured": false, 270 "featured": false,
271 "id": "devRant", 271 "id": "devRant",
272 "name": "devRant", 272 "name": "devRant",
273 "version": "1.0.0", 273 "version": "1.0.1",
274 "icons": { 274 "icons": {
275 "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/devRant/icon.svg" 275 "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/devRant/icon.svg"
276 } 276 }
@@ -297,7 +297,7 @@
297 "featured": true, 297 "featured": true,
298 "id": "discord", 298 "id": "discord",
299 "name": "Discord", 299 "name": "Discord",
300 "version": "1.4.1", 300 "version": "1.4.2",
301 "icons": { 301 "icons": {
302 "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/discord/icon.svg" 302 "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/discord/icon.svg"
303 } 303 }
@@ -876,7 +876,7 @@
876 "featured": false, 876 "featured": false,
877 "id": "lastpass", 877 "id": "lastpass",
878 "name": "LastPass", 878 "name": "LastPass",
879 "version": "2.2.1", 879 "version": "2.2.2",
880 "icons": { 880 "icons": {
881 "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/lastpass/icon.svg" 881 "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/lastpass/icon.svg"
882 } 882 }
@@ -975,7 +975,7 @@
975 "featured": false, 975 "featured": false,
976 "id": "msteams", 976 "id": "msteams",
977 "name": "Microsoft Teams", 977 "name": "Microsoft Teams",
978 "version": "3.1.4", 978 "version": "3.1.5",
979 "aliases": [ 979 "aliases": [
980 "teamsChat" 980 "teamsChat"
981 ], 981 ],
@@ -1350,7 +1350,7 @@
1350 "featured": false, 1350 "featured": false,
1351 "id": "rocketchat", 1351 "id": "rocketchat",
1352 "name": "Rocket.Chat", 1352 "name": "Rocket.Chat",
1353 "version": "1.2.0", 1353 "version": "1.2.1",
1354 "icons": { 1354 "icons": {
1355 "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/rocketchat/icon.svg" 1355 "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/rocketchat/icon.svg"
1356 } 1356 }
@@ -1413,7 +1413,7 @@
1413 "featured": true, 1413 "featured": true,
1414 "id": "slack", 1414 "id": "slack",
1415 "name": "Slack", 1415 "name": "Slack",
1416 "version": "1.3.0", 1416 "version": "1.3.1",
1417 "icons": { 1417 "icons": {
1418 "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/slack/icon.svg" 1418 "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/slack/icon.svg"
1419 } 1419 }
@@ -1656,7 +1656,7 @@
1656 "featured": true, 1656 "featured": true,
1657 "id": "tweetdeck", 1657 "id": "tweetdeck",
1658 "name": "Tweetdeck", 1658 "name": "Tweetdeck",
1659 "version": "1.2.0", 1659 "version": "1.2.1",
1660 "icons": { 1660 "icons": {
1661 "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/tweetdeck/icon.svg" 1661 "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/tweetdeck/icon.svg"
1662 } 1662 }
@@ -1773,7 +1773,7 @@
1773 "featured": true, 1773 "featured": true,
1774 "id": "whatsapp", 1774 "id": "whatsapp",
1775 "name": "WhatsApp", 1775 "name": "WhatsApp",
1776 "version": "3.3.2", 1776 "version": "3.3.3",
1777 "icons": { 1777 "icons": {
1778 "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/whatsapp/icon.svg" 1778 "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/recipes/whatsapp/icon.svg"
1779 } 1779 }
diff --git a/recipes/android-messages/package.json b/recipes/android-messages/package.json
index 354c21d..962eb2b 100644
--- a/recipes/android-messages/package.json
+++ b/recipes/android-messages/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "android-messages", 2 "id": "android-messages",
3 "name": "Android Messages", 3 "name": "Android Messages",
4 "version": "2.2.1", 4 "version": "2.2.2",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://messages.google.com/web", 7 "serviceURL": "https://messages.google.com/web",
diff --git a/recipes/android-messages/webview.js b/recipes/android-messages/webview.js
index 6a73441..db65de6 100644
--- a/recipes/android-messages/webview.js
+++ b/recipes/android-messages/webview.js
@@ -7,17 +7,17 @@ setTimeout(() => {
7 } 7 }
8}, 1000); 8}, 1000);
9 9
10window.addEventListener('beforeunload', async () => {
11 Ferdi.clearStorageData(['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb']);
12 Ferdi.releaseServiceWorkers();
13});
14
15module.exports = (Ferdi, settings) => { 10module.exports = (Ferdi, settings) => {
16 function getMessages() { 11 function getMessages() {
17 const messages = document.querySelectorAll('.text-content.unread').length; 12 const messages = document.querySelectorAll('.text-content.unread').length;
18 Ferdi.setBadge(messages); 13 Ferdi.setBadge(messages);
19 } 14 }
20 15
16 window.addEventListener('beforeunload', async () => {
17 Ferdi.clearStorageData(['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb']);
18 Ferdi.releaseServiceWorkers();
19 });
20
21 Ferdi.loop(getMessages); 21 Ferdi.loop(getMessages);
22 22
23 if (settings.isDarkModeEnabled) { 23 if (settings.isDarkModeEnabled) {
diff --git a/recipes/devRant/package.json b/recipes/devRant/package.json
index 4aa3517..6dee2d6 100644
--- a/recipes/devRant/package.json
+++ b/recipes/devRant/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "devRant", 2 "id": "devRant",
3 "name": "devRant", 3 "name": "devRant",
4 "version": "1.0.0", 4 "version": "1.0.1",
5 "license": "MIT", 5 "license": "MIT",
6 "repository": "https://github.com/emamut/recipe-devrant", 6 "repository": "https://github.com/emamut/recipe-devrant",
7 "config": { 7 "config": {
diff --git a/recipes/devRant/webview.js b/recipes/devRant/webview.js
index e7e41a5..62a47e6 100644
--- a/recipes/devRant/webview.js
+++ b/recipes/devRant/webview.js
@@ -9,11 +9,6 @@ setTimeout(() => {
9 } 9 }
10}, 1000); 10}, 1000);
11 11
12window.addEventListener('beforeunload', async () => {
13 Ferdi.clearStorageData(['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb']);
14 Ferdi.releaseServiceWorkers();
15});
16
17module.exports = (Ferdi) => { 12module.exports = (Ferdi) => {
18 const getMessages = function getMessages() { 13 const getMessages = function getMessages() {
19 const elements = document.querySelectorAll('.CxUIE, .unread, ._0LqQ'); 14 const elements = document.querySelectorAll('.CxUIE, .unread, ._0LqQ');
@@ -27,6 +22,11 @@ module.exports = (Ferdi) => {
27 Ferdi.setBadge(count); 22 Ferdi.setBadge(count);
28 }; 23 };
29 24
25 window.addEventListener('beforeunload', async () => {
26 Ferdi.clearStorageData(['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb']);
27 Ferdi.releaseServiceWorkers();
28 });
29
30 Ferdi.loop(getMessages); 30 Ferdi.loop(getMessages);
31 Ferdi.injectCSS(_path.default.join(__dirname, 'service.css')); 31 Ferdi.injectCSS(_path.default.join(__dirname, 'service.css'));
32}; 32};
diff --git a/recipes/discord/package.json b/recipes/discord/package.json
index c644d66..243e64b 100644
--- a/recipes/discord/package.json
+++ b/recipes/discord/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "discord", 2 "id": "discord",
3 "name": "Discord", 3 "name": "Discord",
4 "version": "1.4.1", 4 "version": "1.4.2",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://discordapp.com/login", 7 "serviceURL": "https://discordapp.com/login",
diff --git a/recipes/discord/webview.js b/recipes/discord/webview.js
index 9c96f9f..3134221 100644
--- a/recipes/discord/webview.js
+++ b/recipes/discord/webview.js
@@ -1,65 +1,7 @@
1// TODO: Some/most of this is already present in https://github.com/getferdi/ferdi/blob/develop/src/webview/screenshare.js#L5
2
3const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
4 2
5function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6 4
7window.navigator.mediaDevices.getDisplayMedia = () => {
8 return new Promise(async (resolve, reject) => {
9 try {
10 const sources = await Ferdi.desktopCapturer.getSources({ types: ['screen', 'window'] });
11
12 const selectionElem = document.createElement('div');
13 selectionElem.classList = 'desktop-capturer-selection';
14 selectionElem.innerHTML = `
15 <div class="desktop-capturer-selection__scroller">
16 <ul class="desktop-capturer-selection__list">
17 ${sources.map(({ id, name, thumbnail, display_id, appIcon }) => `
18 <li class="desktop-capturer-selection__item">
19 <button class="desktop-capturer-selection__btn" data-id="${id}" title="${name}">
20 <img class="desktop-capturer-selection__thumbnail" src="${thumbnail.toDataURL()}" />
21 <span class="desktop-capturer-selection__name">${name}</span>
22 </button>
23 </li>
24 `).join('')}
25 </ul>
26 </div>
27 `;
28 document.body.appendChild(selectionElem);
29
30 document.querySelectorAll('.desktop-capturer-selection__btn')
31 .forEach(button => {
32 button.addEventListener('click', async () => {
33 try {
34 const id = button.getAttribute('data-id');
35 const source = sources.find(source => source.id === id);
36 if (!source) {
37 throw new Error(`Source with id ${id} does not exist`);
38 }
39
40 const stream = await window.navigator.mediaDevices.getUserMedia({
41 audio: false,
42 video: {
43 mandatory: {
44 chromeMediaSource: 'desktop',
45 chromeMediaSourceId: source.id
46 }
47 }
48 });
49 resolve(stream);
50
51 selectionElem.remove();
52 } catch (err) {
53 reject(err);
54 }
55 });
56 });
57 } catch (err) {
58 reject(err);
59 }
60 })
61}
62
63module.exports = (Ferdi, settings) => { 5module.exports = (Ferdi, settings) => {
64 const getMessages = function getMessages() { 6 const getMessages = function getMessages() {
65 let count = 0; 7 let count = 0;
diff --git a/recipes/lastpass/package.json b/recipes/lastpass/package.json
index 75632bd..eed8f9e 100644
--- a/recipes/lastpass/package.json
+++ b/recipes/lastpass/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "lastpass", 2 "id": "lastpass",
3 "name": "LastPass", 3 "name": "LastPass",
4 "version": "2.2.1", 4 "version": "2.2.2",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://lastpass.com/?ac=1&lpnorefresh=1", 7 "serviceURL": "https://lastpass.com/?ac=1&lpnorefresh=1",
diff --git a/recipes/lastpass/webview.js b/recipes/lastpass/webview.js
index 4a92e0c..96e92ff 100644
--- a/recipes/lastpass/webview.js
+++ b/recipes/lastpass/webview.js
@@ -8,11 +8,6 @@ setTimeout(() => {
8 } 8 }
9}, 1000); 9}, 1000);
10 10
11window.addEventListener('beforeunload', async () => {
12 Ferdi.clearStorageData(['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb']);
13 Ferdi.releaseServiceWorkers();
14});
15
16module.exports = Ferdi => { 11module.exports = Ferdi => {
17 const getMessages = function getMessages() { 12 const getMessages = function getMessages() {
18 const elements = document.querySelectorAll('.CxUIE, .unread'); 13 const elements = document.querySelectorAll('.CxUIE, .unread');
@@ -27,6 +22,11 @@ module.exports = Ferdi => {
27 Ferdi.setBadge(count); 22 Ferdi.setBadge(count);
28 }; 23 };
29 24
25 window.addEventListener('beforeunload', async () => {
26 Ferdi.clearStorageData(['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb']);
27 Ferdi.releaseServiceWorkers();
28 });
29
30 Ferdi.loop(getMessages); 30 Ferdi.loop(getMessages);
31 31
32 Ferdi.injectCSS(_path.default.join(__dirname, 'service.css')); 32 Ferdi.injectCSS(_path.default.join(__dirname, 'service.css'));
diff --git a/recipes/msteams/package.json b/recipes/msteams/package.json
index 10fb69b..17c0aa0 100644
--- a/recipes/msteams/package.json
+++ b/recipes/msteams/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "msteams", 2 "id": "msteams",
3 "name": "Microsoft Teams", 3 "name": "Microsoft Teams",
4 "version": "3.1.4", 4 "version": "3.1.5",
5 "license": "MIT", 5 "license": "MIT",
6 "aliases": [ 6 "aliases": [
7 "teamsChat" 7 "teamsChat"
diff --git a/recipes/msteams/webview.js b/recipes/msteams/webview.js
index 786cd9b..94f3ae8 100644
--- a/recipes/msteams/webview.js
+++ b/recipes/msteams/webview.js
@@ -2,11 +2,6 @@ const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4 4
5window.addEventListener('beforeunload', async () => {
6 Ferdi.clearStorageData(['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb']);
7 Ferdi.releaseServiceWorkers();
8});
9
10module.exports = Ferdi => { 5module.exports = Ferdi => {
11 const getMessages = () => { 6 const getMessages = () => {
12 let messages = 0; 7 let messages = 0;
@@ -20,6 +15,11 @@ module.exports = Ferdi => {
20 Ferdi.setBadge(messages, indirectMessages); 15 Ferdi.setBadge(messages, indirectMessages);
21 }; 16 };
22 17
18 window.addEventListener('beforeunload', async () => {
19 Ferdi.clearStorageData(['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb']);
20 Ferdi.releaseServiceWorkers();
21 });
22
23 Ferdi.loop(getMessages); 23 Ferdi.loop(getMessages);
24 24
25 Ferdi.injectCSS(_path.default.join(__dirname, 'service.css')); 25 Ferdi.injectCSS(_path.default.join(__dirname, 'service.css'));
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 @@
1const 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
35module.exports = Ferdi => { 2module.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);
diff --git a/recipes/slack/package.json b/recipes/slack/package.json
index 7c87e93..877bd8e 100644
--- a/recipes/slack/package.json
+++ b/recipes/slack/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "slack", 2 "id": "slack",
3 "name": "Slack", 3 "name": "Slack",
4 "version": "1.3.0", 4 "version": "1.3.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://{teamId}.slack.com", 7 "serviceURL": "https://{teamId}.slack.com",
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
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4 4
5const 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
36const SELECTOR_CHANNELS_UNREAD = '.p-channel_sidebar__channel--unread:not(.p-channel_sidebar__channel--muted)'; 5const SELECTOR_CHANNELS_UNREAD = '.p-channel_sidebar__channel--unread:not(.p-channel_sidebar__channel--muted)';
37 6
38module.exports = Ferdi => { 7module.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);
diff --git a/recipes/tweetdeck/package.json b/recipes/tweetdeck/package.json
index a438716..5400bac 100644
--- a/recipes/tweetdeck/package.json
+++ b/recipes/tweetdeck/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "tweetdeck", 2 "id": "tweetdeck",
3 "name": "Tweetdeck", 3 "name": "Tweetdeck",
4 "version": "1.2.0", 4 "version": "1.2.1",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://tweetdeck.twitter.com/", 7 "serviceURL": "https://tweetdeck.twitter.com/",
diff --git a/recipes/tweetdeck/webview.js b/recipes/tweetdeck/webview.js
index b60415d..54b7997 100644
--- a/recipes/tweetdeck/webview.js
+++ b/recipes/tweetdeck/webview.js
@@ -1,9 +1,9 @@
1// Tweetdeck redirect fix
2Ferdi.ipcRenderer.on('redirect-url', (event, url) => {
3 window.location.assign(url);
4});
5
6module.exports = Ferdi => { 1module.exports = Ferdi => {
2 // Tweetdeck redirect fix
3 Ferdi.ipcRenderer.on('redirect-url', (event, url) => {
4 window.location.assign(url);
5 });
6
7 const getMessages = function getMessages() { 7 const getMessages = function getMessages() {
8 const elements = document.querySelectorAll('.msg-unread-count'); 8 const elements = document.querySelectorAll('.msg-unread-count');
9 let count = 0; 9 let count = 0;
diff --git a/recipes/whatsapp/package.json b/recipes/whatsapp/package.json
index 4e59177..a364a1f 100644
--- a/recipes/whatsapp/package.json
+++ b/recipes/whatsapp/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "whatsapp", 2 "id": "whatsapp",
3 "name": "WhatsApp", 3 "name": "WhatsApp",
4 "version": "3.3.2", 4 "version": "3.3.3",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://web.whatsapp.com", 7 "serviceURL": "https://web.whatsapp.com",
diff --git a/recipes/whatsapp/webview.js b/recipes/whatsapp/webview.js
index 3df34e3..fb1a20b 100644
--- a/recipes/whatsapp/webview.js
+++ b/recipes/whatsapp/webview.js
@@ -2,11 +2,6 @@ const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4 4
5window.addEventListener('beforeunload', async () => {
6 Ferdi.clearStorageData(['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb']);
7 Ferdi.releaseServiceWorkers();
8});
9
10module.exports = Ferdi => { 5module.exports = Ferdi => {
11 const getMessages = function getMessages() { 6 const getMessages = function getMessages() {
12 let count = 0; 7 let count = 0;
@@ -34,6 +29,11 @@ module.exports = Ferdi => {
34 Ferdi.setBadge(count, indirectCount); 29 Ferdi.setBadge(count, indirectCount);
35 }; 30 };
36 31
32 window.addEventListener('beforeunload', async () => {
33 Ferdi.clearStorageData(['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb']);
34 Ferdi.releaseServiceWorkers();
35 });
36
37 Ferdi.loop(getMessages); 37 Ferdi.loop(getMessages);
38 38
39 Ferdi.injectCSS(_path.default.join(__dirname, 'service.css')); 39 Ferdi.injectCSS(_path.default.join(__dirname, 'service.css'));