-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoki-sdk.js
85 lines (85 loc) · 3.14 KB
/
poki-sdk.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
(() => {
var e = function(e) {
var n = RegExp("[?&]" + e + "=([^&]*)").exec(window.location.search);
return n && decodeURIComponent(n[1].replace(/\+/g, " "))
},
n = "kids" === e("tag"),
t = new(function() {
function e() {
var e = this;
this.queue = [], this.init = function(n) {
return void 0 === n && (n = {}), new Promise((function(t, o) {
e.enqueue("init", n, t, o)
}))
}, this.rewardedBreak = function() {
return new Promise((function(e) {
e(!1)
}))
}, this.noArguments = function(n) {
return function() {
e.enqueue(n)
}
}, this.oneArgument = function(n) {
return function(t) {
e.enqueue(n, t)
}
}, this.handleAutoResolvePromise = function() {
return new Promise((function(e) {
e()
}))
}, this.throwNotLoaded = function() {
console.debug("PokiSDK is not loaded yet. Not all methods are available.")
}
}
return e.prototype.enqueue = function(e, t, o, i) {
var r = {
fn: e,
options: t,
resolveFn: o,
rejectFn: i
};
n ? i && i() : this.queue.push(r)
}, e.prototype.dequeue = function() {
for (var e = function() {
var e = n.queue.shift(),
t = e,
o = t.fn,
i = t.options;
"function" == typeof window.PokiSDK[o] ? (null == e ? void 0 : e.resolveFn) || (null == e ? void 0 : e.rejectFn) ? window.PokiSDK[o](i).then((function() {
for (var n = [], t = 0; t < arguments.length; t++) n[t] = arguments[t];
"function" == typeof e.resolveFn && e.resolveFn.apply(e, n)
})).catch((function() {
for (var n = [], t = 0; t < arguments.length; t++) n[t] = arguments[t];
"function" == typeof e.rejectFn && e.rejectFn.apply(e, n)
})) : void 0 !== (null == e ? void 0 : e.fn) && window.PokiSDK[o](i) : console.error("Cannot execute " + e.fn)
}, n = this; this.queue.length > 0;) e()
}, e
}());
window.PokiSDK = {
init: t.init,
initWithVideoHB: t.init,
customEvent: t.throwNotLoaded,
commercialBreak: t.handleAutoResolvePromise,
rewardedBreak: t.rewardedBreak,
displayAd: t.throwNotLoaded,
destroyAd: t.throwNotLoaded,
getLeaderboard: t.handleAutoResolvePromise,
getSharableURL: function() {
return new Promise((function(e, n) {
return n()
}))
},
getURLParam: function(n) {
return e("gd" + n) || e(n) || ""
}
}, ["disableProgrammatic", "gameLoadingStart", "gameLoadingFinished", "gameInteractive", "roundStart", "roundEnd", "muteAd"].forEach((function(e) {
window.PokiSDK[e] = t.noArguments(e)
})), ["setDebug", "gameplayStart", "gameplayStop", "gameLoadingProgress", "happyTime", "setPlayerAge", "togglePlayerAdvertisingConsent", "logError", "sendHighscore", "setDebugTouchOverlayController"].forEach((function(e) {
window.PokiSDK[e] = t.oneArgument(e)
}));
var o, i = ((o = window.pokiSDKVersion) || (o = e("ab") || "v2.263.0"), "/poki-sdk-" + (n ? "kids" : "core") + "-" + o + ".js"),
r = document.createElement("script");
r.setAttribute("src", i), r.setAttribute("type", "text/javascript"), r.setAttribute("crossOrigin", "anonymous"), r.onload = function() {
return t.dequeue()
}, document.head.appendChild(r)
})();