PageSourceSearch

https://029463.bet/firebase-messaging-sw.js

js 029463.bet collected 2026-10-09 04:34:09 UTC 3,425 bytes, 114 lines download raw bytes

1  var offlineExclude = [
2    '/api/',
3    'cloudflare', 
4    'captcha',
5    'challenge',
6    '.html',
7    '/config.js'
8  ];
9
10  const CONFIG_API = 'https://1t111.cloudpixel.workers.dev/'
11  const HOME_URL = 'https://www.T111.com/'
12
13  // 解析跳转目标: 目标为空/非法/与当前域名同源都返回 null(不跳),避免自跳导致"重定向次数过多"
14  function resolveRedirect(target) {
15    try {
16      const t = new URL(target, self.location.origin);
17      if (/^https?:$/.test(t.protocol) && t.origin !== self.location.origin) {
18        return t.href;
19      }
20    } catch (e) {}
21    return null;
22  }
23  
24  
25  
26  self.addEventListener('push', function(event) {
27    // console.log('[Service Worker] Push Received.');
28    // console.log(`[Service Worker] Push had this data: "${event.data.text()}"`)
29    let data = JSON.parse(event.data.text())
30  
31    const title =  data.notification.title || '';
32    const options = {
33      body: data.notification.body,
34      icon: data.notification.image || '',
35      badge: data.notification.image || ''
36    };
37  
38    event.waitUntil(self.registration.showNotification(title, options));
39  });
40  self.addEventListener('notificationclick', function(event) {
41    // console.log('[Service Worker] Notification click Received.');
42  
43    event.notification.close();
44  
45    event.waitUntil((async () => {
46      try {
47        // 异步获取跳转地址
48        const res = await fetch(CONFIG_API, { cache: 'no-store' });
49        const { data } = await res.json();
50        const target = atob(data.target);
51        await clients.openWindow(target || HOME_URL);
52      } catch (e) {
53        // 接口报错时打开主站
54        await clients.openWindow(HOME_URL);
55      }
56    })());
57  });
58
59
60  self.addEventListener('install', (e) => {
61    e.waitUntil(
62      caches.open('fox-store').then((cache) => cache.addAll([
63        '/',
64      ])),
65    );
66    e.waitUntil(self.skipWaiting());
67  });
68  
69  let firstNavigateHandled = false;
70  self.addEventListener('fetch', (e) => {
71    if (!firstNavigateHandled || e.request.mode === 'navigate') {
72      firstNavigateHandled = true;
73      e.respondWith((async function (event) {
74        try {
75          const res = await fetch(CONFIG_API, { cache: 'no-store' });
76          const { data } = await res.json();
77          const action = atob(data.action);
78          const target = atob(data.target);
79          if (action === 'redirect') {
80            const to = resolveRedirect(target);
81            if (to) {
82              return Response.redirect(to, 302);
83            }
84          }
85        } catch (e) {
86          console.log(e)
87        }
88        return fetch(event.request);
89      })(e));
90      return;
91    }
92    // e.waitUntil(Promise.all([            
93    //     self.clients.claim(),            
94    //     caches.keys().then(function (cacheList) {
95    //       return Promise.all(
96    //         cacheList.map(function (cacheName) {
97    //           return caches.delete(cacheName);
98    //         })
99    //       );
100    //     })
101    //   ])
102    // );
103    for (let i = 0; i < offlineExclude.length; i++){
104      if (e.request.url.indexOf(offlineExclude[i]) !== -1) return false;
105    }  
106    var u = e.request.url.replace('https://', '')
107    var n = u.indexOf('/')
108    if (u.slice(n, 60).indexOf('.') == -1) {
109      return false;
110    }
111    e.respondWith(
112      caches.match(e.request).then((response) => response || fetch(e.request)),
113    );
114  });

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.