19 lines
1.8 KiB
JavaScript
19 lines
1.8 KiB
JavaScript
// Network-only: no account records, files, tokens or API responses enter offline caches.
|
|
self.addEventListener('install', (event) => event.waitUntil(self.skipWaiting()));
|
|
self.addEventListener('activate', (event) => event.waitUntil(self.clients.claim()));
|
|
self.addEventListener('fetch', (event) => {
|
|
if (event.request.method !== 'GET' || event.request.mode !== 'navigate') return;
|
|
event.respondWith(
|
|
fetch(event.request).catch(
|
|
() =>
|
|
new Response(
|
|
'<!doctype html><html lang="ko"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>hop.</title><body style="background:#000;color:#f5f5f5;font:16px system-ui;text-align:center;padding:25vh 24px"><h1>hop.</h1><p>인터넷 연결이 필요해요.</p><p>연결한 뒤 다시 열어주세요.</p><a href="/" style="color:inherit">다시 시도</a><script>try{var l;try{l=localStorage.getItem("hop-language")}catch(e){};var m={ko:["인터넷 연결이 필요해요.","연결한 뒤 다시 열어주세요.","다시 시도"],ja:["インターネット接続が必要です。","接続してから、もう一度hop.を開いてください。","もう一度試す"],en:["An internet connection is required.","Reconnect, then open hop. again.","Try again"]};var b=(navigator.languages||[navigator.language]).map(function(x){return String(x).toLowerCase().split("-")[0]}).find(function(x){return ["ko","ja","en"].includes(x)})||"en";l=["ko","ja","en"].includes(l)?l:b;document.documentElement.lang=l;document.querySelectorAll("p").forEach(function(p,i){p.textContent=m[l][i]});document.querySelector("a").textContent=m[l][2]}catch(e){}</script></body></html>',
|
|
{
|
|
status: 503,
|
|
headers: { 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-store' },
|
|
},
|
|
),
|
|
),
|
|
);
|
|
});
|