1 addEventListener("activate", event => {
2 event.waitUntil(self.registration.navigationPreload.enable());
5 async function post_to_page(data) {
6 let cs = await self.clients.matchAll();
7 for (const client of cs) {
8 client.postMessage(data);
12 addEventListener("fetch", event => {
13 if (event.request.url.includes("navigationPreload_page.html")) {
15 new Response("<!DOCTYPE html>", {
16 headers: { "Content-Type": "text/html; charset=utf-8" },
22 let preloadResponse = await event.preloadResponse;
23 let text = await preloadResponse.text();
24 await post_to_page(text);