diff options
author | Vijay A <avijayr@protonmail.com> | 2021-09-05 15:14:28 +0530 |
---|---|---|
committer | Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com> | 2021-09-05 18:00:26 +0530 |
commit | a57a4edcb648d025254ede4d18d267b887ad0b8b (patch) | |
tree | c8b75e58cf108a55608f729218885abdb07fd42d /recipes | |
parent | Add ability to use self-hosted option for 'youtrack' service (fixes #671) (diff) | |
download | ferdium-recipes-a57a4edcb648d025254ede4d18d267b887ad0b8b.tar.gz ferdium-recipes-a57a4edcb648d025254ede4d18d267b887ad0b8b.tar.zst ferdium-recipes-a57a4edcb648d025254ede4d18d267b887ad0b8b.zip |
Remove dependency on 'require' of 'electron' and 'electron/remote' modules.
Instead, use the exposed content from the recipe model in main ferdi.
Diffstat (limited to 'recipes')
-rw-r--r-- | recipes/android-messages/package.json | 2 | ||||
-rw-r--r-- | recipes/android-messages/webview.js | 10 | ||||
-rw-r--r-- | recipes/discord/package.json | 2 | ||||
-rw-r--r-- | recipes/discord/webview.js | 6 | ||||
-rw-r--r-- | recipes/googlemeet/package.json | 2 | ||||
-rw-r--r-- | recipes/googlemeet/webview.js | 6 | ||||
-rw-r--r-- | recipes/lastpass/package.json | 2 | ||||
-rw-r--r-- | recipes/lastpass/webview.js | 7 | ||||
-rw-r--r-- | recipes/pleroma/package.json | 2 | ||||
-rw-r--r-- | recipes/pleroma/webview.js | 4 | ||||
-rw-r--r-- | recipes/rocketchat/package.json | 2 | ||||
-rw-r--r-- | recipes/rocketchat/webview.js | 4 | ||||
-rw-r--r-- | recipes/skype/package.json | 2 | ||||
-rw-r--r-- | recipes/skype/webview.js | 4 | ||||
-rw-r--r-- | recipes/slack/package.json | 2 | ||||
-rw-r--r-- | recipes/slack/webview.js | 4 | ||||
-rw-r--r-- | recipes/steamchat/package.json | 2 | ||||
-rw-r--r-- | recipes/steamchat/webview.js | 4 | ||||
-rw-r--r-- | recipes/tweetdeck/package.json | 2 | ||||
-rw-r--r-- | recipes/tweetdeck/webview.js | 4 | ||||
-rw-r--r-- | recipes/whatsapp/package.json | 2 | ||||
-rw-r--r-- | recipes/whatsapp/webview.js | 31 |
22 files changed, 37 insertions, 69 deletions
diff --git a/recipes/android-messages/package.json b/recipes/android-messages/package.json index 4903955..852b942 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.1.0", | 4 | "version": "2.2.0", |
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 efaa5cf..4b57700 100644 --- a/recipes/android-messages/webview.js +++ b/recipes/android-messages/webview.js | |||
@@ -1,11 +1,3 @@ | |||
1 | const { | ||
2 | remote, | ||
3 | } = require('electron'); | ||
4 | |||
5 | const webContents = remote.getCurrentWebContents(); | ||
6 | const { | ||
7 | session, | ||
8 | } = webContents; | ||
9 | setTimeout(() => { | 1 | setTimeout(() => { |
10 | const elem = document.querySelector('#af-error-container'); | 2 | const elem = document.querySelector('#af-error-container'); |
11 | 3 | ||
@@ -13,8 +5,10 @@ setTimeout(() => { | |||
13 | window.location.reload(); | 5 | window.location.reload(); |
14 | } | 6 | } |
15 | }, 1000); | 7 | }, 1000); |
8 | |||
16 | window.addEventListener('beforeunload', async () => { | 9 | window.addEventListener('beforeunload', async () => { |
17 | try { | 10 | try { |
11 | const { session } = Ferdi.getCurrentWebContents(); | ||
18 | session.flushStorageData(); | 12 | session.flushStorageData(); |
19 | session.clearStorageData({ | 13 | session.clearStorageData({ |
20 | storages: ['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb'], | 14 | storages: ['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb'], |
diff --git a/recipes/discord/package.json b/recipes/discord/package.json index 7a2ec50..73a859c 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.3.1", | 4 | "version": "1.4.0", |
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 0559612..480329d 100644 --- a/recipes/discord/webview.js +++ b/recipes/discord/webview.js | |||
@@ -1,7 +1,5 @@ | |||
1 | // TODO: Some/most of this is already present in https://github.com/getferdi/ferdi/blob/develop/src/webview/screenshare.js#L5 | 1 | // TODO: Some/most of this is already present in https://github.com/getferdi/ferdi/blob/develop/src/webview/screenshare.js#L5 |
2 | 2 | ||
3 | const { desktopCapturer, remote: { BrowserWindow } } = require('electron'); | ||
4 | |||
5 | const _path = _interopRequireDefault(require('path')); | 3 | const _path = _interopRequireDefault(require('path')); |
6 | 4 | ||
7 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | 5 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -9,7 +7,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
9 | window.navigator.mediaDevices.getDisplayMedia = () => { | 7 | window.navigator.mediaDevices.getDisplayMedia = () => { |
10 | return new Promise(async (resolve, reject) => { | 8 | return new Promise(async (resolve, reject) => { |
11 | try { | 9 | try { |
12 | const sources = await desktopCapturer.getSources({ types: ['screen', 'window'] }); | 10 | const sources = await Ferdi.desktopCapturer.getSources({ types: ['screen', 'window'] }); |
13 | 11 | ||
14 | const selectionElem = document.createElement('div'); | 12 | const selectionElem = document.createElement('div'); |
15 | selectionElem.classList = 'desktop-capturer-selection'; | 13 | selectionElem.classList = 'desktop-capturer-selection'; |
@@ -99,7 +97,7 @@ module.exports = (Ferdi, settings) => { | |||
99 | event.stopPropagation(); | 97 | event.stopPropagation(); |
100 | 98 | ||
101 | if (url.includes('views/imgpsh_fullsize_anim')) { | 99 | if (url.includes('views/imgpsh_fullsize_anim')) { |
102 | let win = new BrowserWindow({ | 100 | let win = new Ferdi.BrowserWindow({ |
103 | width: 800, | 101 | width: 800, |
104 | height: window.innerHeight, | 102 | height: window.innerHeight, |
105 | minWidth: 600, | 103 | minWidth: 600, |
diff --git a/recipes/googlemeet/package.json b/recipes/googlemeet/package.json index fe63660..9cab8dd 100644 --- a/recipes/googlemeet/package.json +++ b/recipes/googlemeet/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "googlemeet", | 2 | "id": "googlemeet", |
3 | "name": "Google Meet", | 3 | "name": "Google Meet", |
4 | "version": "2.1.0", | 4 | "version": "2.2.0", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://meet.google.com", | 7 | "serviceURL": "https://meet.google.com", |
diff --git a/recipes/googlemeet/webview.js b/recipes/googlemeet/webview.js index 3a20b0c..d6a29fe 100644 --- a/recipes/googlemeet/webview.js +++ b/recipes/googlemeet/webview.js | |||
@@ -2,11 +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 { remote } = require('electron'); | ||
6 | |||
7 | const webContents = remote.getCurrentWebContents(); | ||
8 | const { session } = webContents; | ||
9 | |||
10 | window.onload = () => { | 5 | window.onload = () => { |
11 | const title = document.querySelector('.window-title').innerHTML; | 6 | const title = document.querySelector('.window-title').innerHTML; |
12 | 7 | ||
@@ -16,6 +11,7 @@ window.onload = () => { | |||
16 | }; | 11 | }; |
17 | 12 | ||
18 | module.exports = Ferdi => { | 13 | module.exports = Ferdi => { |
14 | const { session } = Ferdi.getCurrentWebContents(); | ||
19 | session.flushStorageData(); | 15 | session.flushStorageData(); |
20 | session.clearStorageData({ | 16 | session.clearStorageData({ |
21 | storages: ['serviceworkers'], | 17 | storages: ['serviceworkers'], |
diff --git a/recipes/lastpass/package.json b/recipes/lastpass/package.json index d45cb4b..cf08063 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.1.0", | 4 | "version": "2.2.0", |
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 d4090b3..878fa5e 100644 --- a/recipes/lastpass/webview.js +++ b/recipes/lastpass/webview.js | |||
@@ -2,12 +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 { remote } = require('electron'); | ||
6 | |||
7 | const webContents = remote.getCurrentWebContents(); | ||
8 | |||
9 | const { session } = webContents; | ||
10 | |||
11 | setTimeout(() => { | 5 | setTimeout(() => { |
12 | if (document.querySelector('body').innerHTML.includes('Google Chrome 36+')) { | 6 | if (document.querySelector('body').innerHTML.includes('Google Chrome 36+')) { |
13 | window.location.reload(); | 7 | window.location.reload(); |
@@ -15,6 +9,7 @@ setTimeout(() => { | |||
15 | }, 1000); | 9 | }, 1000); |
16 | window.addEventListener('beforeunload', async () => { | 10 | window.addEventListener('beforeunload', async () => { |
17 | try { | 11 | try { |
12 | const { session } = Ferdi.getCurrentWebContents(); | ||
18 | session.flushStorageData(); | 13 | session.flushStorageData(); |
19 | session.clearStorageData({ | 14 | session.clearStorageData({ |
20 | storages: ['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb'], | 15 | storages: ['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb'], |
diff --git a/recipes/pleroma/package.json b/recipes/pleroma/package.json index 5a4fdf9..1592d7b 100644 --- a/recipes/pleroma/package.json +++ b/recipes/pleroma/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "pleroma", | 2 | "id": "pleroma", |
3 | "name": "Pleroma", | 3 | "name": "Pleroma", |
4 | "version": "1.1.2", | 4 | "version": "1.2.0", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "hasCustomUrl": true | 7 | "hasCustomUrl": true |
diff --git a/recipes/pleroma/webview.js b/recipes/pleroma/webview.js index 2c97ab3..557f318 100644 --- a/recipes/pleroma/webview.js +++ b/recipes/pleroma/webview.js | |||
@@ -1,5 +1,3 @@ | |||
1 | const { ipcRenderer } = require('electron'); | ||
2 | |||
3 | const titleRegex = /^\((\d+)\)/; | 1 | const titleRegex = /^\((\d+)\)/; |
4 | 2 | ||
5 | const getJson = async (relativeUri) => { | 3 | const getJson = async (relativeUri) => { |
@@ -153,7 +151,7 @@ module.exports = Ferdi => { | |||
153 | Ferdi.loop(() => { | 151 | Ferdi.loop(() => { |
154 | getMessages(); | 152 | getMessages(); |
155 | if (updater.update()) { | 153 | if (updater.update()) { |
156 | ipcRenderer.sendToHost('avatar', updater.toDataURL()); | 154 | Ferdi.ipcRenderer.sendToHost('avatar', updater.toDataURL()); |
157 | } | 155 | } |
158 | }); | 156 | }); |
159 | }, (e) => { | 157 | }, (e) => { |
diff --git a/recipes/rocketchat/package.json b/recipes/rocketchat/package.json index 111efbd..3b807bf 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.1.1", | 4 | "version": "1.2.0", |
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 d3d0a27..4240935 100644 --- a/recipes/rocketchat/webview.js +++ b/recipes/rocketchat/webview.js | |||
@@ -1,5 +1,3 @@ | |||
1 | const { ipcRenderer } = require('electron'); | ||
2 | |||
3 | const getTeamIcon = function getTeamIcon() { | 1 | const getTeamIcon = function getTeamIcon() { |
4 | const manifestElement = document.querySelector('link[rel="manifest"]'); | 2 | const manifestElement = document.querySelector('link[rel="manifest"]'); |
5 | 3 | ||
@@ -23,7 +21,7 @@ const getTeamIcon = function getTeamIcon() { | |||
23 | const response = JSON.parse(this.responseText); | 21 | const response = JSON.parse(this.responseText); |
24 | 22 | ||
25 | if (response.icons.length >= 1) { | 23 | if (response.icons.length >= 1) { |
26 | ipcRenderer.sendToHost( | 24 | Ferdi.ipcRenderer.sendToHost( |
27 | 'avatar', | 25 | 'avatar', |
28 | `${window.location.protocol}//${window.location.host}${response.icons[0].src}`, | 26 | `${window.location.protocol}//${window.location.host}${response.icons[0].src}`, |
29 | ); | 27 | ); |
diff --git a/recipes/skype/package.json b/recipes/skype/package.json index 342621c..5d23929 100644 --- a/recipes/skype/package.json +++ b/recipes/skype/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "skype", | 2 | "id": "skype", |
3 | "name": "Skype", | 3 | "name": "Skype", |
4 | "version": "3.1.1", | 4 | "version": "3.2.0", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://web.skype.com/", | 7 | "serviceURL": "https://web.skype.com/", |
diff --git a/recipes/skype/webview.js b/recipes/skype/webview.js index 6e84d78..dd867ea 100644 --- a/recipes/skype/webview.js +++ b/recipes/skype/webview.js | |||
@@ -2,8 +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 { remote: { BrowserWindow } } = require('electron'); | ||
6 | |||
7 | module.exports = (Ferdi, settings) => { | 5 | module.exports = (Ferdi, settings) => { |
8 | const getMessages = function getMessages() { | 6 | const getMessages = function getMessages() { |
9 | let count = 0; | 7 | let count = 0; |
@@ -44,7 +42,7 @@ module.exports = (Ferdi, settings) => { | |||
44 | event.stopPropagation(); | 42 | event.stopPropagation(); |
45 | // TODO: Can we send an ipc event 'open-browser-window' to open the child window? (see the slack recipe for how to send an ipc message) | 43 | // TODO: Can we send an ipc event 'open-browser-window' to open the child window? (see the slack recipe for how to send an ipc message) |
46 | // TODO: Can we change the slack recipe to add a clickHandler for screensharing/video calls? (https://github.com/getferdi/ferdi/issues/1697) | 44 | // TODO: Can we change the slack recipe to add a clickHandler for screensharing/video calls? (https://github.com/getferdi/ferdi/issues/1697) |
47 | const win = new BrowserWindow({ | 45 | const win = new Ferdi.BrowserWindow({ |
48 | width: 800, | 46 | width: 800, |
49 | height: window.innerHeight, | 47 | height: window.innerHeight, |
50 | minWidth: 600, | 48 | minWidth: 600, |
diff --git a/recipes/slack/package.json b/recipes/slack/package.json index 1c5de53..7c87e93 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.2.0", | 4 | "version": "1.3.0", |
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 b8e3817..1a12e80 100644 --- a/recipes/slack/webview.js +++ b/recipes/slack/webview.js | |||
@@ -1,5 +1,3 @@ | |||
1 | const _electron = require('electron'); | ||
2 | |||
3 | const _path = _interopRequireDefault(require('path')); | 1 | const _path = _interopRequireDefault(require('path')); |
4 | 2 | ||
5 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | 3 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -27,7 +25,7 @@ const getTeamIcon = function getTeamIcon(count = 0) { | |||
27 | countTeamIconCheck += 1; | 25 | countTeamIconCheck += 1; |
28 | 26 | ||
29 | if (bgUrl) { | 27 | if (bgUrl) { |
30 | _electron.ipcRenderer.sendToHost('avatar', bgUrl); | 28 | Ferdi.ipcRenderer.sendToHost('avatar', bgUrl); |
31 | } else if (countTeamIconCheck <= 5) { | 29 | } else if (countTeamIconCheck <= 5) { |
32 | setTimeout(() => { | 30 | setTimeout(() => { |
33 | getTeamIcon(countTeamIconCheck + 1); | 31 | getTeamIcon(countTeamIconCheck + 1); |
diff --git a/recipes/steamchat/package.json b/recipes/steamchat/package.json index 4edbb82..12da5b9 100644 --- a/recipes/steamchat/package.json +++ b/recipes/steamchat/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "steamchat", | 2 | "id": "steamchat", |
3 | "name": "SteamChat", | 3 | "name": "SteamChat", |
4 | "version": "1.2.1", | 4 | "version": "1.3.0", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://steamcommunity.com/chat", | 7 | "serviceURL": "https://steamcommunity.com/chat", |
diff --git a/recipes/steamchat/webview.js b/recipes/steamchat/webview.js index 93e68ba..63f002f 100644 --- a/recipes/steamchat/webview.js +++ b/recipes/steamchat/webview.js | |||
@@ -1,5 +1,3 @@ | |||
1 | const { ipcRenderer } = require('electron'); | ||
2 | |||
3 | module.exports = Ferdi => { | 1 | module.exports = Ferdi => { |
4 | const getMessages = function getMessages() { | 2 | const getMessages = function getMessages() { |
5 | // get new msg count | 3 | // get new msg count |
@@ -34,7 +32,7 @@ module.exports = Ferdi => { | |||
34 | const url = link.getAttribute('href'); | 32 | const url = link.getAttribute('href'); |
35 | event.preventDefault(); | 33 | event.preventDefault(); |
36 | event.stopPropagation(); | 34 | event.stopPropagation(); |
37 | ipcRenderer.sendToHost('new-window', url); | 35 | Ferdi.ipcRenderer.sendToHost('new-window', url); |
38 | } | 36 | } |
39 | }, true); | 37 | }, true); |
40 | }; | 38 | }; |
diff --git a/recipes/tweetdeck/package.json b/recipes/tweetdeck/package.json index dd103f8..a438716 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.1.1", | 4 | "version": "1.2.0", |
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 6de7d75..b60415d 100644 --- a/recipes/tweetdeck/webview.js +++ b/recipes/tweetdeck/webview.js | |||
@@ -1,7 +1,5 @@ | |||
1 | const { ipcRenderer } = require('electron'); | ||
2 | |||
3 | // Tweetdeck redirect fix | 1 | // Tweetdeck redirect fix |
4 | ipcRenderer.on('redirect-url', (event, url) => { | 2 | Ferdi.ipcRenderer.on('redirect-url', (event, url) => { |
5 | window.location.assign(url); | 3 | window.location.assign(url); |
6 | }); | 4 | }); |
7 | 5 | ||
diff --git a/recipes/whatsapp/package.json b/recipes/whatsapp/package.json index 6d2a93e..785a3fe 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.2.1", | 4 | "version": "3.3.0", |
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 9b979d2..8087b08 100644 --- a/recipes/whatsapp/webview.js +++ b/recipes/whatsapp/webview.js | |||
@@ -1,14 +1,10 @@ | |||
1 | const { remote } = require('electron'); | ||
2 | |||
3 | const _path = _interopRequireDefault(require('path')); | 1 | const _path = _interopRequireDefault(require('path')); |
4 | 2 | ||
5 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | 3 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
6 | 4 | ||
7 | const webContents = remote.getCurrentWebContents(); | ||
8 | const { session } = webContents; | ||
9 | |||
10 | window.addEventListener('beforeunload', async () => { | 5 | window.addEventListener('beforeunload', async () => { |
11 | try { | 6 | try { |
7 | const { session } = Ferdi.getCurrentWebContents(); | ||
12 | session.flushStorageData(); | 8 | session.flushStorageData(); |
13 | session.clearStorageData({ | 9 | session.clearStorageData({ |
14 | storages: ['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb'], | 10 | storages: ['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb'], |
@@ -28,20 +24,21 @@ module.exports = Ferdi => { | |||
28 | let count = 0; | 24 | let count = 0; |
29 | let indirectCount = 0; | 25 | let indirectCount = 0; |
30 | 26 | ||
31 | const parentChatElem = document.querySelector('#pane-side').children[0].children[0].children[0]; | 27 | const parentChatElem = document.querySelector('[aria-label="Chat list"]'); |
32 | if (!parentChatElem) return; | 28 | if (!parentChatElem) { |
33 | 29 | return; | |
34 | const chatElems = parentChatElem.children; | 30 | } |
35 | for (let i = 0; i < chatElems.length; i++) { | ||
36 | const chatElem = chatElems[i]; | ||
37 | const unreadElem = chatElem.children[0].children[0].children[1].children[1].children[1]; | ||
38 | 31 | ||
32 | const unreadSpans = parentChatElem.querySelectorAll('span[aria-label]'); | ||
33 | for (let i = 0; i < unreadSpans.length; i++) { | ||
34 | const unreadElem = unreadSpans[i]; | ||
39 | const countValue = Ferdi.safeParseInt(unreadElem.textContent); | 35 | const countValue = Ferdi.safeParseInt(unreadElem.textContent); |
40 | 36 | if (countValue > 0) { | |
41 | if (unreadElem.querySelectorAll('[data-icon=muted]').length === 0) { | 37 | if (!unreadElem.parentNode.previousSibling || unreadElem.parentNode.previousSibling.querySelectorAll('[data-icon=muted]').length === 0) { |
42 | count += countValue; | 38 | count += countValue; |
43 | } else { | 39 | } else { |
44 | indirectCount += countValue; | 40 | indirectCount += countValue; |
41 | } | ||
45 | } | 42 | } |
46 | } | 43 | } |
47 | 44 | ||