PageSourceSearch

https://livevns.news/static/c1e/static/notification_config/84451/3269/js/index.js

js livevns.news collected 2026-09-25 00:40:12 UTC 7,282 bytes, 209 lines download raw bytes

1var analytics = null;
2var topic = '3269_topic';
3var registration = null;
4var messaging = null;
5var imageLogo = "/static/c1e/static/notification_config/84451/3269/images/vns-139x90.png";
6var notificationPermissionText = "https://livevns.news/ wants to show notifications";
7var allowedNotificationText = "You've already subscribed to the Notifications.";
8var blockedNotification = "Click Allow to Subscribe.";
9var allowButton = "Allow";
10var laterButton = "Later";
11var okButton = "OK";
12
13$(document).ready(function(){
14	$("#modalCookie1 .modal-body-icon img").attr("src",imageLogo);
15	modifyNotificationModal(notificationPermissionText, laterButton, allowButton);
16});
17async function init() {
18	
19  registration = await navigator.serviceWorker.register("/static/c1e/static/sw/js/sw.js");
20  navigator.serviceWorker.ready;	
21  firebase.initializeApp({
22	  apiKey: "AIzaSyBhynUiXoimIuINinUglEBnDNLhK3i-bcw",
23	    authDomain: "libertad-18ee6.firebaseapp.com",
24	    databaseURL: "https://libertad-18ee6.firebaseio.com",
25	    projectId: "libertad-18ee6",
26	    storageBucket: "libertad-18ee6.appspot.com",
27	    messagingSenderId: "895650955273",
28	    appId: "1:895650955273:web:a3e5851e2907ddbe3c38d8",
29	    measurementId: "G-GQT3P15C6H"
30  });
31  analytics = firebase.analytics();
32  messaging = firebase.messaging();
33  messaging.usePublicVapidKey('BLRYIco27qXYts_RaoiBvrbgJ-uefRg1mSyLcpSj-c1ykLUasXj3d7e09iIy7_znX0Jp0R8ObaykFQrolNA5jCc');
34  messaging.useServiceWorker(registration);	
35  
36  var domain = getDomainName(window.location.hostname);
37  domain = domain.substring(0,domain.lastIndexOf('.'));
38  
39  const db = await getDb();
40  
41  if(getSubscribedTopic(domain, topic)!==topic && !getCookie('firstVisit')) {
42	  if(Notification.permission === "default") {
43	  $('#modalCookie1').modal('show');
44	  } else if(Notification.permission === "granted") {
45	  subscribeTokenToTopic();
46	  }
47	  setCookie('firstVisit', true);
48  }
49 
50}
51function getDomainName(hostName) {
52    return hostName.substring(hostName.lastIndexOf(".", hostName.lastIndexOf(".") - 1) + 1);
53}
54function getSubscribedTopic(hostname, topic) {
55	return "";
56// read(db, hostname);
57}
58async function showData() {
59  
60}
61async function getDb() {
62  if (this.db) {
63    return Promise.resolve(this.db);
64  }
65  return new Promise(resolve => {
66    const openRequest = indexedDB.open("topics", 1);
67    openRequest.onupgradeneeded = event => {
68      const db = event.target.result;
69    };
70    openRequest.onsuccess = event => {
71      this.db = event.target.result;
72      resolve(this.db);
73    }
74  });
75}
76async function subscribeTokenToTopic() {
77	var initialPermission;
78	try {
79	  initialPermission = Notification.permission;
80	  if(Notification.permission === "default"){
81	  console.log("subscribed_notification_popup");
82	  analytics.logEvent('subscribed_notification_popup', {
83	  topic: topic
84	  });
85	  }
86	  await messaging.requestPermission();
87	  var finalPermission = Notification.permission;
88	  if(initialPermission === "default" && finalPermission === "granted") {
89	  console.log("subscribed_notification");
90	  analytics.logEvent('subscribed_notification', {
91	  topic: topic
92	  });
93	  }
94	  } catch (e) {
95	    console.log('Unable to get permission', e);
96	    if(initialPermission !== "denied") {
97	    	console.log("unsubscribed_notification");
98	    analytics.logEvent('unsubscribed_notification', {
99	  topic: topic
100	  });
101	    }
102	    return;
103	  }
104	  
105	  const currentToken = await messaging.getToken();
106	
107	  fetch('https://c1enotify.clmbtech.com/register', { method: 'post', body: JSON.stringify({token: currentToken, topic: topic}), headers: {
108	      'Accept': 'application/json',
109	      'Content-Type': 'application/json'
110	    } });
111	  showData();
112	  
113// addDomainToDb(domain, topic);
114	  
115	  messaging.onTokenRefresh(async () => {
116	    console.log('token refreshed');
117	    const newToken = await messaging.getToken();
118	    fetch('https://c1enotify.clmbtech.com/register', { method: 'post', body: JSON.stringify({token: currentToken, topic: topic}), headers: {
119	        'Accept': 'application/json',
120	        'Content-Type': 'application/json'
121	      } });
122	  });
123}
124function subscribe(){
125	if(Notification.permission === "granted") {
126	modifyNotificationModal(allowedNotificationText, "", okButton);
127	} else if(Notification.permission === "denied") {
128	modifyNotificationModal(blockedNotification, "", okButton);
129	} else if(Notification.permission === "default") {
130	modifyNotificationModal(notificationPermissionText, laterButton, allowButton);
131	}
132	$('#modalCookie1').modal('show');
133}
134function modifyNotificationModal(text, laterButton, allowButton) {
135	$("#modalCookie1 .modal-body-message").text(text);
136	if (laterButton === "") {
137	$("#modalCookie1 .modal-footer .btn-secondary").hide(); 
138	$("#modalCookie1 .modal-footer .btn-primary").attr("onclick","");
139	} else {
140	$("#modalCookie1 .modal-footer .btn-secondary").text(laterButton);
141	}
142	$("#modalCookie1 .modal-footer .btn-primary").text(allowButton);
143}
144navigator.permissions.query({name:'notifications'}).then(function(permissionStatus){
145	var initial = permissionStatus.state;
146	console.log('notifications permission status is ', permissionStatus.state);
147	  permissionStatus.onchange = function() {
148	if(initial === "granted" && this.state === "denied") {
149	    console.log('notifications permission status has changed to ', this.state);
150	    analytics.logEvent('allow_to_block_transition', {
151	  topic: topic
152	    });
153	  	} else if(this.state === "granted" && initial === "denied") {
154	    console.log('notifications permission status has changed to ', this.state);
155	    analytics.logEvent('block_to_allow_transition', {
156	  topic: topic
157	    });
158	  	} else if(initial === "prompt" && this.state ==="denied"){
159	  	console.log("do Nothing");
160	  	} else if(initial === "prompt" && this.state ==="granted"){
161	  	console.log("do Nothing");
162	  	}
163 	  };
164});
165navigator.serviceWorker.addEventListener('message', event => {
166	  console.log(event.data);
167	    if (event.data === 'pushData') {
168	    	analytics.logEvent('notification_receive', {
169	  topic: topic
170	    });
171	    } else if(event.data === 'notificationOnClick') {
172	    	analytics.logEvent('notification_open', {
173	  topic: topic
174	    });
175	    }
176});
177function setCookie(c_name,value,exdays) {
178	var exdate=new Date();
179	exdate.setDate(exdate.getDate() + exdays);
180	var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
181	document.cookie=c_name + "=" + c_value;
182}
183function getCookie(c_name) {
184	var c_value = document.cookie;
185	var c_start = c_value.indexOf(" " + c_name + "=");
186	if (c_start == -1) {
187	c_start = c_value.indexOf(c_name + "=");
188	}
189	if (c_start == -1) {
190	c_value = null;
191	} else {
192	c_start = c_value.indexOf("=", c_start) + 1;
193	var c_end = c_value.indexOf(";", c_start);
194	if (c_end == -1) {
195	c_end = c_value.length;
196	}
197	c_value = unescape(c_value.substring(c_start,c_end));
198	}
199	return c_value;
200}
201function delCookie(name) {
202	document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
203}
204function customPopUpEvent() {
205	analytics.logEvent('custom_popup_notification_default', {
206	  topic: topic
207	  });
208}
209init();

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.