diff options
author | Bennett <hello@vantezzen.io> | 2020-09-22 20:56:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-22 19:56:48 +0100 |
commit | 6f5e4a00588aefdda7a5a1cfe70935870e7e234a (patch) | |
tree | 9e29aa7aa0620a1a4a968ff8739b4b8ba96791a9 /uncompressed/whatsapp/webview.js | |
parent | Updated logos for Outlook/OWA (diff) | |
download | ferdium-recipes-6f5e4a00588aefdda7a5a1cfe70935870e7e234a.tar.gz ferdium-recipes-6f5e4a00588aefdda7a5a1cfe70935870e7e234a.tar.zst ferdium-recipes-6f5e4a00588aefdda7a5a1cfe70935870e7e234a.zip |
Unpack recipes and update recipes icons (#292)
Co-authored-by: Amine Mouafik <amine@mouafik.fr>
Diffstat (limited to 'uncompressed/whatsapp/webview.js')
-rw-r--r-- | uncompressed/whatsapp/webview.js | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/uncompressed/whatsapp/webview.js b/uncompressed/whatsapp/webview.js deleted file mode 100644 index 263c543..0000000 --- a/uncompressed/whatsapp/webview.js +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | "use strict"; | ||
2 | |||
3 | const { | ||
4 | remote | ||
5 | } = require('electron'); | ||
6 | |||
7 | const path = require('path'); | ||
8 | |||
9 | const webContents = remote.getCurrentWebContents(); | ||
10 | const { | ||
11 | session | ||
12 | } = webContents; | ||
13 | window.addEventListener('beforeunload', async () => { | ||
14 | try { | ||
15 | session.flushStorageData(); | ||
16 | session.clearStorageData({ | ||
17 | storages: ['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb'] | ||
18 | }); | ||
19 | const registrations = await window.navigator.serviceWorker.getRegistrations(); | ||
20 | registrations.forEach(r => { | ||
21 | r.unregister(); | ||
22 | console.log('ServiceWorker unregistered'); | ||
23 | }); | ||
24 | } catch (err) { | ||
25 | console.err(err); | ||
26 | } | ||
27 | }); | ||
28 | |||
29 | module.exports = Franz => { | ||
30 | const getMessages = function getMessages() { | ||
31 | const elements = document.querySelectorAll("[class=_31gEB]"); | ||
32 | var count = 0; | ||
33 | var indirectCount = 0; | ||
34 | |||
35 | for (var i = 0; i < elements.length; i += 1) { | ||
36 | var countValue = parseInt(elements[i].textContent || '0', 10); | ||
37 | |||
38 | if (elements[i].parentNode.previousElementSibling === null || elements[i].parentNode.previousElementSibling.querySelectorAll("[data-icon=muted]").length === 0) { | ||
39 | count += countValue; | ||
40 | } | ||
41 | else { | ||
42 | indirectCount += countValue; | ||
43 | } | ||
44 | } | ||
45 | |||
46 | Franz.setBadge(count, indirectCount); | ||
47 | }; | ||
48 | |||
49 | Franz.injectCSS(path.join(__dirname, 'service.css')); | ||
50 | Franz.loop(getMessages); | ||
51 | }; | ||