-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvisitor_statistic.js
53 lines (50 loc) · 1.25 KB
/
visitor_statistic.js
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
//github:zhishixiang
var id = document.getElementById("visitorId");
var sum = document.getElementById("sum")
if(document.cookie.indexOf("uuid=") == -1)
{
document.cookie = "uuid="+Math.random();
}
function getCookie(cname)
{
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++)
{
var c = ca[i].trim();
if (c.indexOf(name)==0) return c.substring(name.length,c.length);
}
return "";
}
function getVisitorData(uuid,domain)
{
const xhr = new XMLHttpRequest();
xhr.open("GET","https://st.api.bnnet.com.cn/release/getVisitorData?&uuid="+getCookie("uuid")+"&domain="+domain);
xhr.send();
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
if(xhr.status == 200){
console.log("200 OK");
id.innerText = xhr.response
}
}
}
}
function getWebsiteData(domain)
{
const xhr = new XMLHttpRequest();
xhr.open("GET","https://st.api.bnnet.com.cn/release/getWebsiteData?&domain="+domain);
xhr.send();
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
if(xhr.status == 200){
console.log("200 OK");
sum.innerText = xhr.response
}
}
}
}
console.log(getCookie("uuid"));
console.log(location.host);
getVisitorData(getCookie("uuid"),location.host);
getWebsiteData(location.host);