Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
RishiRecon
GitHub Repository: RishiRecon/exploits
Path: blob/main/misc/smashkarts/scripts/main-v2.js
36008 views
1
'use strict';
2
3
function setV(val2)
4
{
5
if(window.unityGame != null)
6
{
7
window.unityGame.SendMessage(unityFirebaseGameOjbectName, "V2", val2);
8
}
9
}
10
11
function getReferrerUrl()
12
{
13
var url = (window.location != window.parent.location)
14
? document.referrer
15
: document.location.href;
16
return url;
17
}
18
19
function isMobile()
20
{
21
var isMobile = RegExp(/Android|webOS|iPhone|iPod|iPad/i).test(navigator.userAgent);
22
return isMobile || isIpad();
23
}
24
25
function isTablet()
26
{
27
var userAgent = navigator.userAgent.toLowerCase();
28
var isAndroidTablet = ((userAgent.search("android") > -1) && !(userAgent.search("mobile") > -1));
29
30
return isAndroidTablet || isIpad();
31
}
32
33
function isIpad()
34
{
35
var isIpad = RegExp(/iPad/i).test(navigator.userAgent);
36
37
if (!isIpad)
38
{
39
const isMac = RegExp(/Macintosh/i).test(navigator.userAgent);
40
41
if (isMac && navigator.maxTouchPoints && navigator.maxTouchPoints > 2)
42
{
43
isIpad = true;
44
}
45
}
46
return isIpad;
47
}
48
49
function getOS()
50
{
51
var detectedOS = "Unknown";
52
if (window.navigator.userAgent.indexOf("Windows") != -1) { detectedOS = "Windows";}
53
else if (window.navigator.userAgent.indexOf("CrOS") != -1) { detectedOS = "Chrome";}
54
else if (window.navigator.userAgent.indexOf("Mac") != -1) detectedOS="Mac/iOS";
55
else if (window.navigator.userAgent.indexOf("X11") != -1) detectedOS="UNIX";
56
else if (window.navigator.userAgent.indexOf("Linux") != -1) detectedOS="Linux";
57
58
return detectedOS;
59
}
60
61
function isIos()
62
{
63
var isIos = (/iPhone|iPad|iPod/i.test(navigator.userAgent));
64
return isIos || isIpad();
65
}
66
67
68
function copyTextToClipboard(text)
69
{
70
var textArea = document.createElement("textarea");
71
textArea.style.position = 'fixed';
72
textArea.style.top = 0;
73
textArea.style.left = 0;
74
textArea.style.width = '2em';
75
textArea.style.height = '2em';
76
textArea.style.padding = 0;
77
textArea.style.border = 'none';
78
textArea.style.outline = 'none';
79
textArea.style.boxShadow = 'none';
80
textArea.style.background = 'transparent';
81
textArea.value = text;
82
document.body.appendChild(textArea);
83
textArea.select();
84
try {
85
var successful = document.execCommand('copy');
86
var msg = successful ? 'successful' : 'unsuccessful';
87
console.log('Copying text command was ' + msg);
88
} catch (err) {
89
console.warn('Unable to copy text');
90
}
91
document.body.removeChild(textArea);
92
}
93
94
window.copyText = function (text) {
95
var listener = function () {
96
97
copyTextToClipboard(text);
98
if(isMobile())
99
{
100
document.removeEventListener('touchend', listener);
101
}
102
else
103
{
104
document.removeEventListener('mouseup', listener);
105
}
106
107
};
108
109
if(isMobile())
110
{
111
document.addEventListener('touchend', listener);
112
}
113
else
114
{
115
document.addEventListener('mouseup', listener);
116
}
117
};
118
119
function firebaseLogEvent(eventName)
120
{
121
if(firebaseSupported) firebase.analytics().logEvent(eventName);
122
}
123
124
function firebaseSetScreen(screenName)
125
{
126
if(firebaseSupported) firebase.analytics().setCurrentScreen(screenName);
127
if(firebaseSupported) firebase.analytics().logEvent("screen_view", { "screen_name": screenName})
128
}
129
130
function firebaseLogEventWithParam(eventName, p, v)
131
{
132
if(firebaseSupported) firebase.analytics().logEvent(eventName, { [p]: v});
133
}
134
135
var fs = false;
136
function toggleFullscreen()
137
{
138
if(fs)
139
{
140
console.log("exitFullScreen");
141
exitFullScreen();
142
}
143
else
144
{
145
console.log("setElementFullScreen");
146
var elem = document.getElementById("mainContainer");
147
setElementFullScreen(elem);
148
}
149
fs = !fs;
150
}
151
152
function isFullscreen()
153
{
154
return fs;
155
}
156
157
158
function onNextMouseUp(a)
159
{
160
var listenerName = isMobile() ? 'touchend' : 'mouseup';
161
var listener = function () {
162
a();
163
document.removeEventListener(listenerName, listener);
164
};
165
document.addEventListener(listenerName, listener);
166
}
167
168
function openUrl(url)
169
{
170
onNextMouseUp(function () {
171
console.log("openUrl onNextMouseUp");
172
window.open(url, "_blank");
173
});
174
}
175
176
function setElementFullScreen(el) {
177
onNextMouseUp(function () {
178
var request = el.requestFullscreen || el.webkitRequestFullscreen || el.mozRequestFullScreen || el.msRequestFullscreen;
179
request.call(el);
180
});
181
}
182
183
function exitFullScreen() {
184
onNextMouseUp(function () {
185
var exitFS = document.exitFullscreen || document.webkitExitFullscreen || document.mozCancelFullScreen || document.msExitFullscreen;
186
exitFS.call(document);
187
});
188
}
189
190
function handleKeyDown(keycode)
191
{
192
if(window.unityGame) window.unityGame.SendMessage(unityFirebaseGameOjbectName, "HandleKeyDown", keycode);
193
}
194
195
function handleKeyUp(keycode)
196
{
197
if(window.unityGame) window.unityGame.SendMessage(unityFirebaseGameOjbectName, "HandleKeyUp", keycode);
198
}
199
200
var source = "notset";
201
function setUrlSource(src)
202
{
203
source = src;
204
console.log("setUrlSource " + src);
205
}
206
207
function reloadPage()
208
{
209
location.reload();
210
}
211
212