simple_fetch_worker.js (379B)
1 // A simple worker script that forward intercepted url to the controlled window. 2 3 function responseMsg(msg) { 4 self.clients 5 .matchAll({ 6 includeUncontrolled: true, 7 type: "window", 8 }) 9 .then(clients => { 10 if (clients && clients.length) { 11 clients[0].postMessage(msg); 12 } 13 }); 14 } 15 16 onfetch = function (e) { 17 responseMsg(e.request.url); 18 };