diff options
Diffstat (limited to 'recipes/whatsapp')
-rw-r--r-- | recipes/whatsapp/index.js | 36 | ||||
-rw-r--r-- | recipes/whatsapp/webview.js | 26 |
2 files changed, 29 insertions, 33 deletions
diff --git a/recipes/whatsapp/index.js b/recipes/whatsapp/index.js index a0ff71f..96c95a3 100644 --- a/recipes/whatsapp/index.js +++ b/recipes/whatsapp/index.js | |||
@@ -1,20 +1,18 @@ | |||
1 | "use strict"; | 1 | module.exports = (Franz) => class Messenger extends Franz { |
2 | overrideUserAgent() { | ||
3 | return window.navigator.userAgent.replace(/(Ferdi|Electron)\/\S+( \([^)]+\))?/g, '').trim(); | ||
4 | } | ||
2 | 5 | ||
3 | module.exports = (Franz) => | 6 | modifyRequestHeaders() { |
4 | class Messenger extends Franz { | 7 | return [ |
5 | overrideUserAgent() { | 8 | { |
6 | return window.navigator.userAgent.replace(/(Ferdi|Electron)\/\S+( \([^)]+\))?/g, "").trim(); | 9 | headers: { |
7 | } | 10 | 'user-agent': window.navigator.userAgent.replace(/(Ferdi|Electron)\/\S+( \([^)]+\))?/g, '').trim(), |
8 | modifyRequestHeaders() { | 11 | }, |
9 | return [ | 12 | requestFilters: { |
10 | { | 13 | urls: ['*://*/*'], |
11 | headers: { | 14 | }, |
12 | 'user-agent': window.navigator.userAgent.replace(/(Ferdi|Electron)\/\S+( \([^)]+\))?/g, "").trim(), | 15 | }, |
13 | }, | 16 | ]; |
14 | requestFilters: { | 17 | } |
15 | urls: ['*://*/*'], | 18 | }; |
16 | } | ||
17 | } | ||
18 | ] | ||
19 | } | ||
20 | }; | ||
diff --git a/recipes/whatsapp/webview.js b/recipes/whatsapp/webview.js index 8320d9e..c01b7d1 100644 --- a/recipes/whatsapp/webview.js +++ b/recipes/whatsapp/webview.js | |||
@@ -1,20 +1,18 @@ | |||
1 | "use strict"; | ||
2 | |||
3 | const { | 1 | const { |
4 | remote | 2 | remote, |
5 | } = require('electron'); | 3 | } = require('electron'); |
6 | 4 | ||
7 | const path = require('path'); | 5 | const path = require('path'); |
8 | 6 | ||
9 | const webContents = remote.getCurrentWebContents(); | 7 | const webContents = remote.getCurrentWebContents(); |
10 | const { | 8 | const { |
11 | session | 9 | session, |
12 | } = webContents; | 10 | } = webContents; |
13 | window.addEventListener('beforeunload', async () => { | 11 | window.addEventListener('beforeunload', async () => { |
14 | try { | 12 | try { |
15 | session.flushStorageData(); | 13 | session.flushStorageData(); |
16 | session.clearStorageData({ | 14 | session.clearStorageData({ |
17 | storages: ['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb'] | 15 | storages: ['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb'], |
18 | }); | 16 | }); |
19 | const registrations = await window.navigator.serviceWorker.getRegistrations(); | 17 | const registrations = await window.navigator.serviceWorker.getRegistrations(); |
20 | registrations.forEach(r => { | 18 | registrations.forEach(r => { |
@@ -28,18 +26,18 @@ window.addEventListener('beforeunload', async () => { | |||
28 | 26 | ||
29 | module.exports = Franz => { | 27 | module.exports = Franz => { |
30 | const getMessages = function getMessages() { | 28 | const getMessages = function getMessages() { |
31 | var count = 0; | 29 | let count = 0; |
32 | var indirectCount = 0; | 30 | let indirectCount = 0; |
33 | 31 | ||
34 | var parentChatElem = document.querySelector("#pane-side").children[0].children[0].children[0]; | 32 | const parentChatElem = document.querySelector('#pane-side').children[0].children[0].children[0]; |
35 | var chatElems = parentChatElem.children; | 33 | const chatElems = parentChatElem.children; |
36 | for (var i = 0; i < chatElems.length; i++) { | 34 | for (let i = 0; i < chatElems.length; i++) { |
37 | var chatElem = chatElems[i]; | 35 | const chatElem = chatElems[i]; |
38 | var unreadElem = chatElem.children[0].children[0].children[1].children[1].children[1]; | 36 | const unreadElem = chatElem.children[0].children[0].children[1].children[1].children[1]; |
39 | 37 | ||
40 | var countValue = parseInt(unreadElem.textContent) || 0; // Returns 0 in case of isNaN | 38 | const countValue = parseInt(unreadElem.textContent) || 0; // Returns 0 in case of isNaN |
41 | 39 | ||
42 | if (unreadElem.querySelectorAll("[data-icon=muted]").length === 0) { | 40 | if (unreadElem.querySelectorAll('[data-icon=muted]').length === 0) { |
43 | count += countValue; | 41 | count += countValue; |
44 | } else { | 42 | } else { |
45 | indirectCount += countValue; | 43 | indirectCount += countValue; |