Spaces:
Running
Running
Download sw.js from mrhappynice/bookmarklets: direct link, hf CLI and curl.
- Browser
- Download file 768 Bytes
-
https://huggingface.co/spaces/mrhappynice/bookmarklets/resolve/main/sw.js
- Command line
-
hf download hf://spaces/mrhappynice/bookmarklets/sw.js
-
curl -L -o sw.js https://huggingface.co/spaces/mrhappynice/bookmarklets/resolve/main/sw.js
768 Bytes
| const CACHE_NAME = 'bm-manager-v1'; | |
| const ASSETS = [ | |
| '/', | |
| '/index.html', | |
| '/style.css', | |
| '/script.js', | |
| '/manifest.webmanifest' | |
| ]; | |
| self.addEventListener('install', (event) => { | |
| event.waitUntil( | |
| caches.open(CACHE_NAME).then((cache) => cache.addAll(ASSETS)) | |
| ); | |
| self.skipWaiting(); | |
| }); | |
| self.addEventListener('activate', (event) => { | |
| event.waitUntil( | |
| caches.keys().then((keys) => | |
| Promise.all( | |
| keys.map((key) => { | |
| if (key !== CACHE_NAME) return caches.delete(key); | |
| }) | |
| ) | |
| ) | |
| ); | |
| self.clients.claim(); | |
| }); | |
| self.addEventListener('fetch', (event) => { | |
| if (event.request.method !== 'GET') return; | |
| event.respondWith( | |
| caches.match(event.request).then((cached) => cached || fetch(event.request)) | |
| ); | |
| }); |