PageSourceSearch

https://bitcoinnews.io/sw.js

js bitcoinnews.io collected 2026-10-06 05:24:20 UTC 1,383 bytes, 50 lines download raw bytes

1const CACHE_VERSION = "bn-shell-v3";
2const SHELL = ["/", "/dashboard", "/offline"];
3
4self.addEventListener("install", (event) => {
5  event.waitUntil(
6    caches.open(CACHE_VERSION).then((cache) => cache.addAll(SHELL))
7  );
8  self.skipWaiting();
9});
10
11self.addEventListener("activate", (event) => {
12  event.waitUntil(
13    caches
14      .keys()
15      .then((keys) =>
16        Promise.all(keys.filter((k) => k !== CACHE_VERSION).map((k) => caches.delete(k)))
17      )
18  );
19  self.clients.claim();
20});
21
22self.addEventListener("fetch", (event) => {
23  const url = new URL(event.request.url);
24
25  if (url.pathname.startsWith("/api/")) return;
26  if (event.request.method !== "GET") return;
27  if (url.origin !== self.location.origin) return;
28
29  event.respondWith(
30    fetch(event.request)
31      .then((res) => {
32        if (res.ok) {
33          const copy = res.clone();
34          caches.open(CACHE_VERSION).then((cache) => cache.put(event.request, copy));
35        }
36        return res;
37      })
38      .catch(() =>
39        caches.match(event.request).then((cached) => {
40          if (cached) return cached;
41          if (event.request.mode === "navigate") return caches.match("/offline");
42          return new Response("", { status: 503, statusText: "Offline" });
43        })
44      )
45  );
46});
47
48self.addEventListener("message", (event) => {
49  if (event.data === "skipWaiting") self.skipWaiting();
50});

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.