PageSourceSearch

https://metawilo.com/sw.js

js metawilo.com collected 2026-10-08 13:28:30 UTC 1,181 bytes, 35 lines download raw bytes

1// 台灣罪犯圖鑑 網頁 App 背景程式
2// 原則:有網路一律抓最新版(站長常更新,不能讓人看到舊卡片);只有斷網時才用上次存下的頁面。
3const CACHE = 'metawilo-v1';
4
5self.addEventListener('install', () => self.skipWaiting());
6
7self.addEventListener('activate', (event) => {
8  event.waitUntil(
9    caches.keys()
10      .then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k))))
11      .then(() => self.clients.claim())
12  );
13});
14
15self.addEventListener('fetch', (event) => {
16  const req = event.request;
17  if (req.method !== 'GET') return;
18  const url = new URL(req.url);
19  if (url.origin !== self.location.origin) return;   // 字型、臉書等外部資源不處理
20
21  // 只處理頁面本身(首頁、案件頁、延伸閱讀);圖片等照常走網路
22  if (req.mode !== 'navigate') return;
23
24  event.respondWith(
25    fetch(req)
26      .then((res) => {
27        if (res.ok) {
28          const copy = res.clone();
29          caches.open(CACHE).then((c) => c.put(req, copy));
30        }
31        return res;
32      })
33      .catch(() => caches.match(req).then((hit) => hit || caches.match('/')))
34  );
35});

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.