diff options
author | 2019-12-20 19:22:21 +0100 | |
---|---|---|
committer | 2019-12-20 19:22:21 +0100 | |
commit | a54d5cfa8564ee77f1a08972edb1f4bdfe4248a4 (patch) | |
tree | fb19d5c6cb80005059b456e4ba7ce4710f388b5f /uncompressed/android-messages/webview.js | |
parent | #15 Add mastodon recipe (diff) | |
parent | Add Zimbra recipe (diff) | |
download | ferdium-recipes-a54d5cfa8564ee77f1a08972edb1f4bdfe4248a4.tar.gz ferdium-recipes-a54d5cfa8564ee77f1a08972edb1f4bdfe4248a4.tar.zst ferdium-recipes-a54d5cfa8564ee77f1a08972edb1f4bdfe4248a4.zip |
Merge branch 'master' of https://github.com/getferdi/recipes
Diffstat (limited to 'uncompressed/android-messages/webview.js')
-rw-r--r-- | uncompressed/android-messages/webview.js | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/uncompressed/android-messages/webview.js b/uncompressed/android-messages/webview.js index 414a902..7c8e004 100644 --- a/uncompressed/android-messages/webview.js +++ b/uncompressed/android-messages/webview.js | |||
@@ -1,10 +1,47 @@ | |||
1 | "use strict"; | 1 | "use strict"; |
2 | 2 | ||
3 | module.exports = Franz => { | 3 | const { |
4 | remote | ||
5 | } = require('electron'); | ||
6 | |||
7 | const webContents = remote.getCurrentWebContents(); | ||
8 | const { | ||
9 | session | ||
10 | } = webContents; | ||
11 | setTimeout(() => { | ||
12 | const elem = document.querySelector('#af-error-container'); | ||
13 | |||
14 | if (elem && elem.innerText.toLowerCase().includes('the requested url was not found on this server')) { | ||
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, settings) => { | ||
4 | function getMessages() { | 35 | function getMessages() { |
5 | const messages = document.querySelectorAll('.text-content.unread').length; | 36 | const messages = document.querySelectorAll('.text-content.unread').length; |
6 | Franz.setBadge(messages); | 37 | Franz.setBadge(messages); |
7 | } | 38 | } |
8 | 39 | ||
40 | if (settings.isDarkModeEnabled) { | ||
41 | localStorage.setItem('dark_mode_enabled', 'true'); | ||
42 | } else { | ||
43 | localStorage.setItem('dark_mode_enabled', 'false'); | ||
44 | } | ||
45 | |||
9 | Franz.loop(getMessages); | 46 | Franz.loop(getMessages); |
10 | }; \ No newline at end of file | 47 | }; \ No newline at end of file |