PageSourceSearch

https://www.terranauta.it/wp-content/cache/min/1/wp-content/plugin…/js/magellano_webpush.js?ver=1785176320

js terranauta.it collected 2026-10-02 07:26:46 UTC 3,399 bytes, 16 lines download raw bytes

1document.addEventListener('DOMContentLoaded',()=>{const applicationServerKey=magellanoWebPushData.vapid_key;if(!('serviceWorker' in navigator)){console.warn('Service workers are not supported by this browser');return}
2if(!('PushManager' in window)){console.warn('Push notifications are not supported by this browser');return}
3if(!('showNotification' in ServiceWorkerRegistration.prototype)){console.warn('Notifications are not supported by this browser');return}
4if(Notification.permission==='denied'){console.warn('Notifications are denied by the user');return}
5navigator.serviceWorker.register('/sw.js').then(()=>{console.log('Worker registered');push_updateSubscription()},e=>{console.error('Worker Error',e)});function urlBase64ToUint8Array(base64String){const padding='='.repeat((4-(base64String.length%4))%4);const base64=(base64String+padding).replace(/\-/g,'+').replace(/_/g,'/');const rawData=window.atob(base64);const outputArray=new Uint8Array(rawData.length);for(let i=0;i<rawData.length;++i){outputArray[i]=rawData.charCodeAt(i)}
6return outputArray}
7function checkNotificationPermission(){return new Promise((resolve,reject)=>{if(Notification.permission==='denied'){return reject(new Error('Push messages are blocked.'))}
8if(Notification.permission==='granted'){return resolve()}
9if(Notification.permission==='default'){return Notification.requestPermission().then(result=>{if(result!=='granted'){reject(new Error('Bad permission result'))}else{resolve()}})}
10return reject(new Error('Unknown permission'))})}
11function push_subscribe(){return checkNotificationPermission().then(()=>navigator.serviceWorker.ready).then(serviceWorkerRegistration=>serviceWorkerRegistration.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:urlBase64ToUint8Array(applicationServerKey),})).then(subscription=>{return push_sendSubscriptionToServer(subscription,'POST')}).then(subscription=>subscription).catch(e=>{if(Notification.permission==='denied'){console.warn('Notifications are denied by the user.')}else{console.error('Impossible to subscribe to push notifications',e)}})}
12function push_updateSubscription(){navigator.serviceWorker.ready.then(serviceWorkerRegistration=>serviceWorkerRegistration.pushManager.getSubscription()).then(subscription=>{if(!subscription){push_subscribe();return}
13return push_sendSubscriptionToServer(subscription,'PUT')}).then(subscription=>subscription).catch(e=>{console.error('Error when updating the subscription',e)})}
14function push_unsubscribe(){navigator.serviceWorker.ready.then(serviceWorkerRegistration=>serviceWorkerRegistration.pushManager.getSubscription()).then(subscription=>{if(!subscription){return}
15return push_sendSubscriptionToServer(subscription,'DELETE')}).then(subscription=>subscription.unsubscribe()).catch(e=>{console.error('Error when unsubscribing the user',e)})}
16function push_sendSubscriptionToServer(subscription,method){const key=subscription.getKey('p256dh');const token=subscription.getKey('auth');const contentEncoding=(PushManager.supportedContentEncodings||['aesgcm'])[0];return fetch(magellanoWebPushData.magellano_webpush_api,{method,body:JSON.stringify({site:magellanoWebPushData.site,endpoint:subscription.endpoint,publicKey:key?btoa(String.fromCharCode.apply(null,new Uint8Array(key))):null,authToken:token?btoa(String.fromCharCode.apply(null,new Uint8Array(token))):null,contentEncoding,}),}).then(()=>subscription)}})

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.