-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.html
97 lines (84 loc) · 2.89 KB
/
log.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-app.js";
import { getDatabase, ref, update, get, child } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-database.js";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyAwBo-LBbTZWimOAkgByg9zVd3sgwdON6U",
authDomain: "exactalytics.firebaseapp.com",
projectId: "exactalytics",
storageBucket: "exactalytics.appspot.com",
messagingSenderId: "2502194733",
appId: "1:2502194733:web:8b3ef42a216fa6bfbf2aa4"
};
function encodeFB(text2) {
var text1 = text2.replaceAll(".","%2E").replaceAll("#","%23").replaceAll("$","%24").replaceAll("/","%2F").replaceAll("[","%5B").replaceAll("]","%5D").replaceAll('"',"%22")
return text1;
}
function decodeFB(text2) {
var text1 = text2.replaceAll("%2E",".").replaceAll("%23","#").replaceAll("%24","$").replaceAll("%2F","/").replaceAll("%5B","[").replaceAll("%5D","]").replaceAll('%22','"')
return text1;
}
var metaTitle = encodeFB(new URLSearchParams(window.location.search).get("metaID"));
var metaPage = encodeFB(new URLSearchParams(window.location.search).get("metaPage"));
var apiKey = encodeFB(new URLSearchParams(window.location.search).get("key"));
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const db = getDatabase();
const dbRef = ref(db);
get(child(dbRef, "/analytics/" + apiKey)).then((snapshot) => {
if ((snapshot.val()).exists) {
update(ref(db,"/analytics/" + apiKey),{exists:false})
}
})
get(child(dbRef, "/analytics/" + apiKey + "/" + metaTitle)).then((snapshot) => {
var toadd = {}
if (snapshot.exists()) {
var gdata = snapshot.val();
} else {
var gdata = {}
}
if (window.parent != window.top) {
if (gdata.embeds) {
toadd.embeds = gdata.embeds + 1;
} else {
toadd.embeds = 1;
}
} else {
if (gdata.clicks) {
toadd.clicks = gdata.clicks + 1;
} else {
toadd.clicks = 1;
}
if (!localStorage.getItem("viewdone")) {
if (gdata.users) {
toadd.users = gdata.users + 1;
} else {
toadd.users = 1;
}
localStorage.setItem("viewdone","true")
}
if (gdata.pages) {
var pages1 = gdata.pages;
} else {
var pages1 = {}
}
if (pages1[metaPage]) {
pages1[metaPage] = pages1[metaPage] + 1;
} else {
pages1[metaPage] = 1;
}
}
update(ref(db,"/analytics/" + apiKey + "/" + metaTitle),toadd)
update(ref(db,"/analytics/" + apiKey + "/" + metaTitle + "/pages"),pages1)
});
</script>
</body>
</html>