Revert "apparently chrome is a shit browser"

This reverts commit f6f47fcbbe.
This commit is contained in:
2026-07-15 16:32:01 +02:00
parent f6f47fcbbe
commit 8b003c4d57
2 changed files with 7 additions and 33 deletions

View File

@@ -1815,12 +1815,9 @@
const streamUrl = `/api/v2/export/stream?id=${streamId}&filename=${encodeURIComponent(suggestedFileName)}`;
const worker = new Worker(URL.createObjectURL(new Blob([workerCode], { type: 'application/javascript' })));
// The SW must be controlling this page or be active to intercept /api/v2/export/stream.
let sw = navigator.serviceWorker.controller;
if (!sw) {
const reg = await navigator.serviceWorker.getRegistration('/api/v2/export/');
sw = reg ? reg.active : null;
}
// The SW must be controlling this page to intercept /api/v2/export/stream.
// .controller is null after hard refresh — in that case, reload once.
const sw = navigator.serviceWorker.controller;
if (!sw) {
worker.terminate();
exportStatusMsg.textContent = 'Reloading to activate Service Worker...';

View File

@@ -618,33 +618,10 @@
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
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);
});
}
navigator.serviceWorker.register('/sw.js').then((registration) => {
window.f0ckDebug('ServiceWorker registration successful with scope: ', registration.scope);
}, (err) => {
window.f0ckDebug('ServiceWorker registration failed: ', err);
});
});
}