forked from tangly1024/NotionNext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
busuanzi.js
99 lines (93 loc) · 2.96 KB
/
busuanzi.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
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
98
99
/* eslint-disable */
let bszCaller, bszTag, scriptTag, ready
let t; let e; let n; let a = !1
let c = []
// 修复Node同构代码的问题
if (typeof document !== 'undefined') {
ready = function (t) {
return a || document.readyState === 'interactive' || document.readyState === 'complete'
? t.call(document)
: c.push(function () {
return t.call(this)
}), this
}, e = function () {
for (let t = 0, e = c.length; t < e; t++) c[t].apply(document)
c = []
}, n = function () {
a || (a = !0, e.call(window),
document.removeEventListener ? document.removeEventListener('DOMContentLoaded', n, !1) : document.attachEvent && (document.detachEvent('onreadystatechange', n), window == window.top && (clearInterval(t), t = null)))
}, document.addEventListener
? document.addEventListener('DOMContentLoaded', n, !1)
: document.attachEvent && (document.attachEvent('onreadystatechange', function () {
/loaded|complete/.test(document.readyState) && n()
}), window == window.top && (t = setInterval(function () {
try {
a || document.documentElement.doScroll('left')
} catch (t) {
return
}
n()
}, 5)))
}
bszCaller = {
fetch: function (t, e) {
const n = 'BusuanziCallback_' + Math.floor(1099511627776 * Math.random())
t = t.replace('=BusuanziCallback', '=' + n)
scriptTag = document.createElement('SCRIPT'), scriptTag.type = 'text/javascript', scriptTag.defer = !0, scriptTag.src = t, scriptTag.referrerPolicy = "no-referrer-when-downgrade", document.getElementsByTagName('HEAD')[0].appendChild(scriptTag)
window[n] = this.evalCall(e)
},
evalCall: function (e) {
return function (t) {
ready(function () {
try {
e(t), scriptTag && scriptTag.parentElement && scriptTag.parentElement.removeChild && scriptTag.parentElement.removeChild(scriptTag)
} catch (t) {
// console.log(t), bszTag.hides()
}
})
}
}
}
const fetch = () => {
bszTag && bszTag.hides()
bszCaller.fetch('//busuanzi.ibruce.info/busuanzi?jsonpCallback=BusuanziCallback', function (t) {
// console.log('不蒜子',t)
bszTag.texts(t), bszTag.shows()
})
}
bszTag = {
bszs: ['site_pv', 'page_pv', 'site_uv'],
texts: function (n) {
this.bszs.map(function (t) {
const e = document.getElementsByClassName('busuanzi_value_' + t)
if(e){
for (var element of e) {
element.innerHTML = n[t]
}
}
})
},
hides: function () {
this.bszs.map(function (t) {
const e = document.getElementsByClassName('busuanzi_container_' + t)
if(e){
for (var element of e){
element.style.display = 'none'
}
}
})
},
shows: function () {
this.bszs.map(function (t) {
const e = document.getElementsByClassName('busuanzi_container_' + t)
if(e){
for(var element of e){
element.style.display = 'inline'
}
}
})
}
}
module.exports = {
fetch
}