Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
RishiRecon
GitHub Repository: RishiRecon/exploits
Path: blob/main/misc/smashkarts/scripts/ads-v2.js
36008 views
1
'use strict';
2
3
var gameContainer;
4
function updateAdSizes()
5
{
6
if(gameContainer == null)
7
{
8
gameContainer = document.getElementById('gameContainer');
9
}
10
11
if(gameContainer != null)
12
{
13
updateMainMenuBanner();
14
updateLongBanner();
15
updateWinBanner();
16
}
17
}
18
19
function adBlockerActive()
20
{
21
var active = (document.getElementById('nbAIVXTtpUxM') == null);
22
return active;
23
}
24
25
var mainMenuBanner;
26
function updateMainMenuBanner()
27
{
28
if(mainMenuBanner == null)
29
{
30
mainMenuBanner = document.getElementById('adContainer');
31
}
32
33
if(mainMenuBanner != null && mainMenuBanner.display != "none")
34
{
35
var adContainerW = mainMenuBanner.offsetWidth;
36
var adContainerH = mainMenuBanner.offsetHeight;
37
var gameContainerH = gameContainer.offsetHeight;
38
39
if(adContainerH/gameContainerH > 0.8)
40
{
41
var newHeight = gameContainerH * 0.8;
42
var newScale = newHeight / adContainerH;
43
var scaleString = "scale( " + newScale + "," + newScale + ")";
44
var offsetX = (adContainerW - (adContainerW*newScale))/2 - 10;
45
var offsetY = 10 - (adContainerH - adContainerH*newScale)/2;
46
var translateString = "translate(" + offsetX + "px, " + offsetY + "px)";
47
mainMenuBanner.style.transform = translateString + " " + scaleString;
48
}
49
else
50
{
51
mainMenuBanner.style.transform = "scale( 1, 1) translate(-10px, 10px)";
52
}
53
}
54
}
55
56
var winBanner;
57
function updateWinBanner()
58
{
59
if(winBanner == null)
60
{
61
winBanner = document.getElementById('adContainer2');
62
}
63
64
if(winBanner != null && winBanner.display != "none")
65
{
66
var adContainerW = winBanner.offsetWidth;
67
var adContainerH = winBanner.offsetHeight;
68
var gameContainerH = gameContainer.offsetHeight;
69
70
if(adContainerH/gameContainerH > 0.65)
71
{
72
var newHeight = gameContainerH * 0.65;
73
var newScale = newHeight / adContainerH;
74
var scaleString = "scale( " + newScale + "," + newScale + ")";
75
var offsetX = (adContainerW - (adContainerW*newScale))/2 - 10;
76
var offsetY = gameContainerH/2 - adContainerH/2;
77
var translateString = "translate(" + offsetX + "px, " + offsetY + "px)";
78
winBanner.style.transform = translateString + " " + scaleString;
79
}
80
else
81
{
82
var offsetY = gameContainerH/2 - adContainerH/2;
83
winBanner.style.transform = "scale( 1, 1) translate(-10px, " + offsetY + "px)";
84
}
85
}
86
}
87
88
var longBanner;
89
function updateLongBanner()
90
{
91
if(longBanner == null)
92
{
93
longBanner = document.getElementById('adLongContainer');
94
}
95
96
if(longBanner != null && longBanner.display != "none")
97
{
98
if(isMobile())
99
{
100
longBanner.style.left = "50%";
101
longBanner.style.marginRight = "-50%";
102
103
var p = window.innerHeight - longBanner.offsetHeight;
104
105
longBanner.style.top = p + "px";
106
longBanner.style.transform = "scale( 1, 1) translate(-50%, -10px)";
107
}
108
else
109
{
110
longBanner.style.bottom = 0 + "px";
111
longBanner.style.width = 100 + "vw";
112
113
var adContainerH = longBanner.offsetHeight;
114
var gameContainerH = gameContainer.offsetHeight;
115
116
if(adContainerH/gameContainerH > 0.3)
117
{
118
var newHeight = gameContainerH * 0.3;
119
var newScale = newHeight / adContainerH;
120
var scaleString = "scale( " + newScale + "," + newScale + ")";
121
var offsetX = 0;
122
var offsetY = (adContainerH - adContainerH*newScale)/2 - 10;
123
var translateString = "translate(" + offsetX + "px, " + offsetY + "px)";
124
longBanner.style.transform = translateString + " " + scaleString;
125
}
126
else
127
{
128
longBanner.style.transform = "scale( 1, 1) translate(0px, -10px)";
129
}
130
}
131
132
if(isMobile())
133
{
134
var p = window.innerHeight - longBanner.offsetHeight;
135
longBanner.style.top = p + "px";
136
}
137
else
138
{
139
longBanner.style.bottom = 0 + "px";
140
}
141
}
142
}
143
144
setInterval(updateAdSizes, 500);
145
146
function showMainMenuBanner()
147
{
148
hideWinCeremonyBanner();
149
hideLongBanner();
150
151
const ad = document.querySelector("#adContainer");
152
ad.style.display = "block";
153
updateAdSizes();
154
155
requestMainMenuBanner();
156
}
157
158
function hideMainMenuBanner()
159
{
160
const ad = document.querySelector("#adContainer");
161
if(ad != null) ad.style.display = "none";
162
163
const ad2 = document.querySelector("#adContainerMainMenu");
164
if(ad2 != null) ad2.style.display = "none";
165
}
166
167
function showWinCeremonyBanner(interstialRequested)
168
{
169
hideLongBanner();
170
hideMainMenuBanner();
171
172
const ad = document.querySelector("#adContainer2");
173
ad.style.display = "block";
174
updateAdSizes();
175
176
requestWinCeremonyBanner(interstialRequested);
177
}
178
179
180
function hideWinCeremonyBanner()
181
{
182
const ad = document.querySelector("#adContainer2");
183
if(ad != null) ad.style.display = "none";
184
185
const ad2 = document.querySelector("#adContainerWin");
186
if(ad2 != null) ad2.style.display = "none";
187
}
188
189
function showLongBanner()
190
{
191
hideWinCeremonyBanner();
192
hideMainMenuBanner();
193
194
const ad = document.querySelector("#adLongContainer");
195
ad.style.display = "flex";
196
updateAdSizes();
197
198
requestLongBanner();
199
}
200
201
202
function hideLongBanner()
203
{
204
const ad = document.querySelector("#adLongContainer");
205
if(ad != null) ad.style.display = "none";
206
207
const ad2 = document.querySelector("#adLongContainer2");
208
if(ad2 != null) ad2.style.display = "none";
209
}
210
211
function showLongBanner2()
212
{
213
hideWinCeremonyBanner();
214
hideMainMenuBanner();
215
216
const ad = document.querySelector("#adLongContainer2");
217
ad.style.position = "absolute";
218
ad.style.display = "block";
219
requestLongBanner2();
220
}
221
222
function showMainMenuBanner2()
223
{
224
hideWinCeremonyBanner();
225
hideLongBanner();
226
227
const ad = document.querySelector("#adContainerMainMenu");
228
ad.style.position = "absolute";
229
ad.style.display = "block";
230
requestMainMenuBanner2();
231
}
232
233
function showWinCeremonyBanner2(interstialRequested)
234
{
235
hideLongBanner();
236
hideMainMenuBanner();
237
238
const ad = document.querySelector("#adContainerWin");
239
ad.style.position = "absolute";
240
ad.style.display = "block";
241
requestWinCeremonyBanner2(interstialRequested);
242
}
243
244
245
function setElementSize(identifier, x, y, w, h)
246
{
247
const el = document.getElementById(identifier);
248
if(el != null)
249
{
250
el.style.left = x + "px";
251
el.style.top = y + "px";
252
el.style.width = w + "px";
253
el.style.height = h + "px";
254
}
255
}
256
257
function showPreGameInterstitial(audioOn)
258
{
259
showInterstitial(audioOn, 'start', 'pregame');
260
}
261
262
function showWinCeremonyInterstitial(audioOn)
263
{
264
showInterstitial(audioOn, 'next', 'winceremony')
265
}
266
267
function interstitialStart()
268
{
269
window.unityGame.SendMessage(unityFirebaseGameOjbectName, "InterstitialStart");
270
}
271
272
function interstitialError()
273
{
274
window.unityGame.SendMessage(unityFirebaseGameOjbectName, "InterstitialFailed");
275
}
276
277
function interstitialSkipped()
278
{
279
window.unityGame.SendMessage(unityFirebaseGameOjbectName, "InterstitialSkipped");
280
}
281
282
283
function interstitialComplete()
284
{
285
window.unityGame.SendMessage(unityFirebaseGameOjbectName, "InterstitialComplete");
286
}
287
288