apparently chrome is a shit browser

This commit is contained in:
2026-07-15 16:30:07 +02:00
parent ac7bb2e699
commit f6f47fcbbe
2 changed files with 33 additions and 7 deletions

View File

@@ -618,10 +618,33 @@
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js').then((registration) => {
window.f0ckDebug('ServiceWorker registration successful with scope: ', registration.scope);
}, (err) => {
window.f0ckDebug('ServiceWorker registration failed: ', err);
navigator.serviceWorker.getRegistrations().then((registrations) => {
let rootFound = false;
let scopedFound = false;
for (let r of registrations) {
try {
const scopePath = new URL(r.scope).pathname;
if (scopePath === '/') {
r.unregister().then(() => {
console.log('[SW] Root ServiceWorker cleaned up.');
});
rootFound = true;
} else if (scopePath === '/api/v2/export/') {
scopedFound = true;
}
} catch (e) {}
}
// Register the scoped service worker so that exports still work on settings page
// without intercepting normal site requests.
if (!scopedFound || rootFound) {
navigator.serviceWorker.register('/sw.js', { scope: '/api/v2/export/' }).then((registration) => {
window.f0ckDebug('ServiceWorker registered with scoped path: ', registration.scope);
}).catch((err) => {
window.f0ckDebug('ServiceWorker registration failed: ', err);
});
}
});
});
}