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

View File

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