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.