aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/lastpass/webview.js
diff options
context:
space:
mode:
authorLibravatar Bennett <hello@vantezzen.io>2020-09-22 20:56:48 +0200
committerLibravatar GitHub <noreply@github.com>2020-09-22 19:56:48 +0100
commit6f5e4a00588aefdda7a5a1cfe70935870e7e234a (patch)
tree9e29aa7aa0620a1a4a968ff8739b4b8ba96791a9 /recipes/lastpass/webview.js
parentUpdated logos for Outlook/OWA (diff)
downloadferdium-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 'recipes/lastpass/webview.js')
-rw-r--r--recipes/lastpass/webview.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/recipes/lastpass/webview.js b/recipes/lastpass/webview.js
new file mode 100644
index 0000000..4fdd007
--- /dev/null
+++ b/recipes/lastpass/webview.js
@@ -0,0 +1,50 @@
1"use strict";
2
3const {
4 remote
5} = require('electron');
6
7const path = require('path');
8
9const webContents = remote.getCurrentWebContents();
10const {
11 session
12} = webContents;
13setTimeout(() => {
14 if (document.querySelector('body').innerHTML.includes('Google Chrome 36+')) {
15 window.location.reload();
16 }
17}, 1000);
18window.addEventListener('beforeunload', async () => {
19 try {
20 session.flushStorageData();
21 session.clearStorageData({
22 storages: ['appcache', 'serviceworkers', 'cachestorage', 'websql', 'indexdb']
23 });
24 const registrations = await window.navigator.serviceWorker.getRegistrations();
25 registrations.forEach(r => {
26 r.unregister();
27 console.log('ServiceWorker unregistered');
28 });
29 } catch (err) {
30 console.err(err);
31 }
32});
33
34module.exports = Franz => {
35 const getMessages = function getMessages() {
36 const elements = document.querySelectorAll('.CxUIE, .unread');
37 let count = 0;
38
39 for (let i = 0; i < elements.length; i += 1) {
40 if (elements[i].querySelectorAll('*[data-icon="muted"]').length === 0) {
41 count += 1;
42 }
43 }
44
45 Franz.setBadge(count);
46 };
47
48 Franz.injectCSS(path.join(__dirname, 'service.css'));
49 Franz.loop(getMessages);
50}; \ No newline at end of file