PageSourceSearch

https://0697.ai/sw.produce.min.2.1.6.js

js 0697.ai collected 2026-10-05 11:46:50 UTC 4,700 bytes, 127 lines download raw bytes

1(() => {
2  "use strict";
3  importScripts(
4    './sw/sw-moudules.utils.js', // 工具函数
5    './sw/sw-moudules.domain.js', // 域名切换相关
6    './sw/sw-moudules.page.js', // 域名切换页面
7    './sw/sw-moudules.webpush.js', // 极光相关函数
8  );
9
10
11  self.addEventListener("install", event => {
12    event.waitUntil(self.skipWaiting());
13  }),
14
15    self.addEventListener("fetch", event => {
16      // 避免处理非同源请求
17      const url = new URL(event.request.url);
18      if (event.request.method !== 'GET' || url.origin !== self.location.origin) return;
19      if (url.pathname.includes('/api/') || url.pathname.includes('.')) { // 避免处理 api 请求和静态资源请求
20        return;
21      }
22      // 处理c域名
23      event.respondWith(
24        (async () => {
25          try {
26            const networkResponse = await fetch(event.request);
27            if (networkResponse.ok) {
28              return networkResponse;
29            }
30            // 如果网络响应不正常,抛出错误进入 catch 块
31            throw new Error('network error when fetching request');
32          } catch (err) {
33            // 记录错误(替换为你自己的错误日志函数)
34            console.error('请求失败:', err);
35    
36            if (!navigator.onLine) {
37              // 离线:返回自定义离线页面
38              return new Response(
39                '<h1>navigator is offLine,Please check the device network</h1>',
40                {
41                  status: 503,
42                  headers: { 'Content-Type': 'text/html' },
43                }
44              );
45            } else {
46              // 在线:生成并缓存动态页面
47              const htmlContent = createDynamicOnlinePage(buildStringMap());
48              // 异步缓存响应
49              try {
50                const cache = await caches.open('online-page');
51                const cacheRequest = new Request(self.location.origin + '/sw-page.html');
52                await cache.put(cacheRequest, htmlContent.clone());
53              } catch (cacheError) {
54                console.error('缓存失败:', cacheError);
55              }
56    
57              // 优先返回新生成的响应,或从缓存中获取
58              const cacheRequest = new Request(self.location.origin + '/sw-page.html');
59              const cachedResponse = await caches.match(cacheRequest);
60              console.log(cachedResponse,'cachedResponse')
61              return cachedResponse || htmlContent;
62            }
63          }
64        })()
65      );
66    }),
67    self.addEventListener("message", async function (t) {
68      const e = t.data || { code: 0, msg: {} };
69      var n;
70      9999 === e.code &&
71        ((n = e.msg),
72          s("https://webpushstat.api.engagelab.cc/v4/web/report", n.data, {
73            headers: { Authorization: n.Authorization },
74          })),
75        6666 === t.data.code &&
76        a(
77          [{ type: "msg_status", msg_id: e.msg.msg_id, result: 3018 }],
78          e.msg
79        );
80    }),
81    self.addEventListener("notificationclick", function (t) {
82      const e = t.notification.data;
83      if (e) {
84        const s = "MTPush" === e.engagelab_mesg_type ? "MTPush" : "W3Push";
85        a(
86          [{ type: "msg_status", msg_id: t.notification.tag, result: 3002 }],
87          e,
88          s
89        );
90        let n = null == e ? void 0 : e.engagelab_url;
91        t.action &&
92          e.engagelab_action_urls &&
93          e.engagelab_action_urls[t.action] &&
94          (n = e.engagelab_action_urls[t.action]),
95          n &&
96          (n.includes('redirect=') ? n = self.location.origin + n.split('redirect=')[1] + '?timestamp=' + new Date().getTime() :
97            n = self.location.origin, console.log('跳转页面:', n), t.notification.close(), t.waitUntil(self.clients.openWindow(n)));
98      }
99    }),
100    self.addEventListener("push", function (t) {
101      if (!t.data) return;
102      const e = t.data.json();
103      var s;
104      if (e.locationTestDempWebPush52755665)
105        self.registration.showNotification(e.title, e);
106      else if (
107        (a([{ type: "msg_status", msg_id: e.tag, result: 3001 }], e.data),
108          self.clients.matchAll().then((t) => {
109            t &&
110              t.length &&
111              t.forEach((t) => {
112                t.postMessage(e);
113              });
114          }),
115          (s = e.data.ntf_or_msg) && (1 === s || 3 === s))
116      ) {
117        a([{ type: "msg_status", msg_id: e.tag, result: 3018 }], e.data);
118        const s = self.registration.showNotification(e.title, e);
119        t.waitUntil(s);
120      }
121    }
122    );
123  self.addEventListener("activate", event => {
124    event.waitUntil(self.clients.claim());
125  });
126})();
127

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.