main
html 67 lines 2.4 KB
Raw
1 <!DOCTYPE html>
2 <html lang="en" data-safe-theme="dark">
3
4 <head>
5 <meta charset="UTF-8">
6 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
7 <title>Agent Zero — Safe mode</title>
8 <link rel="icon" href="data:,">
9 <script>
10 try {
11 if (localStorage.getItem("darkMode") === "false") document.documentElement.dataset.safeTheme = "light"
12 } catch (_) {}
13 </script>
14 <style>
15 html, body { width: 100%; height: 100%; margin: 0; }
16 html { background: #131313; color: #fff; }
17 html[data-safe-theme="light"] { background: #fafafa; color: #111; }
18 body { display: grid; place-items: center; font-family: system-ui, sans-serif; }
19 main { display: grid; justify-items: center; gap: .75rem; padding: 2rem; text-align: center; }
20 strong { font-size: 1.15rem; }
21 p { margin: 0; color: #aaa; }
22 html[data-safe-theme="light"] p { color: #666; }
23 </style>
24 </head>
25
26 <body>
27 <main role="status" aria-live="polite">
28 <strong>Starting Agent Zero in safe mode</strong>
29 <p>Disabling the offline worker before loading the application…</p>
30 </main>
31
32 <script>
33 (() => {
34 const DIRECT_PARAMETER = "__direct"
35 const FALLBACK_TIMEOUT_MS = 3000
36 let navigationStarted = false
37
38 const navigateToApp = () => {
39 if (navigationStarted) return
40 navigationStarted = true
41 const target = new URL(location.href)
42 target.pathname = "/safe"
43 target.searchParams.set(DIRECT_PARAMETER, "1")
44 location.replace(target.href)
45 }
46
47 const fallbackTimer = setTimeout(navigateToApp, FALLBACK_TIMEOUT_MS)
48
49 const disableServiceWorkers = async () => {
50 if (!("serviceWorker" in navigator)) return
51 const registrations = await navigator.serviceWorker.getRegistrations()
52 await Promise.allSettled(
53 registrations.map((registration) => registration.unregister()),
54 )
55 }
56
57 disableServiceWorkers()
58 .catch((error) => console.warn("Unable to disable service workers.", error))
59 .finally(() => {
60 clearTimeout(fallbackTimer)
61 navigateToApp()
62 })
63 })()
64 </script>
65 </body>
66
67 </html>