blob: 55be389618ea9ace19296e56c377ed161b04996b [file] [log] [blame]
addEventListener("message", async (e) => {
if (!e.data.port)
return;
self.port = e.data.port;
self.port.postMessage("ok");
});
addEventListener("fetch", async (e) => {
if (e.request.url.includes("clone")) {
const cloned = e.request.clone();
e.respondWith(fetch(e.request.clone()));
if (self.port)
self.port.postMessage(await cloned.text());
return;
}
e.respondWith(fetch(e.request));
});