-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogsdk.js
More file actions
110 lines (97 loc) · 2.68 KB
/
logsdk.js
File metadata and controls
110 lines (97 loc) · 2.68 KB
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
105
106
107
108
109
110
var currentVersion = 28111039;
window.SUPER_DEBUG = (function () {
function shouldExecute() {
if (currentVersion > window.SUPER_DEBUG_VERSION) {
return true;
}
return false;
}
function init() {
if (shouldExecute()) {
PLAYER_PRINT_MANGER.tryPrintingNow();
setTimeout(function () {
pollForNewVersion();
}, 1000);
} else {
setTimeout(function () {
pollAgain();
}, 1000);
}
window.SUPER_DEBUG_VERSION = currentVersion;
}
function pollAgain() {
let filePath = extractCurrentPath();
loadJavascript(filePath);
}
function extractCurrentPath() {
let currentScriptName = "logsdk.js";
let scripts = document.getElementsByTagName("script");
for (let i = 0; i < scripts.length; i++) {
let src = scripts[i].src;
if (src.includes(currentScriptName)) {
return src;
}
}
return null;
}
function loadJavascript(filePath) {
var script = document.createElement("script");
script.src = filePath;
document.head.appendChild(script);
}
init();
return {
init: init,
shouldExecute: shouldExecute,
};
})();
window.PLAYER_PRINT_MANGER = (function () {
function tryPrintingNow() {
if (SPN_PLAYER.playerObj) {
let length =
SPN_PLAYER.playerObj.dataModel.languageItems.languages.length;
var lastLang =
SPN_PLAYER.playerObj.dataModel.languageItems.languages[length - 1];
var stringLastLang = JSON.stringify(lastLang, null, 2);
printScreen("stringLastLang :: " + stringLastLang);
} else {
printScreen("SPN_PLAYER.playerObj not found");
}
}
tryPrintingNow();
function createDebugScreen() {
var div = document.createElement("div");
div.id = "debugScreen";
div.style.position = "fixed";
div.style.top = "0";
div.style.left = "0";
div.style.width = "100%";
div.style.height = "50%";
div.style.backgroundColor = "rgba(0,0,0,0.5)";
div.style.zIndex = "99999";
div.style.display = "none";
document.body.appendChild(div);
}
function printScreen(message) {
var debugScreen = document.getElementById("debugScreen");
if (debugScreen) {
debugScreen.innerHTML = "";
debugScreen.style.display = "block";
var p = document.createElement("p");
p.style.color = "#fff";
p.style.fontSize = "20px";
p.style.fontWeight = "bold";
p.style.padding = "10px";
p.innerHTML = message;
debugScreen.appendChild(p);
}
}
if (!document.getElementById("debugScreen")) {
createDebugScreen();
} else {
document.getElementById("debugScreen").style.height = "10%";
}
return {
tryPrintingNow: tryPrintingNow,
};
})();