-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoldenkey.js
104 lines (103 loc) · 3.21 KB
/
goldenkey.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
100
101
102
103
104
function CHECKER_INIT(e) {
function t() {
n(),
// l = setTimeout(i, Math.random())
l = setTimeout(i, 100)
}
function n() {
var e = new window.URL(window.location.href)
, t = e.searchParams.get("token");
null !== t && "" !== t && (o(t),
e.searchParams["delete"]("token"),
history.replaceState(null, document.title, e.toString()))
}
function a(e) {
var t;
clearTimeout(p),
e && (t = new Date(e).getTime() - (new Date).getTime(),
t > 0 && (p = setTimeout(c, t)))
}
function o(e) {
var t = new Date;
h = e,
t.setMinutes(t.getMinutes() + 10),
document.cookie = "token=" + e + "; expires=" + t.toUTCString(),
r() || (document.cookie = "token=" + e)
}
function r() {
for (var e = document.cookie.split(";"), t = 0, n = e.length; n > t; t++) {
var a = e[t]
, o = a.substr(0, a.indexOf("="));
if ("token" == o.replace(/ /g, ""))
return a.substr(a.indexOf("=") + 1)
}
return h
}
function i() {
var t = r()
, n = {
now: (new Date).getTime() - 100
};
// console.clear();
console.log("%cChecking Data %s", 'color: green; font-size: 30px;', n.now);
t && (n.token = t),
e.queueData || (f = setTimeout(e.pageManager.loadingMessage, 1500)),
qwest.get(e.refreshUrl, n).then(function(e, t) {
// debugger;
clearTimeout(f);
try {
d(t, u(n.now))
} catch (a) {
s(12e4)
}
})["catch"](function() {
console.error.apply(null, arguments);
// debugger
e.gaManager.sendGATiming(u(n.now), "failed"),
s()
})
}
function u(e) {
return (new Date).getTime() - e
}
function s(e) {
clearTimeout(l),
// l = setTimeout(i, e || 2e4 * Math.random())
// l = setTimeout(i, 300)
l = setTimeout(i, 100)
}
function c() {
e.pageManager.renderPage(),
e.announcementManager.renderAnnouncements()
}
function d(t, n) {
0 === Object.keys(t).length ? (e.gaManager.sendGATiming(n, "no data"),
s()) : (e.queueData = t,
t.redirect ? (o(""),
e.gaManager.sendGATiming(n, "redirect"),
e.foManager.loadRedirectURL(t.redirect)) : (o(t.token || ""),
a(t.start_date),
e.gaManager.sendGATiming(n, "success"),
null === e.langManager.locale && e.langManager.setLocale(t.content.locale),
c(),
// s(t.refresh_seconds ? 1e3 * t.refresh_seconds : 3e4 + 6e4 * Math.random())))
s(100)))
}
var l = null
, f = null
, p = null
, h = null;
qwest.setDefaultOptions({
responseType: "json",
// timeout: 6e4,
timeout: 1000,
cache: !0
}),
// document.addEventListener("lang-changed", c),
// document.addEventListener("page-changed", function() {
// e.gaManager.sendGAPage(e.queueData.content.active_page_name)
// }),
t();
console.log("%cSuccess!", 'color: red; font-size: 40px;');
}
var CH = CHECKER_INIT(window.PL);