-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1049 lines (955 loc) ยท 54.2 KB
/
index.html
File metadata and controls
1049 lines (955 loc) ยท 54.2 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
<title id="tabTitle">GOONGAMES</title>
<meta name="description" content="Play premium unblocked games effortlessly on GOONGAMES. Access advanced tab cloaking features, responsive full-screen layouts, and an optimized gaming collection.">
<meta name="keywords" content="goongames, goon games, goongames2, goongames2.vercel.app, unblocked games, school unblocked games, goon games vercel">
<meta name="robots" content="index, follow">
<link rel="canonical" href="https://goongames2.vercel.app/">
<meta property="og:type" content="website">
<meta property="og:url" content="https://goongames2.vercel.app/">
<meta property="og:title" content="GOONGAMES - Premium Unblocked Web Games">
<meta property="og:description" content="Play your favorite unblocked games seamlessly with dark themes, tab cloaking features, and full screen optimizations on GOONGAMES.">
<meta property="og:image" content="droplet.png">
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://goongames2.vercel.app/">
<meta property="twitter:title" content="GOONGAMES - Premium Unblocked Web Games">
<meta property="twitter:description" content="Play your favorite unblocked games seamlessly with dark themes, tab cloaking features, and full screen optimizations on GOONGAMES.">
<meta property="twitter:image" content="droplet.png">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="GOONGAMES">
<link id="tabIcon" rel="icon" type="image/png" href="droplet.png">
<link rel="apple-touch-icon" href="droplet.png">
<link rel="manifest" href="data:application/manifest+json,{'name':'GOONGAMES','short_name':'GOONGAMES','start_url':'index.html','display':'standalone','background_color':'#09090b','theme_color':'#3b82f6','icons':[{'src':'droplet.png','sizes':'192x192','type':'image/png'}]}">
<script src="https://cdn.tailwindcss.com"></script>
<script>
(function() {
var t = localStorage.getItem('theme') || 'dark';
if (t === 'dark') document.documentElement.classList.add('dark');
var ct = localStorage.getItem('cloakTitle'), ci = localStorage.getItem('cloakIcon');
if (ct) document.title = ct;
if (ci) {
var existingIcons = document.querySelectorAll("link[rel*='icon']");
existingIcons.forEach(function(el) { el.remove(); });
var l = document.createElement('link');
l.id = 'tabIcon'; l.rel = 'icon'; l.href = ci;
document.head.appendChild(l);
}
})();
tailwind.config = { darkMode: 'class' };
if ('serviceWorker' in navigator) window.addEventListener('load', function(){ navigator.serviceWorker.register('sw.js').catch(function(){}); });
</script>
<script src="games.js"></script>
<script src="shortcut.js"></script>
<style>
*, *::before, *::after {
-webkit-tap-highlight-color: transparent !important;
touch-action: manipulation;
-webkit-user-select: none !important;
-moz-user-select: none !important;
-ms-user-select: none !important;
user-select: none !important;
}
*::selection { background: transparent !important; }
iframe, #gameIframe, slot, embed, object {
-webkit-user-select: none !important;
user-select: none !important;
outline: none !important;
-webkit-tap-highlight-color: rgba(0,0,0,0) !important;
}
input, textarea {
-webkit-user-select: text !important;
-moz-user-select: text !important;
-ms-user-select: text !important;
user-select: text !important;
}
input::selection, textarea::selection {
background: rgba(59, 130, 246, 0.3) !important;
}
/* PRELOAD: disable transitions on first paint, removed via rAF */
.preload * { transition: none !important; }
html, body, nav, section, div, h1, h2, h3, span, button {
transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 10px; }
#toggleCircle { transition: transform 0.3s cubic-bezier(0.4,0,0.2,1); transform: translateX(0px); }
.dark #toggleCircle { transform: translateX(24px); }
.sun-visible { display: block; } .moon-visible { display: none; }
.dark .sun-visible { display: none; } .dark .moon-visible { display: block; }
.star-icon { transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.star-active { transform: scale(1.4) rotate(15deg); }
@keyframes toastIn { from { transform: translateY(100px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.toast-notify { animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.logo-img { filter: invert(1); transition: filter 0.3s ease; }
.dark .logo-img { filter: invert(0); }
#mobileModeToggle { transition: background-color 0.25s; }
#mobileModeToggle .mobile-dot { transition: transform 0.25s cubic-bezier(0.4,0,0.2,1); }
/* FIX: Use top offset trick to prevent scroll jump when locking body */
body.game-open {
overflow: hidden !important;
position: fixed !important;
width: 100% !important;
height: 100dvh !important;
max-height: 100dvh !important;
}
#gameIframe {
pointer-events: auto;
background: #000;
}
img {
-webkit-touch-callout: none !important;
pointer-events: none !important;
}
.fade-in-card {
opacity: 0;
transform: translateY(35px) scale(0.95);
transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
.fade-in-card.visible {
opacity: 1;
transform: translateY(0) scale(1);
}
.card-container-box {
transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.28), border-color 0.3s, box-shadow 0.4s;
}
.game-card-wrapper:hover .card-container-box,
.game-card-wrapper.pop-up-active .card-container-box {
border-color: #3b82f6 !important;
transform: translateY(-6px) scale(1.045);
box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.45);
}
.star-btn-container {
opacity: 0;
transform: translateY(6px) scale(0.8);
pointer-events: none;
transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.game-card-wrapper:hover .star-btn-container,
.game-card-wrapper.pop-up-active .star-btn-container {
opacity: 1;
transform: translateY(0) scale(1);
pointer-events: auto;
}
.premium-modal-backdrop {
display: flex !important;
opacity: 0;
visibility: hidden;
transition: opacity 0.3s cubic-bezier(0.25, 1, 0.5, 1), visibility 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}
.premium-modal-backdrop.modal-visible {
opacity: 1;
visibility: visible;
}
.premium-modal-card {
transform: scale(0.9) translateY(15px);
transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.premium-modal-backdrop.modal-visible .premium-modal-card {
transform: scale(1) translateY(0);
}
.filter-dropdown {
transform-origin: top center;
animation: dropdownPop 0.2s cubic-bezier(0.2, 0.9, 0.4, 1.2) forwards;
}
@keyframes dropdownPop {
from { opacity: 0; transform: scaleY(0.7); }
to { opacity: 1; transform: scaleY(1); }
}
.filter-option {
position: relative;
transition: background 0.2s;
overflow: hidden;
}
.filter-option::after {
content: '';
position: absolute;
bottom: 0; left: 0;
width: 0%;
height: 2px;
background: linear-gradient(90deg, #3b82f6, #60a5fa);
transition: width 0.3s cubic-bezier(0.2, 0.9, 0.4, 1.1);
}
.filter-option.active::after { width: 100%; }
.filter-option.active { background: #eef2ff; color: #2563eb; }
.dark .filter-option.active { background: #1e293b; color: #60a5fa; }
.game-title {
display: block;
line-height: 1.4;
max-width: 100%;
word-break: break-word;
}
/* Empty state */
#emptyState {
display: none;
grid-column: 1 / -1;
text-align: center;
padding: 3rem 1rem;
opacity: 0.4;
}
#emptyState.visible { display: block; }
</style>
</head>
<body class="preload bg-zinc-50 dark:bg-zinc-900 text-zinc-900 dark:text-zinc-100 min-h-screen font-sans overflow-x-hidden">
<div id="notification-container" class="fixed bottom-5 right-5 z-[100] flex flex-col gap-3 pointer-events-none"></div>
<!-- Confirm Close Dialog -->
<div id="confirmClose" class="hidden fixed inset-0 z-[80] bg-black/70 backdrop-blur-sm flex items-center justify-center p-4">
<div class="bg-white dark:bg-zinc-800 p-6 rounded-2xl w-full max-w-xs border border-zinc-200 dark:border-zinc-700 shadow-2xl text-center">
<p class="font-bold text-sm mb-1">Close game?</p>
<p class="text-xs opacity-50 mb-5">Your progress may be lost.</p>
<div class="flex gap-3">
<button id="confirmNo" class="flex-1 py-2 rounded-xl bg-zinc-100 dark:bg-zinc-700 text-sm font-bold active:scale-95">Cancel</button>
<button id="confirmYes" class="flex-1 py-2 rounded-xl bg-red-600 text-white text-sm font-bold active:scale-95">Close</button>
</div>
</div>
</div>
<!-- Nav -->
<nav class="sticky top-0 z-40 w-full bg-white/80 dark:bg-zinc-800/80 backdrop-blur-md border-b border-zinc-200 dark:border-zinc-700 px-4 py-3 flex flex-wrap gap-4 justify-between items-center">
<div class="flex items-center gap-2">
<img src="droplet.png" class="w-8 h-8 object-contain logo-img" alt="Logo">
<div class="flex items-baseline gap-1">
<h1 class="text-xl font-black tracking-tighter uppercase">GOONGAMES</h1>
<span class="text-[10px] font-bold text-blue-500 uppercase">Remake</span>
</div>
</div>
<div class="flex-grow max-w-md relative order-3 sm:order-none">
<div class="relative">
<input type="text" id="searchInput" placeholder="Search games..."
class="w-full bg-zinc-100 dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 rounded-full py-2 pl-10 pr-12 focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm">
<svg class="absolute left-3 top-2.5 text-zinc-400" xmlns="http://www.w3.org/2000/svg" width="16" height="16"
viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>
</svg>
<!-- Clear search button (hidden by default) -->
<button id="clearSearch" class="hidden absolute right-10 top-1/2 -translate-y-1/2 p-1 rounded-full text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-200 transition-colors">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18M6 6l12 12"/></svg>
</button>
<div id="filterButton" class="absolute right-2 top-1/2 -translate-y-1/2 p-1.5 rounded-full cursor-pointer hover:bg-zinc-200 dark:hover:bg-zinc-700 transition-colors">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"/></svg>
</div>
<div id="filterDropdown" class="filter-dropdown hidden absolute right-0 top-full mt-2 bg-white dark:bg-zinc-800 rounded-xl shadow-2xl border border-zinc-200 dark:border-zinc-700 z-50 min-w-[140px] overflow-hidden">
<div class="filter-option px-4 py-2.5 text-[11px] font-bold uppercase tracking-wide cursor-pointer" data-sort="default">Default</div>
<div class="filter-option px-4 py-2.5 text-[11px] font-bold uppercase tracking-wide cursor-pointer" data-sort="alpha">0 โ Z</div>
<div class="filter-option px-4 py-2.5 text-[11px] font-bold uppercase tracking-wide cursor-pointer" data-sort="newest">Newest โ Oldest</div>
</div>
</div>
</div>
<button id="settingsBtn" class="p-2 hover:bg-zinc-200 dark:hover:bg-zinc-700 rounded-full transition-all active:scale-90 relative z-50">
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15-.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/>
<circle cx="12" cy="12" r="3"/>
</svg>
</button>
</nav>
<!-- Home View -->
<main id="homeView" class="max-w-7xl mx-auto p-6 space-y-12">
<section id="shortcutsSection" class="hidden">
<div class="flex justify-between items-center mb-6 cursor-pointer select-none group" onclick="toggleShortcutsDropdown()">
<h2 class="text-xs font-black uppercase tracking-[0.3em] opacity-40 flex items-center gap-2 group-hover:opacity-100 transition-opacity">
Quick Links
</h2>
<svg id="shortcutsChevron" class="text-zinc-400 group-hover:text-zinc-600 dark:group-hover:text-zinc-300 transition-transform duration-300" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="m6 9 6 6 6-6"/>
</svg>
</div>
<div id="shortcutGrid" class="flex flex-wrap gap-6 border-b border-zinc-200 dark:border-zinc-800 pb-12 transition-all duration-300"></div>
</section>
<section id="favoritesSection" class="hidden">
<div class="flex justify-between items-center mb-6 cursor-pointer select-none group" onclick="toggleFavDropdown()">
<h2 class="text-xs font-black uppercase tracking-[0.3em] text-yellow-500 flex items-center gap-2">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="currentColor">
<path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"/>
</svg>
Favourited
</h2>
<svg id="favChevron" class="text-zinc-400 group-hover:text-yellow-500 transition-transform duration-300" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="m6 9 6 6 6-6"/>
</svg>
</div>
<div id="favGrid" class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-6 border-b border-zinc-200 dark:border-zinc-800 pb-12 transition-all duration-300"></div>
</section>
<section id="librarySection">
<div class="flex justify-between items-center mb-6">
<h2 class="text-xs font-black uppercase tracking-[0.3em] opacity-40">Library</h2>
<span id="gameCount" class="text-[10px] font-bold opacity-30 uppercase tracking-widest"></span>
</div>
<div id="gameGrid" class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-6">
<div id="emptyState">
<p class="text-2xl mb-2">๐ฎ</p>
<p class="text-xs font-bold uppercase tracking-widest">No games found</p>
</div>
</div>
</section>
</main>
<!-- Player View -->
<section id="playerView" class="hidden fixed inset-0 h-[100dvh] max-h-[100dvh] z-50 bg-black flex flex-col overflow-hidden select-none">
<button id="exitFullscreenBtn" onclick="toggleFullscreenMode()" title="Exit Fullscreen"
class="hidden absolute top-4 left-4 z-[60] p-3 rounded-xl bg-zinc-900/90 text-zinc-200 backdrop-blur-md border border-white/10 hover:bg-zinc-800 transition-all active:scale-90 shadow-2xl flex items-center justify-center">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M4 14h6v6M20 10h-6V4M14 10l7-7M10 14l-7 7"/>
</svg>
</button>
<div id="playerHeader" class="p-4 bg-zinc-900 flex justify-between items-center border-b border-zinc-800 relative z-50">
<h2 id="activeGameTitle" class="font-bold text-white uppercase tracking-widest text-sm truncate max-w-[50%]">Game Title</h2>
<div class="flex items-center gap-2 relative z-50">
<button id="refreshBtn" title="Refresh game"
class="p-2 rounded-full hover:bg-zinc-800 transition-all active:scale-90 relative z-50 pointer-events-auto">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"
class="text-zinc-400">
<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/>
<path d="M21 3v5h-5"/>
<path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/>
<path d="M8 16H3v5"/>
</svg>
</button>
<button id="closePlayer"
class="px-6 py-2 bg-red-600 hover:bg-red-700 text-white rounded-full font-bold transition-all active:scale-95 text-xs uppercase relative z-50 pointer-events-auto">Close</button>
</div>
</div>
<div class="flex-grow flex items-center justify-center relative bg-black overflow-hidden w-full h-full p-2">
<iframe id="gameIframe" src="about:blank" class="max-w-full max-h-full w-full h-full border-0 block"
allow="autoplay; fullscreen; gamepad; keyboard-map"
sandbox="allow-downloads allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-scripts allow-same-origin allow-storage-access-by-user-activation"></iframe>
</div>
<div id="playerFooter" class="p-3 bg-zinc-900 flex gap-6 justify-center border-t border-zinc-800 relative z-50">
<button onclick="toggleFullscreenMode()"
class="text-zinc-400 hover:text-white text-[10px] font-bold uppercase tracking-widest active:scale-95 relative z-50 pointer-events-auto">Fullscreen</button>
<button id="tabBtn"
class="text-zinc-400 hover:text-white text-[10px] font-bold uppercase tracking-widest active:scale-95 relative z-50 pointer-events-auto">New Tab</button>
</div>
</section>
<!-- Settings Modal -->
<div id="settingsModal" class="premium-modal-backdrop fixed inset-0 z-[60] bg-black/60 backdrop-blur-sm items-center justify-center p-4">
<div id="settingsCard" class="premium-modal-card bg-white dark:bg-zinc-800 p-8 rounded-3xl w-full max-w-sm border border-zinc-200 dark:border-zinc-700 shadow-2xl">
<h2 class="text-xl font-black mb-6 text-center uppercase tracking-tighter">Settings</h2>
<div class="flex justify-between items-center mb-4 bg-zinc-100 dark:bg-zinc-700/50 p-4 rounded-2xl">
<span class="text-[10px] font-bold opacity-50 uppercase tracking-widest">Theme</span>
<button id="themeToggle" class="relative w-14 h-8 bg-zinc-300 dark:bg-blue-600 rounded-full p-1 transition-colors duration-300 active:scale-95">
<div id="toggleCircle" class="w-6 h-6 bg-white rounded-full shadow-md flex items-center justify-center">
<svg class="sun-visible w-4 h-4 text-yellow-500" fill="currentColor" viewBox="0 0 20 20">
<path d="M10 2a1 1 0 011 1v1a1 1 0 11-2 0V3a1 1 0 011-1zm4 8a4 4 0 11-8 0 4 4 0 018 0zm-.464 4.95l.707.707a1 1 0 001.414-1.414l-.707-.707a1 1 0 00-1.414 1.414zm2.12-10.607a1 1 0 010 1.414l-.706.707a1 1 0 11-1.414-1.414l.707-.707a1 1 0 011.414 0z"/>
</svg>
<svg class="moon-visible w-4 h-4 text-blue-500" fill="currentColor" viewBox="0 0 20 20">
<path d="M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z"/>
</svg>
</div>
</button>
</div>
<div class="flex justify-between items-center mb-4 bg-zinc-100 dark:bg-zinc-700/50 p-4 rounded-2xl">
<div>
<span class="text-[10px] font-bold opacity-50 uppercase tracking-widest block">Force Mobile Mode</span>
<span class="text-[10px] opacity-40">Gamepad overlay when playing</span>
</div>
<button id="mobileModeToggle" class="relative w-14 h-8 bg-zinc-300 rounded-full p-1 transition-colors duration-300 active:scale-95">
<div class="mobile-dot w-6 h-6 bg-white rounded-full shadow-md"></div>
</button>
</div>
<button id="openCloakBtn" class="w-full py-4 mb-4 bg-blue-600 text-white rounded-xl text-xs font-bold uppercase tracking-widest active:scale-95">Tab Cloak Settings</button>
<button id="closeSettings" class="w-full py-3 bg-zinc-900 dark:bg-zinc-100 text-white dark:text-zinc-900 rounded-xl font-bold transition active:scale-95">DONE</button>
</div>
</div>
<!-- Cloak Modal -->
<div id="cloakModal" class="premium-modal-backdrop fixed inset-0 z-[70] bg-black/80 backdrop-blur-md items-center justify-center p-4">
<div id="cloakCard" class="premium-modal-card bg-white dark:bg-zinc-800 p-8 rounded-3xl w-full max-w-sm border border-zinc-200 dark:border-zinc-700">
<h2 class="text-xl font-black mb-6 text-center uppercase tracking-tighter">Tab Cloak</h2>
<div class="space-y-4">
<input type="text" id="cloakTitleInput" placeholder="New Title"
class="w-full bg-zinc-100 dark:bg-zinc-700 border border-zinc-600 rounded-xl py-3 px-4 text-sm outline-none">
<div class="flex gap-2">
<input type="text" id="cloakIconInput" placeholder="Icon URL"
class="flex-grow bg-zinc-100 dark:bg-zinc-700 border border-zinc-600 rounded-xl py-3 px-4 text-sm outline-none">
<button type="button" onclick="document.getElementById('cloakFileSelect').click()" class="bg-zinc-200 dark:bg-zinc-600 hover:bg-zinc-300 dark:hover:bg-zinc-500 text-xs px-4 rounded-xl font-bold border border-zinc-500/20 whitespace-nowrap active:scale-95 transition-transform">Upload</button>
</div>
<input type="file" id="cloakFileSelect" accept="image/*" class="hidden" onchange="handleCloakFileUpload(this)">
<button onclick="saveCloak()" class="w-full py-3 bg-blue-600 text-white rounded-xl text-xs font-bold uppercase active:scale-95">Apply</button>
<button onclick="resetCloak()" class="w-full py-2 bg-zinc-600 text-zinc-300 rounded-xl text-[10px] font-bold uppercase active:scale-95">Reset</button>
<button id="closeCloak" class="w-full mt-4 text-xs font-bold opacity-50 active:scale-95">Back</button>
</div>
</div>
</div>
<script>
// โโโ Remove preload class on first rAF to enable transitions cleanly โโโ
requestAnimationFrame(function() {
requestAnimationFrame(function() {
document.body.classList.remove('preload');
});
});
// โโโ Helpers โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
function isMobileMode() { return localStorage.getItem('forceMobile') === 'true'; }
function escapeHtml(str) {
return str.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,''');
}
function loadCloakInputs() {
var savedTitle = localStorage.getItem('cloakTitle') || '';
var savedIconRaw = localStorage.getItem('cloakIconRaw') || localStorage.getItem('cloakIcon') || '';
var titleInput = document.getElementById('cloakTitleInput');
var iconInput = document.getElementById('cloakIconInput');
if (titleInput) titleInput.value = savedTitle;
if (iconInput) iconInput.value = savedIconRaw;
}
function getGameUrl(originalUrl, gameMobileFlag) {
if (!isMobileMode() || !gameMobileFlag) return originalUrl;
return 'mobile.html?url=' + encodeURIComponent(originalUrl) + '&mobile=true';
}
function syncMobileToggle() {
var btn = document.getElementById('mobileModeToggle');
var dot = btn && btn.querySelector('.mobile-dot');
if (!btn) return;
var on = isMobileMode();
btn.style.background = on ? '#22c55e' : '';
if (dot) dot.style.transform = on ? 'translateX(24px)' : 'translateX(0)';
}
function showNotification(text) {
var c = document.getElementById('notification-container');
var t = document.createElement('div');
t.className = "toast-notify bg-zinc-900 dark:bg-zinc-100 text-white dark:text-zinc-900 px-5 py-3 rounded-2xl shadow-xl text-xs font-bold uppercase tracking-widest border border-white/10";
t.innerText = text;
c.appendChild(t);
setTimeout(function() {
t.style.opacity = '0';
t.style.transform = 'translateY(-20px)';
t.style.transition = 'all 0.4s ease';
setTimeout(function() { t.remove(); }, 400);
}, 2500);
}
// โโโ Cloak โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
window.handleCloakFileUpload = function(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
document.getElementById('cloakIconInput').value = e.target.result;
showNotification("Local icon image loaded! Click Apply.");
};
reader.readAsDataURL(input.files[0]);
}
};
function saveCloak() {
var title = document.getElementById('cloakTitleInput').value;
var iconUrl = document.getElementById('cloakIconInput').value;
var pi = iconUrl;
if (iconUrl && !iconUrl.startsWith('data:')) {
pi = "https://images.weserv.nl/?url=" + encodeURIComponent(iconUrl) + "&w=32&h=32";
}
if (title) {
document.title = title;
localStorage.setItem('cloakTitle', title);
}
if (iconUrl) {
document.querySelectorAll("link[rel*='icon']").forEach(function(el) { el.remove(); });
var l = document.createElement('link');
l.id = 'tabIcon'; l.rel = 'icon'; l.href = pi;
document.head.appendChild(l);
localStorage.setItem('cloakIcon', pi);
localStorage.setItem('cloakIconRaw', iconUrl);
}
showNotification("Cloak Applied!");
}
function resetCloak() {
localStorage.removeItem('cloakTitle');
localStorage.removeItem('cloakIcon');
localStorage.removeItem('cloakIconRaw');
location.reload();
}
// โโโ State โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
var grid = document.getElementById('gameGrid');
var favGrid = document.getElementById('favGrid');
var favSection = document.getElementById('favoritesSection');
var searchInput = document.getElementById('searchInput');
var home = document.getElementById('homeView');
var player = document.getElementById('playerView');
var iframe = document.getElementById('gameIframe');
var activeTitle = document.getElementById('activeGameTitle');
var favorites = [];
try { favorites = JSON.parse(localStorage.getItem('favorites') || '[]'); } catch(e) { favorites = []; }
var currentGameUrl = '';
var savedScrollPosition = 0;
var favExpanded = localStorage.getItem('favExpanded') !== 'false';
var shortcutsExpanded= localStorage.getItem('shortcutsExpanded') !== 'false';
var currentSort = localStorage.getItem('gameSort') || 'default';
var searchDebounce = null;
// โโโ Sort โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
function sortGamesArray(arr) {
var copy = arr.slice();
if (currentSort === 'alpha') copy.sort(function(a,b){ return a.title.localeCompare(b.title); });
if (currentSort === 'newest') copy.sort(function(a,b){ return (Number(b.id)||0) - (Number(a.id)||0); });
return copy;
}
// โโโ Hyphenated titles โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
function applyHyphenatedTitles() {
setTimeout(function() {
var titleElements = document.querySelectorAll('.game-title');
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
titleElements.forEach(function(el) {
var raw = el.getAttribute('data-raw');
if (!raw) return;
var maxWidth = el.clientWidth;
if (maxWidth < 20) return;
var style = getComputedStyle(el);
var fontStr = (style.fontWeight || '700') + ' ' + (style.fontSize || '10px') + ' ' + (style.fontFamily || 'sans-serif');
ctx.font = fontStr;
function measure(t) { return ctx.measureText(t).width; }
// If raw title fits on one line, leave innerHTML untouched (preserves <mark> highlights)
if (measure(raw) <= maxWidth) return;
// Find best split point on raw text
var hyphen = ' -';
var bestSplit = 0;
for (var i = 1; i <= raw.length; i++) {
if (measure(raw.slice(0, i) + hyphen) <= maxWidth) bestSplit = i;
else break;
}
if (bestSplit === 0) bestSplit = Math.floor(raw.length * 0.5);
// Re-render innerHTML: split the existing innerHTML at the same character offset
// by splitting the raw text and rebuilding around any <mark> tags
var currentHTML = el.innerHTML;
// Simple case: no marks, just set directly
if (currentHTML.indexOf('<mark') === -1) {
el.innerHTML = raw.slice(0, bestSplit) + '‑<br>' + raw.slice(bestSplit);
} else {
// Has highlights: split the raw text and patch marks back in
var part1raw = raw.slice(0, bestSplit);
var part2raw = raw.slice(bestSplit);
// Re-escape for safe insertion
function esc(s){ return s.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); }
// Re-apply mark highlight on each part
var searchTerm = el.getAttribute('data-search');
if (searchTerm) {
var re = new RegExp('(' + searchTerm.replace(/[-\/\\^$*+?.()|[\]{}]/g,'\\$&') + ')', 'gi');
var mark = '<mark class="bg-blue-500/30 text-blue-600 dark:text-blue-400 font-bold rounded px-0.5">$1</mark>';
el.innerHTML = esc(part1raw).replace(re, mark) + '‑<br>' + esc(part2raw).replace(re, mark);
} else {
el.innerHTML = esc(part1raw) + '‑<br>' + esc(part2raw);
}
}
});
}, 30);
}
// โโโ Scroll lock / unlock (no jump) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
function lockScroll() {
savedScrollPosition = window.scrollY;
document.body.style.top = '-' + savedScrollPosition + 'px';
document.body.classList.add('game-open');
suspendBackgroundWork();
}
function unlockScroll() {
var pos = savedScrollPosition;
document.body.classList.remove('game-open');
document.body.style.top = '';
window.scrollTo({ top: pos, behavior: 'instant' });
resumeBackgroundWork();
}
// โโโ Background process suspension during gameplay โโโโโโโโโโโโโโโโโโโโโ
var _scrollObserver = null;
var _resizeHandler = null;
var _suspended = false;
function suspendBackgroundWork() {
if (_suspended) return;
_suspended = true;
// Disconnect scroll observer - no point watching cards while game is fullscreen
if (_scrollObserver) { _scrollObserver.disconnect(); }
// Stop listening to resize events
if (_resizeHandler) { window.removeEventListener('resize', _resizeHandler); }
}
function resumeBackgroundWork() {
if (!_suspended) return;
_suspended = false;
// Reconnect observer for any cards not yet visible
setupScrollFadeIn();
if (_resizeHandler) { window.addEventListener('resize', _resizeHandler); }
}
window.addEventListener('keydown', function(e) {
if (document.body.classList.contains('game-open')) {
var blocked = ['Space','ArrowUp','ArrowDown','ArrowLeft','ArrowRight','PageUp','PageDown'];
if (blocked.indexOf(e.code) > -1) {
if (document.activeElement.tagName !== 'INPUT' && document.activeElement.tagName !== 'TEXTAREA') {
e.preventDefault();
}
}
}
}, { passive: false });
// โโโ Confirm close โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
function showConfirmClose(onYes) {
var dialog = document.getElementById('confirmClose');
dialog.classList.remove('hidden');
document.getElementById('confirmYes').onclick = function() {
dialog.classList.add('hidden');
onYes();
};
document.getElementById('confirmNo').onclick = function() {
dialog.classList.add('hidden');
};
}
function doCloseGame() {
// BUG FIX: use about:blank instead of '' to avoid blank page load in Safari
iframe.src = 'about:blank';
currentGameUrl = '';
player.classList.add('hidden');
home.classList.remove('hidden');
unlockScroll();
var header = document.getElementById('playerHeader');
var footer = document.getElementById('playerFooter');
var exitBtn = document.getElementById('exitFullscreenBtn');
if (header) header.classList.remove('hidden');
if (footer) footer.classList.remove('hidden');
if (exitBtn) exitBtn.classList.add('hidden');
}
document.getElementById('closePlayer').onclick = function() {
showConfirmClose(doCloseGame);
};
// Android back button / browser back while game is open
window.addEventListener('popstate', function() {
if (!player.classList.contains('hidden')) {
showConfirmClose(doCloseGame);
}
});
document.getElementById('refreshBtn').onclick = function() {
if (currentGameUrl) {
iframe.src = 'about:blank';
setTimeout(function() { iframe.src = currentGameUrl; }, 50);
}
};
// โโโ Fullscreen โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
window.toggleFullscreenMode = function() {
var header = document.getElementById('playerHeader');
var footer = document.getElementById('playerFooter');
var exitBtn = document.getElementById('exitFullscreenBtn');
if (!header || !footer || !exitBtn) return;
var isHidden = header.classList.contains('hidden');
if (isHidden) {
header.classList.remove('hidden');
footer.classList.remove('hidden');
exitBtn.classList.add('hidden');
} else {
header.classList.add('hidden');
footer.classList.add('hidden');
exitBtn.classList.remove('hidden');
showNotification("๐บ Fullscreen Activated");
}
};
// โโโ Fav / Shortcuts dropdowns โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
window.toggleFavDropdown = function() {
favExpanded = !favExpanded;
localStorage.setItem('favExpanded', favExpanded ? 'true' : 'false');
syncFavDropdownUI();
};
function syncFavDropdownUI() {
var fg = document.getElementById('favGrid');
var chev = document.getElementById('favChevron');
if (!fg || !chev) return;
fg.style.display = favExpanded ? '' : 'none';
chev.style.transform = favExpanded ? 'rotate(0deg)' : 'rotate(-90deg)';
}
window.toggleShortcutsDropdown = function() {
shortcutsExpanded = !shortcutsExpanded;
localStorage.setItem('shortcutsExpanded', shortcutsExpanded ? 'true' : 'false');
syncShortcutsDropdownUI();
};
function syncShortcutsDropdownUI() {
var sg = document.getElementById('shortcutGrid');
var chev = document.getElementById('shortcutsChevron');
if (!sg || !chev) return;
sg.style.display = shortcutsExpanded ? '' : 'none';
chev.style.transform = shortcutsExpanded ? 'rotate(0deg)' : 'rotate(-90deg)';
}
// โโโ Touch: dismiss keyboard on tap outside search โโโโโโโโโโโโโโโโโโโโโ
document.addEventListener('touchstart', function(e) {
if (e.target !== searchInput && document.activeElement === searchInput) {
searchInput.blur();
}
}, { passive: true });
// โโโ Render card โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
function renderCard(game, filterText) {
var isFav = favorites.indexOf(game.id) !== -1;
var escapedTitle = escapeHtml(game.title);
var displayTitle = escapedTitle;
if (filterText) {
var cleanTerm = filterText.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
displayTitle = escapedTitle.replace(new RegExp("(" + cleanTerm + ")", "gi"),
'<mark class="bg-blue-500/30 text-blue-600 dark:text-blue-400 font-bold rounded px-0.5">$1</mark>');
}
return '<div class="game-card-wrapper fade-in-card group relative tracking-wide" data-card-id="' + game.id + '">' +
'<div class="star-btn-container absolute top-2 right-2 z-30">' +
'<button onclick="toggleFav(\'' + escapeHtml(game.id) + '\',event)" class="p-2 rounded-full bg-black/60 backdrop-blur-md active:scale-125 transition-transform">' +
'<svg class="star-icon ' + (isFav ? 'text-yellow-500' : 'text-white') + '" width="16" height="16" fill="' + (isFav ? 'currentColor' : 'none') + '" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">' +
'<path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"/></svg>' +
'</button>' +
'</div>' +
'<div class="cursor-pointer" onclick="playGame(\'' + escapeHtml(game.id) + '\')">' +
'<div class="card-container-box aspect-video bg-zinc-800 rounded-2xl overflow-hidden mb-3 border-2 border-transparent">' +
'<img src="' + escapeHtml(game.image) + '" class="w-full h-full object-cover" loading="lazy" alt="' + escapedTitle + '">' +
'</div>' +
'<h3 class="game-title font-bold text-[10px] uppercase tracking-widest opacity-60 group-hover:opacity-100 block w-full" data-raw="' + escapedTitle + '" data-search="' + (filterText ? escapeHtml(filterText) : '') + '">' + displayTitle + '</h3>' +
'</div>' +
'</div>';
}
// โโโ Intersection observer for fade-in โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
function setupScrollFadeIn() {
if (_scrollObserver) _scrollObserver.disconnect();
_scrollObserver = new IntersectionObserver(function(entries) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
_scrollObserver.unobserve(entry.target);
}
});
}, { threshold: 0.02 });
document.querySelectorAll('.fade-in-card:not(.visible)').forEach(function(el) {
_scrollObserver.observe(el);
});
}
// โโโ Touch swipe pop-up animations โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
function setupTouchSwipeAnimations() {
[grid, favGrid].forEach(function(g) {
if (!g) return;
g.addEventListener('touchmove', function(e) {
var touch = e.touches[0];
var element = document.elementFromPoint(touch.clientX, touch.clientY);
var card = element ? element.closest('.game-card-wrapper') : null;
document.querySelectorAll('.game-card-wrapper.pop-up-active').forEach(function(el) {
if (el !== card) el.classList.remove('pop-up-active');
});
if (card) card.classList.add('pop-up-active');
}, { passive: true });
g.addEventListener('touchend', function() {
setTimeout(function() {
document.querySelectorAll('.game-card-wrapper.pop-up-active').forEach(function(el) {
el.classList.remove('pop-up-active');
});
}, 250);
}, { passive: true });
});
}
// โโโ Main init โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
function init(filter) {
filter = filter || '';
if (typeof GAMES_DATA === 'undefined') {
grid.innerHTML = '<div id="emptyState" class="visible col-span-full text-center py-12 opacity-40"><p class="text-2xl mb-2">โ ๏ธ</p><p class="text-xs font-bold uppercase tracking-widest">games.js failed to load</p></div>';
return;
}
var fl = filter.toLowerCase();
var filteredGames = GAMES_DATA.filter(function(g) { return g.title.toLowerCase().indexOf(fl) !== -1; });
var sortedGames = sortGamesArray(filteredGames);
// Game count
var countEl = document.getElementById('gameCount');
if (countEl) countEl.textContent = sortedGames.length + ' game' + (sortedGames.length !== 1 ? 's' : '');
// Empty state
if (sortedGames.length === 0) {
grid.innerHTML = '<div class="col-span-full text-center py-12 opacity-40"><p class="text-2xl mb-2">๐ฎ</p><p class="text-xs font-bold uppercase tracking-widest">No games found</p></div>';
} else {
grid.innerHTML = sortedGames.map(function(game) { return renderCard(game, filter); }).join('');
}
// Favourites (only show if no active search)
var favGames = GAMES_DATA.filter(function(g) { return favorites.indexOf(g.id) !== -1; });
var favFiltered = favGames.filter(function(g) { return g.title.toLowerCase().indexOf(fl) !== -1; });
var sortedFav = sortGamesArray(favFiltered);
if (sortedFav.length && !filter) {
favSection.classList.remove('hidden');
favGrid.innerHTML = sortedFav.map(function(game) { return renderCard(game, filter); }).join('');
} else {
favSection.classList.add('hidden');
favGrid.innerHTML = ''; // clear stale markup
}
// Hide Quick Links while searching
var ss = document.getElementById('shortcutsSection');
if (ss) ss.style.display = filter ? 'none' : '';
syncFavDropdownUI();
syncShortcutsDropdownUI();
setupScrollFadeIn();
setupTouchSwipeAnimations();
applyHyphenatedTitles();
}
// โโโ Favorites โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
window.toggleFav = function(id, event) {
event.stopPropagation();
var game = (typeof GAMES_DATA !== 'undefined') && GAMES_DATA.find(function(g) { return g.id === id; });
if (!game) return;
var idx = favorites.indexOf(id);
var adding = idx === -1;
if (adding) {
favorites.push(id);
showNotification("Added " + game.title + " to Favourites");
} else {
favorites.splice(idx, 1);
showNotification("Removed " + game.title);
}
localStorage.setItem('favorites', JSON.stringify(favorites));
// Patch every star button for this game ID without re-rendering the whole grid
document.querySelectorAll('[data-card-id="' + id + '"]').forEach(function(card) {
var svg = card.querySelector('.star-icon');
var btn = card.querySelector('.star-btn-container button');
if (!svg) return;
if (adding) {
svg.setAttribute('fill', 'currentColor');
svg.classList.remove('text-white');
svg.classList.add('text-yellow-500', 'star-active');
setTimeout(function() { svg.classList.remove('star-active'); }, 400);
} else {
svg.setAttribute('fill', 'none');
svg.classList.remove('text-yellow-500');
svg.classList.add('text-white');
}
});
// Only re-render the favourites section, not the whole library
var favGames = (typeof GAMES_DATA !== 'undefined') ? GAMES_DATA.filter(function(g) { return favorites.indexOf(g.id) !== -1; }) : [];
var sortedFav = sortGamesArray(favGames);
if (sortedFav.length) {
favSection.classList.remove('hidden');
favGrid.innerHTML = sortedFav.map(function(g) { return renderCard(g, ''); }).join('');
syncFavDropdownUI();
setupScrollFadeIn();
setupTouchSwipeAnimations();
applyHyphenatedTitles();
} else {
favSection.classList.add('hidden');
favGrid.innerHTML = '';
}
};
// โโโ Play game โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
window.playGame = function(id) {
if (typeof GAMES_DATA === 'undefined') return;
var game = GAMES_DATA.find(function(g) { return g.id === id; });
if (!game) return;
// BUG FIX: guard against undefined game.url before calling string methods
var gameUrl = game.url || '';
var proxyPatterns = ['homo-unblocker', '/uv/service/', 'unblocker.vercel.app'];
var isProxy = proxyPatterns.some(function(pattern) {
return gameUrl.toLowerCase().indexOf(pattern) !== -1;
});
if (isProxy) {
window.open(gameUrl, '_blank');
showNotification(game.title + " opened in new tab");
return;
}
activeTitle.innerText = game.title;
currentGameUrl = getGameUrl(gameUrl, game.mobile);
// Start loading immediately - don't wait for the visual transition
iframe.src = currentGameUrl;
document.getElementById('tabBtn').onclick = function() {
var cT = localStorage.getItem('cloakTitle') || "My Drive";
var cI = localStorage.getItem('cloakIcon') || "droplet.png";
var win = window.open('about:blank', '_blank');
if (win) {
win.document.write('<html><head><title>' + cT + '</title><link rel="icon" href="' + cI + '"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover"><style>body,html{margin:0;padding:0;height:100dvh;width:100%;overflow:hidden;background:#000;position:fixed}iframe{border:none;width:100%;height:100%;display:block;max-width:100%;max-height:100%;margin:auto}</style></head><body style="display:flex;align-items:center;justify-content:center"><iframe src="' + currentGameUrl + '" allow="autoplay;fullscreen;keyboard-map;gamepad" sandbox="allow-downloads allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-scripts allow-same-origin allow-storage-access-by-user-activation"></iframe></body></html>');
win.document.close();
iframe.src = 'about:blank';
currentGameUrl = '';
player.classList.add('hidden');
home.classList.remove('hidden');
unlockScroll();
} else {
alert("Please allow pop-ups!");
}
};
// Push history state so back button triggers confirm-close
history.pushState({ gameOpen: true }, '');
setTimeout(function() {
home.classList.add('hidden');
player.classList.remove('hidden');
lockScroll();
}, 150);
};
// โโโ Theme toggle โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
document.getElementById('themeToggle').onclick = function() {
document.documentElement.classList.toggle('dark');
localStorage.setItem('theme', document.documentElement.classList.contains('dark') ? 'dark' : 'light');
};
// โโโ Settings / Cloak modals โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
document.getElementById('settingsBtn').onclick = function() {
document.getElementById('settingsModal').classList.add('modal-visible');
syncMobileToggle();
loadCloakInputs(); // BUG FIX: always refresh inputs when modal opens
};
document.getElementById('closeSettings').onclick = function() {
document.getElementById('settingsModal').classList.remove('modal-visible');
};
document.getElementById('openCloakBtn').onclick = function() {
document.getElementById('cloakModal').classList.add('modal-visible');
document.getElementById('settingsModal').classList.remove('modal-visible');
};
document.getElementById('closeCloak').onclick = function() {
document.getElementById('cloakModal').classList.remove('modal-visible');
document.getElementById('settingsModal').classList.add('modal-visible');
};
// โโโ Mobile mode toggle โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
document.getElementById('mobileModeToggle').addEventListener('click', function() {
var newVal = !isMobileMode();
localStorage.setItem('forceMobile', newVal ? 'true' : 'false');
syncMobileToggle();
showNotification(newVal ? '๐ฎ Mobile Mode ON' : '๐ฎ Mobile Mode OFF');
});
// โโโ Search (debounced) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
var clearSearchBtn = document.getElementById('clearSearch');
searchInput.oninput = function(e) {
var val = e.target.value;
clearSearchBtn.classList.toggle('hidden', val.length === 0);
clearTimeout(searchDebounce);
searchDebounce = setTimeout(function() { init(val); }, 120);
};
clearSearchBtn.onclick = function() {
searchInput.value = '';
clearSearchBtn.classList.add('hidden');
searchInput.focus();
init('');
};
// โโโ Filter dropdown โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
var filterBtn = document.getElementById('filterButton');
var filterDropdown = document.getElementById('filterDropdown');
var filterOptions = document.querySelectorAll('.filter-option');
function updateFilterActive() {
filterOptions.forEach(function(opt) {
opt.classList.toggle('active', opt.getAttribute('data-sort') === currentSort);
});
}
filterBtn.addEventListener('click', function(e) {
e.stopPropagation();