Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mamayaya1
GitHub Repository: mamayaya1/game
Path: blob/main/projects/crossy-road/poki-sdk.js
4626 views
1
(() => {
2
var e = function (e) {
3
var n = RegExp("[?&]" + e + "=([^&]*)").exec(window.location.search);
4
return n && decodeURIComponent(n[1].replace(/\+/g, " "));
5
},
6
n = "kids" === e("tag"),
7
o = new ((function () {
8
function e() {
9
var e = this;
10
(this.queue = []),
11
(this.init = function (n) {
12
return (
13
void 0 === n && (n = {}),
14
new Promise(function (o, t) {
15
e.enqueue("init", n, o, t);
16
})
17
);
18
}),
19
(this.rewardedBreak = function () {
20
return new Promise(function (e) {
21
e(!1);
22
});
23
}),
24
(this.noArguments = function (n) {
25
return function () {
26
e.enqueue(n);
27
};
28
}),
29
(this.oneArgument = function (n) {
30
return function (o) {
31
e.enqueue(n, o);
32
};
33
}),
34
(this.handleAutoResolvePromise = function () {
35
return new Promise(function (e) {
36
e();
37
});
38
}),
39
(this.handleAutoResolvePromiseObj = function () {
40
return new Promise(function (e) {
41
e();
42
});
43
}),
44
(this.throwNotLoaded = function () {
45
console.debug("PokiSDK is not loaded yet. Not all methods are available.");
46
});
47
}
48
return (
49
(e.prototype.enqueue = function (e, o, t, i) {
50
var r = { fn: e, options: o, resolveFn: t, rejectFn: i };
51
n ? i && i() : this.queue.push(r);
52
}),
53
(e.prototype.dequeue = function () {
54
for (
55
var e = function () {
56
var e = n.queue.shift(),
57
o = e,
58
t = o.fn,
59
i = o.options;
60
"function" == typeof window.PokiSDK[t]
61
? (null == e ? void 0 : e.resolveFn) || (null == e ? void 0 : e.rejectFn)
62
? window.PokiSDK[t](i)
63
.then(function () {
64
for (var n = [], o = 0; o < arguments.length; o++) n[o] = arguments[o];
65
"function" == typeof e.resolveFn && e.resolveFn.apply(e, n);
66
})
67
.catch(function () {
68
for (var n = [], o = 0; o < arguments.length; o++) n[o] = arguments[o];
69
"function" == typeof e.rejectFn && e.rejectFn.apply(e, n);
70
})
71
: void 0 !== (null == e ? void 0 : e.fn) && window.PokiSDK[t](i)
72
: console.error("Cannot execute " + e.fn);
73
},
74
n = this;
75
this.queue.length > 0;
76
77
)
78
e();
79
}),
80
e
81
);
82
})())();
83
(window.PokiSDK = { init: o.init, initWithVideoHB: o.init, customEvent: o.throwNotLoaded, destroyAd: o.throwNotLoaded, getLeaderboard: o.handleAutoResolvePromiseObj }),
84
["disableProgrammatic", "gameLoadingStart", "gameLoadingFinished", "gameInteractive", "roundStart", "roundEnd", "muteAd"].forEach(function (e) {
85
window.PokiSDK[e] = o.noArguments(e);
86
}),
87
[
88
"setDebug",
89
"gameplayStart",
90
"gameplayStop",
91
"gameLoadingProgress",
92
"happyTime",
93
"setPlayerAge",
94
"togglePlayerAdvertisingConsent",
95
"toggleNonPersonalized",
96
"setConsentString",
97
"logError",
98
"sendHighscore",
99
"setDebugTouchOverlayController",
100
].forEach(function (e) {
101
window.PokiSDK[e] = o.oneArgument(e);
102
});
103
var t,
104
i = ((t = window.pokiSDKVersion) || (t = e("ab") || "v2.234.2"), "poki-sdk-" + (n ? "kids" : "core") + "-" + t + ".js"),
105
r = document.createElement("script");
106
r.setAttribute("src", i),
107
r.setAttribute("type", "text/javascript"),
108
r.setAttribute("crossOrigin", "anonymous"),
109
(r.onload = function () {
110
return o.dequeue();
111
}),
112
document.head.appendChild(r);
113
})();
114