1/* eslint-disable no-undef */ 2importScripts('https://www.gstatic.com/firebasejs/9.10.0/firebase-app-compat.js'); 3importScripts('https://www.gstatic.com/firebasejs/9.10.0/firebase-messaging-compat.js'); 4 5const config = new URL(location).searchParams.get('config'); 6 7firebase.initializeApp(JSON.parse(config)); 8 9const messaging = firebase.messaging(); 10 11self.addEventListener('install', () => { 12 self.skipWaiting(); 13}); 14 15self.onnotificationclick = (event) => { 16 event.notification.close(); 17 18 event.waitUntil( 19 clients 20 .matchAll({ includeUncontrolled: true, type: 'window' }) 21 .then((clientList) => { 22 for (const client of clientList) { 23 if (client.url === location.origin + '/notification' && 'focus' in client) { 24 return client.focus(); 25 } 26 } 27 if (clients.openWindow) { 28 return clients.openWindow('/notification'); 29 } 30 }), 31 ); 32}; 33 34messaging.onBackgroundMessage((payload) => { 35 const notificationTitle = payload.data.Title; 36 const notificationOptions = { 37 body: payload.data.Body, 38 }; 39 40 self.registration.showNotification(notificationTitle, notificationOptions); 41});
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.