1self.addEventListener('install', () => { 2 self.skipWaiting(); 3}); 4 5self.addEventListener('activate', (event) => { 6 event.waitUntil(self.clients.claim()); 7}); 8 9self.addEventListener('push', (event) => { 10 if (!event.data) { 11 return; 12 } 13 14 let payload; 15 16 try { 17 payload = event.data.json(); 18 } catch (error) { 19 payload = { title: 'DOOMSCROLLR', body: event.data.text() }; 20 } 21 22 const notification = payload.notification || payload; 23 const title = notification.title || 'DOOMSCROLLR'; 24 const body = notification.body || notification.message || 'New activity on your DOOMSCROLLR account.'; 25 const icon = notification.icon || '/images/DOOMSCROLLR-Mark.png'; 26 const data = notification.data || payload.data || {}; 27 28 event.waitUntil( 29 self.registration.showNotification(title, { 30 body, 31 icon, 32 data, 33 badge: '/images/DOOMSCROLLR-Mark.png', 34 tag: data.type || 'doomscrollr', 35 renotify: true, 36 }) 37 ); 38}); 39 40self.addEventListener('notificationclick', (event) => { 41 event.notification.close(); 42 43 const targetUrl = event.notification.data?.url || '/dashboard'; 44 45 event.waitUntil( 46 self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then((clientList) => { 47 for (const client of clientList) { 48 if ('focus' in client) { 49 const url = new URL(client.url); 50 if (url.pathname === new URL(targetUrl, self.location.origin).pathname) { 51 return client.focus(); 52 } 53 } 54 } 55 56 if (self.clients.openWindow) { 57 return self.clients.openWindow(targetUrl); 58 } 59 60 return undefined; 61 }) 62 ); 63}); 64
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.