PageSourceSearch

https://cbboxe.vercel.app/firebase-messaging-sw.js

js cbboxe.vercel.app collected 2026-10-03 06:22:29 UTC 2,479 bytes, 90 lines download raw bytes

1/* eslint-disable @typescript-eslint/no-unused-vars */
2/* eslint-disable no-undef */
3importScripts(
4  'https://www.gstatic.com/firebasejs/10.12.0/firebase-app-compat.js',
5)
6importScripts(
7  'https://www.gstatic.com/firebasejs/10.12.0/firebase-messaging-compat.js',
8)
9
10// Your web app's Firebase configuration
11const firebaseConfig = {
12  apiKey: 'AIzaSyA6ccEE1zB_8Ioy5gPVT1zBMDwz0jebmts',
13  authDomain: 'cbboxe-sge.firebaseapp.com',
14  projectId: 'cbboxe-sge',
15  storageBucket: 'cbboxe-sge.firebasestorage.app',
16  messagingSenderId: '392435015724',
17  appId: '1:392435015724:web:0b06b91426a947d6947189',
18  measurementId: 'G-QZ87CGDPC6'
19};
20
21firebase.initializeApp(firebaseConfig)
22
23class CustomPushEvent extends Event {
24  constructor(data) {
25    super('push')
26
27    Object.assign(this, data)
28    this.custom = true
29  }
30}
31
32/*
33 * Overrides push notification data, to avoid having 'notification' key and firebase blocking
34 * the message handler from being called
35 */
36self.addEventListener('push', (e) => {
37  // Skip if event is our own custom event
38  if (e.custom) return
39
40  // Kep old event data to override
41  const oldData = e.data
42
43  // Create a new event to dispatch, pull values from notification key and put it in data key,
44  // and then remove notification key
45  const newEvent = new CustomPushEvent({
46    data: {
47      ehheh: oldData.json(),
48      json() {
49        const newData = oldData.json()
50        newData.data = {
51          ...newData.data,
52          ...newData.notification,
53        }
54        delete newData.notification
55        return newData
56      },
57    },
58    waitUntil: e.waitUntil.bind(e),
59  })
60
61  // Stop event propagation
62  e.stopImmediatePropagation()
63
64  // Dispatch the new wrapped event
65  dispatchEvent(newEvent)
66})
67
68const messaging = firebase.messaging()
69
70messaging.onBackgroundMessage((payload) => {
71  // console.log('[firebase-messaging-sw.js] Received background message ', payload);
72
73  const { title, body, image, icon, ...restPayload } = payload.data
74  const notificationOptions = {
75    body,
76    icon: image || '/icons/firebase-logo.png', // path to your "fallback" firebase notification logo
77    data: restPayload,
78  }
79  return self.registration.showNotification(title, notificationOptions)
80})
81
82self.addEventListener('notificationclick', (event) => {
83  if (event?.notification?.data && event?.notification?.data?.link) {
84    self.clients.openWindow(event.notification.data.link)
85  }
86
87  // close notification after click
88  event.notification.close()
89})
90  

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.