diff options
author | Jonathan Winter <14960780+jhwinter@users.noreply.github.com> | 2020-09-19 14:30:27 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-19 19:30:27 +0100 |
commit | 6ecbbff345eed6e252ea8b2567176464873cb531 (patch) | |
tree | b8be0c24fc98d4582936dcc1c36ce716607c302a /uncompressed/meetfranz-lastpass/webview.js | |
parent | Update Jitsi Meet to allow self-hosted versions and fix UA string (#167) (diff) | |
download | ferdium-recipes-6ecbbff345eed6e252ea8b2567176464873cb531.tar.gz ferdium-recipes-6ecbbff345eed6e252ea8b2567176464873cb531.tar.zst ferdium-recipes-6ecbbff345eed6e252ea8b2567176464873cb531.zip |
Add LastPass recipe (#290)
Diffstat (limited to 'uncompressed/meetfranz-lastpass/webview.js')
-rw-r--r-- | uncompressed/meetfranz-lastpass/webview.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/uncompressed/meetfranz-lastpass/webview.js b/uncompressed/meetfranz-lastpass/webview.js new file mode 100644 index 0000000..4fdd007 --- /dev/null +++ b/uncompressed/meetfranz-lastpass/webview.js | |||
@@ -0,0 +1,50 @@ | |||
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 | setTimeout(() => { | ||
14 | if (document.querySelector('body').innerHTML.includes('Google Chrome 36+')) { | ||
15 | window.location.reload(); | ||
16 | } | ||
17 | }, 1000); | ||
18 | window.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 | |||
34 | module.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 | ||