PageSourceSearch

https://radiotortosa.cat/?mg_radio_sw=1&ver=1341

js radiotortosa.cat collected 2026-10-02 12:29:46 UTC 2,943 bytes, 34 lines download raw bytes

1const CACHE_NAME='mg-radio-pwa-v1341';const PRECACHE=['https://radiotortosa.cat/mg-radio-app','https://radiotortosa.cat/mg-radio-manifest.json','https://radiotortosa.cat/noticies-app/?mg_embed=1','https://radiotortosa.cat/temps-app/?mg_embed=1','https://radiotortosa.cat/podcast-app/?mg_embed=1','https://radiotortosa.cat/notificacions/?mg_embed=1'];
2// Safari/iOS pot fallar la instal·lació del Service Worker si una sola URL del precache dona error.
3// Fem precache 'best-effort' per evitar el 'Timeout Service Worker' a iPhone.
4self.addEventListener('install',e=>{e.waitUntil((async()=>{const cache=await caches.open(CACHE_NAME);await Promise.all(PRECACHE.map(async(u)=>{try{const r=await fetch(u,{cache:'reload'});if(r&&r.ok){await cache.put(u,r.clone());}}catch(err){}}));await self.skipWaiting();})());});
5self.addEventListener('activate',e=>{e.waitUntil(caches.keys().then(keys=>Promise.all(keys.map(k=>k===CACHE_NAME?null:caches.delete(k)))).then(()=>self.clients.claim()))});
6async function networkFirst(r){try{const n=await fetch(r);const c=await caches.open(CACHE_NAME);c.put(r,n.clone());return n}catch(e){const c=await caches.open(CACHE_NAME);const a=await c.match(r);if(a)return a; if(r.mode==='navigate'){return c.match('https://radiotortosa.cat/mg-radio-app');} throw e;}}
7self.addEventListener('fetch',e=>{const r=e.request;const u=new URL(r.url);
8  if(u.pathname.indexOf('/wp-json/mg-radio/v1/nowplaying')===0 || (u.pathname.indexOf('/wp-admin/admin-ajax.php')===0 && u.searchParams.get('action')==='mg_radio_nowplaying')){
9    e.respondWith(fetch(r)); return;
10  }
11  if(r.mode==='navigate'){e.respondWith(networkFirst(r));}
12  else {e.respondWith(caches.match(r).then(res=>res||fetch(r).then(n=>caches.open(CACHE_NAME).then(c=>{c.put(r,n.clone());return n;}))))}
13});
14self.addEventListener('push',function(event){
15  event.waitUntil((async function(){
16    try{
17      const r = await fetch('/wp-json/mg-radio/v1/push/last?_ts=' + Date.now(), {cache:'no-store'});
18      const d = await r.json();
19      const title = d.title || 'Ràdio Tortosa';
20      const body = d.body || '';
21      const url = d.url || '/';
22      const opts = { body: body, icon: 'https://radiotortosa.cat/wp-content/plugins/mg-radio-pwa-1.3.46/assets/icons/icon-192.png?ver=1.3.43', badge: 'https://radiotortosa.cat/wp-content/plugins/mg-radio-pwa-1.3.46/assets/icons/icon-192.png?ver=1.3.43', data: { url: url } };
23      return self.registration.showNotification(title, opts);
24    }catch(e){ return null; }
25  })());
26});
27self.addEventListener('notificationclick', function(event){
28  event.notification.close();
29  const url = (event.notification && event.notification.data && event.notification.data.url) || '/';
30  event.waitUntil(clients.matchAll({type:'window', includeUncontrolled:true}).then(list=>{
31    for(const c of list){ if('focus' in c){ c.navigate(url); return c.focus(); } }
32    if(clients.openWindow){ return clients.openWindow(url); }
33  }));
34});

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.