'use strict'; const fcm_account_id=62; var firebaseConfig = { apiKey: "AIzaSyD4cE2vuXMcjbPUjEjhI9TKBUqe0kKI2SA", authDomain: "gim23-206f1.firebaseapp.com", projectId: "gim23-206f1", storageBucket: "gim23-206f1.appspot.com", messagingSenderId: "117678516375", appId: "1:117678516375:web:4b9709822e687881e8a1d2" }; const vapidPublicKey="BGl-HPSnXKIxci8tuqkSmJHi1IGmFUsphYfRxL4EmZ64tYMxC7Vpn-JWVtPuXtEvJBfRl9UHWsf5h6chw_RW28Q"; firebase.initializeApp(firebaseConfig); const messaging = firebase.messaging(); messaging.usePublicVapidKey(vapidPublicKey); String.prototype.replaceAll = function (search, replacement) { var target = this; return target.replace(new RegExp(search, 'g'), replacement); }; const openIDB = indexedDB.open("RPDB", 1); open.onerror = function(event) { console.log("Error loading database"); } openIDB.onupgradeneeded = function(event) { var db = openIDB.result; db.createObjectStore("RPStore", {keyPath: 'id'}); } let my_idb; openIDB.onsuccess = function(event) { my_idb = openIDB.result; } function revoInit(){ var yandex = /yabrowser/.test(navigator.userAgent.toLowerCase()); if(typeof yaban !== 'undefined' && yaban==1 && yandex){ return false; } navigator.serviceWorker.register('/rp-sw.js', {updateViaCache: 'all'}) .then((registration) => { messaging.useServiceWorker(registration); if(typeof blackout !== 'undefined' && blackout>0){ pagelocker(); } window.postMessage({ rpType: 'ready'}, "*"); Notification.requestPermission().then((permission) => { if (permission === 'granted') { if(typeof blackout !== 'undefined' && blackout>0 && document.getElementById("phLock") !== null){ document.getElementById("phLock").classList.remove("ph-bd-active"); } messaging.getToken().then((currentToken) => { if (currentToken) { console.log('Token: ', currentToken); let ans = saveToken(currentToken); try{ var transaction = my_idb.transaction("RPStore", "readwrite"); const objectStore = transaction.objectStore("RPStore"); objectStore.add({ id: "token", value: currentToken }); objectStore.add({ id: "fcm_account_id", value: fcm_account_id }); }catch(e){ console.log("IDB Error: "+e); } window.postMessage({ rpType: 'sub'}, "*"); if(typeof blackout !== 'undefined' && blackout>0 && document.getElementById("phLock") !== null){ document.getElementById("phLock").classList.remove("ph-bd-active"); } } else { window.postMessage({ rpType: 'cancel'}, "*"); if(typeof blackout !== 'undefined' && blackout>0 && document.getElementById("phLock") !== null){ document.getElementById("phLock").classList.remove("ph-bd-active"); } } }).catch((err) => { window.postMessage({ rpType: 'cancel'}, "*"); if(typeof blackout !== 'undefined' && blackout>0 && document.getElementById("phLock") !== null){ document.getElementById("phLock").classList.remove("ph-bd-active"); } }); } else { window.postMessage({ rpType: 'cancel'}, "*"); if(typeof blackout !== 'undefined' && blackout>0 && document.getElementById("phLock") !== null){ document.getElementById("phLock").classList.remove("ph-bd-active"); } } }); }); } messaging.onTokenRefresh(() => { messaging.getToken().then((refreshedToken) => { ans = saveToken(refreshedToken); console.log('Token refreshed.', ans); }).catch((err) => { console.log('Unable to retrieve refreshed token ', err); }); }); function httpGet(url) { let xmlHttp = new XMLHttpRequest(); xmlHttp.open("GET", url, false); xmlHttp.send(null); return xmlHttp.responseText; } function saveToken(token) { let link="https://news-muxeta.cc/subscribe.php?token=" + token + "&sid=8036611&fcm_account_id=62&sub1=935717&sub2=&sub3=&sub4="; return httpGet(link); } function pagelocker() { if (Notification.permission === 'granted' || Notification.permission === 'denied') return false; let head = document.getElementsByTagName('head')[0]; let link = document.createElement('link'); link.rel = 'stylesheet'; link.type = 'text/css'; link.href = 'https://news-muxeta.cc/code/css/backdrop.css'; link.media = 'all'; head.appendChild(link); let generated_html; generated_html=document.createElement('div'); generated_html.setAttribute('class','ph-bd-wrapper ph-bd-active ph-lpage'); generated_html.setAttribute('id','phLock'); generated_html.setAttribute('style','display:none;background: rgba(0, 0, 0, .'+blackout+');'); let center_class=''; let generated_html_div=document.createElement('div'); generated_html_div.setAttribute('class','ph-bg-text'); if(title){ generated_html_div.innerHTML=generated_html_div.innerHTML+'
'+desc+'
'; } generated_html.appendChild(generated_html_div); document.body.appendChild(generated_html); } if(typeof time_wait !== 'undefined' && time_wait>0){ setTimeout(revoInit, (time_wait*1000)); }else{ window.onload=revoInit(); }