aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/lastpass/webview.js
diff options
context:
space:
mode:
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