diff options
author | 2021-07-31 15:28:23 +0530 | |
---|---|---|
committer | 2021-07-31 15:28:23 +0530 | |
commit | 97697e3d069972844b2912a93022f4a4904a40d6 (patch) | |
tree | 53faff30fbac9d72042f593dfe1c547809f4f121 /recipes/whatsapp/webview.js | |
parent | Allow any url in the custom-service to allow for sites like 'http://translate... (diff) | |
download | ferdium-recipes-97697e3d069972844b2912a93022f4a4904a40d6.tar.gz ferdium-recipes-97697e3d069972844b2912a93022f4a4904a40d6.tar.zst ferdium-recipes-97697e3d069972844b2912a93022f4a4904a40d6.zip |
Fixed eslintrc as root for this folder; Reformatted all files.
Diffstat (limited to 'recipes/whatsapp/webview.js')
-rw-r--r-- | recipes/whatsapp/webview.js | 26 |
1 files changed, 12 insertions, 14 deletions
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; |