1importScripts('https://www.gstatic.com/firebasejs/10.1.0/firebase-app-compat.js'); 2importScripts('https://www.gstatic.com/firebasejs/10.1.0/firebase-messaging-compat.js'); 3 4const params = new URL(self.location.href).searchParams; 5const config = JSON.parse(params.get('config') || '{}'); 6 7if (config.apiKey) { 8 firebase.initializeApp(config); 9 firebase.messaging(); 10} 11 12self.addEventListener('install', () => self.skipWaiting()); 13self.addEventListener('activate', e => e.waitUntil(self.clients.claim())); 14 15self.addEventListener('notificationclick', function (event) { 16 event.notification.close(); 17 const data = event.notification.data || {}; 18 const raw = data.url || (data.FCM_MSG && data.FCM_MSG.data && data.FCM_MSG.data.url) || '/'; 19 const targetUrl = new URL(raw, self.location.origin).href; 20 21 event.waitUntil( 22 clients.matchAll({ type: 'window', includeUncontrolled: true }).then(function (list) { 23 for (const c of list) { 24 if (c.url === targetUrl && 'focus' in c) return c.focus(); 25 } 26 return clients.openWindow ? clients.openWindow(targetUrl) : null; 27 }) 28 ); 29});
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.