aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/whatsapp/webview.js
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/whatsapp/webview.js')
-rw-r--r--recipes/whatsapp/webview.js31
1 files changed, 14 insertions, 17 deletions
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 @@
1const { remote } = require('electron');
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
7const webContents = remote.getCurrentWebContents();
8const { session } = webContents;
9
10window.addEventListener('beforeunload', async () => { 5window.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