blob: 763d55764a92d0727a2d4dc338d3a9eb5234766f (
plain)
1
2
3
4
5
6
7
8
9
10
11
|
self.addEventListener("fetch", async e => {
if (e.request.url.endsWith("ping"))
e.respondWith(new Response('pong'));
else if (e.request.url.endsWith("client")) {
e.respondWith((async () => {
const client = await clients.get(e.clientId);
const clientInfo = client ? {id: e.clientId, visibilityState: client.visibilityState, focused: client.focused} : null;
return new Response(JSON.stringify({clientInfo}), {headers: {'Content-Type': 'application/json'}});
})());
}
});
|