PageSourceSearch

https://undress.app/firebase-messaging-sw.js

js undress.app collected 2026-09-28 11:11:05 UTC 3,210 bytes, 88 lines download raw bytes

1const allowedHost =
2  self.location.hostname.endsWith('undress.app') ||
3  self.location.hostname === 'localhost' ||
4  self.location.hostname.endsWith('vercel.app')
5
6if (!allowedHost) {
7  console.warn('ServiceWorker initialization skipped - wrong domain')
8} else {
9
10importScripts('https://www.gstatic.com/firebasejs/11.3.1/firebase-app-compat.js')
11importScripts('https://www.gstatic.com/firebasejs/11.3.1/firebase-messaging-compat.js')
12
13firebase.initializeApp({
14  apiKey: 'AIzaSyBBHj64MosNOWWZnlJffIyQe5p1W0X3h0s',
15  authDomain: 'u-projects-5209d.firebaseapp.com',
16  projectId: 'u-projects-5209d',
17  storageBucket: 'u-projects-5209d.firebasestorage.app',
18  messagingSenderId: '449186702793',
19  appId: '1:449186702793:web:b81ab38a7d2ce19b987418',
20})
21
22const messaging = firebase.messaging()
23
24messaging.onBackgroundMessage((payload) => {
25  const { title, body, avatar_url, action, messageId } = payload.data || {}
26
27  if (title && body) {
28    self.registration.showNotification(title, {
29      body,
30      icon: avatar_url || './icon-192-192.png',
31      data: { action },
32      tag: messageId || 'default',
33    })
34  }
35})
36
37// action может быть как обычной строкой-путём (старый формат), так и
38// строкой с JSON внутри ({"type":"open_promocode","issue_id":"…"}) — если
39// это второе, ведём по типу действия, иначе — как раньше, на сам путь.
40function resolveActionPath(action) {
41  if (!action) return '/edit'
42
43  try {
44    const parsed = JSON.parse(action)
45
46    if (parsed && typeof parsed === 'object' && parsed.type === 'open_promocode') {
47      // issue_id подсвечивает конкретную карточку на странице (если она
48      // ещё жива — могла сгореть между отправкой пуша и тапом, тогда
49      // просто открывается список, без ошибки). Держим в синхроне с
50      // resolveActionHref в push-notifications.provider.tsx.
51      return parsed.issue_id
52        ? '/promocodes?issueId=' + encodeURIComponent(parsed.issue_id)
53        : '/promocodes'
54    }
55
56    // Валидный JSON, но не наш формат действия (число, null, объект без
57    // type и т.п.) — не путь, отдавать его как return action ниже нельзя.
58    return '/edit'
59  } catch {
60    // Не JSON — значит это старый формат (просто путь), падаем на него ниже.
61  }
62
63  return action
64}
65
66self.addEventListener('notificationclick', function (event) {
67  event.notification.close()
68
69  const action = event.notification.data?.action
70  const url = self.location.origin + resolveActionPath(action)
71
72  event.waitUntil(
73    clients
74      .matchAll({ type: 'window', includeUncontrolled: true })
75      .then(function (clientList) {
76        for (const client of clientList) {
77          if (client.url === url && 'focus' in client) {
78            return client.focus()
79          }
80        }
81        if (clients.openWindow) {
82          return clients.openWindow(url)
83        }
84      })
85  )
86})
87
88}

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.