blob: b2d5a1196de4cc1a91fcd9e52b71370d630073b6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
const _path = _interopRequireDefault(require('path'));
setTimeout(() => {
const elem = document.querySelector('#af-error-container');
// TODO: This will not work for non-english locales
if (
elem &&
elem.textContent &&
elem.textContent
.toLowerCase()
.includes('the requested url was not found on this server')
) {
window.location.reload();
}
}, 1000);
module.exports = (Ferdium, settings) => {
const getMessages = () => {
const messages = document.querySelectorAll('.text-content.unread').length;
Ferdium.setBadge(messages);
};
window.addEventListener('beforeunload', async () => {
Ferdium.clearStorageData(settings.id, {
storages: [
'appcache',
'serviceworkers',
'cachestorage',
'websql',
'indexdb',
],
});
Ferdium.releaseServiceWorkers();
});
Ferdium.loop(getMessages);
if (settings.isDarkModeEnabled) {
localStorage.setItem('dark_mode_enabled', 'true');
} else {
localStorage.setItem('dark_mode_enabled', 'false');
}
Ferdium.injectCSS(_path.default.join(__dirname, 'service.css'));
};
|