aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/whatsapp
diff options
context:
space:
mode:
authorLibravatar Vijay A <avijayr@protonmail.com>2021-07-31 15:28:23 +0530
committerLibravatar Vijay A <avijayr@protonmail.com>2021-07-31 15:28:23 +0530
commit97697e3d069972844b2912a93022f4a4904a40d6 (patch)
tree53faff30fbac9d72042f593dfe1c547809f4f121 /recipes/whatsapp
parentAllow any url in the custom-service to allow for sites like 'http://translate... (diff)
downloadferdium-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')
-rw-r--r--recipes/whatsapp/index.js36
-rw-r--r--recipes/whatsapp/webview.js26
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"; 1module.exports = (Franz) => class Messenger extends Franz {
2 overrideUserAgent() {
3 return window.navigator.userAgent.replace(/(Ferdi|Electron)\/\S+( \([^)]+\))?/g, '').trim();
4 }
2 5
3module.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
3const { 1const {
4 remote 2 remote,
5} = require('electron'); 3} = require('electron');
6 4
7const path = require('path'); 5const path = require('path');
8 6
9const webContents = remote.getCurrentWebContents(); 7const webContents = remote.getCurrentWebContents();
10const { 8const {
11 session 9 session,
12} = webContents; 10} = webContents;
13window.addEventListener('beforeunload', async () => { 11window.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
29module.exports = Franz => { 27module.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;