One Hat Cyber Team
Your IP :
3.12.163.14
Server IP :
50.28.103.30
Server :
Linux host.jcukjv-lwsites.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
Server Software :
nginx/1.24.0
PHP Version :
8.3.12
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
www
/
wwwroot
/
globify.live
/
assets
/
js
/
chat_page
/
View File Name :
firebase_push_notifications.js
import { initializeApp } from 'https://www.gstatic.com/firebasejs/10.5.2/firebase-app.js' import { getAnalytics } from 'https://www.gstatic.com/firebasejs/10.5.2/firebase-analytics.js' import { getAuth } from 'https://www.gstatic.com/firebasejs/10.5.2/firebase-auth.js' import { getFirestore } from 'https://www.gstatic.com/firebasejs/10.5.2/firebase-firestore.js' import { getMessaging, getToken } from 'https://www.gstatic.com/firebasejs/10.5.2/firebase-messaging.js' let hasRequestedFBPermission = false; const firebaseConfig = { apiKey: $('.web_push_service_variables > .apiKey').text(), authDomain: $('.web_push_service_variables > .authDomain').text(), projectId: $('.web_push_service_variables > .projectId').text(), messagingSenderId: $('.web_push_service_variables > .messagingSenderId').text(), appId: $('.web_push_service_variables > .appId').text(), }; const app = initializeApp(firebaseConfig); const messaging = getMessaging(app); const firebase_requestPermission = async () => { if ('Notification' in window) { const permission = await Notification.requestPermission(); if (permission === 'granted') { console.log('Notification permission granted.'); return true; } else { console.log('Notification permission denied.'); return false; } } else { console.error('This browser does not support notifications.'); return false; } }; const firebase_getDeviceToken = async () => { try { const token = await getToken(messaging, { serviceWorkerRegistration: firebase_sw_reg }); add_push_subscriber(token, 'firebase'); } catch (error) { console.error('Error getting device token:', error); } }; document.querySelectorAll('.site_records').forEach(element => { element.addEventListener('click', async () => { if (!hasRequestedFBPermission) { if (firebase_sw_reg) { const permissionGranted = await firebase_requestPermission(); if (permissionGranted) { await firebase_getDeviceToken(); } hasRequestedFBPermission = true; } else { console.log('Service worker is not registered yet.'); } } }); });