permission-sw.js (516B)
1 importScripts("helpers.js"); 2 3 // Send the result to the clients of this service worker. 4 async function ping(message) { 5 const clients = await self.clients.matchAll({ includeUncontrolled: true }); 6 for (const client of clients) { 7 client.postMessage(message); 8 } 9 for (const n of await registration.getNotifications()) { 10 n.close(); 11 } 12 } 13 14 (async () => { 15 await untilActivate(); 16 17 const shown = await registration.showNotification("serviceworker").then(() => true, err => false); 18 ping({ shown }); 19 })();