forked from coldwater-10/free-sub-link
-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathscript.js
More file actions
890 lines (798 loc) · 46.7 KB
/
Copy pathscript.js
File metadata and controls
890 lines (798 loc) · 46.7 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
// script.js
// توجه: این فایل به عنوان یک ماژول بارگذاری میشود (type="module" در index.html)
import { suggestedClients, osIcons, coreIcons } from './clients.js'; // وارد کردن دادههای کلاینتها و آیکونها
import { dayBackgrounds, nightBackgrounds } from './backgrounds.js'; // وارد کردن لینکهای پسزمینه
document.addEventListener('DOMContentLoaded', function() {
// گرفتن ارجاع به عناصر DOM
const categorySelect = document.getElementById('category-select');
const itemsContainer = document.getElementById('items-container');
const linkDisplay = document.getElementById('link-display');
const selectedLink = document.getElementById('selected-link');
const copyBtn = document.getElementById('copy-btn');
const notification = document.getElementById('copy-notification');
const themeToggle = document.getElementById('theme-toggle');
const scrollTopBtn = document.getElementById('scroll-top');
const scrollBottomBtn = document.getElementById('scroll-bottom');
const rowCountSelect = document.getElementById('row-count');
const clientsContainer = document.getElementById('clients-container');
const coreFilterSelect = document.getElementById('core-filter');
const osFilterSelect = document.getElementById('os-filter');
const convertersContainer = document.getElementById('converters-container');
const toolsContainer = document.getElementById('tools-container');
const promptsContainer = document.getElementById('prompts-container');
const workersContainer = document.getElementById('workers-container');
const otherPeopleToolsContainer = document.getElementById('other-people-tools-container');
// نگاشت نام کشورها به کدهای دو حرفی ISO برای دریافت پرچم
const countryFlagMap = {
"آلبانی": "al", "آرژانتین": "ar", "ارمنستان": "am", "استرالیا": "au", "اتریش": "at",
"بحرین": "bh", "بلاروس": "by", "بلژیک": "be", "بولیوی": "bo", "برزیل": "br",
"بلغارستان": "bg", "کانادا": "ca", "چین": "cn", "کلمبیا": "co", "کرواسی": "hr",
"قبرس": "cy", "چک": "cz", "دانمارک": "dk", "اکوادور": "ec",
"استونی": "ee", "فنلاند": "fi", "فرانسه": "fr", "آلمان": "de", "جبلالطارق": "gi",
"یونان": "gr", "گواتمالا": "gt",
"هنگ کنگ": "hk", "مجارستان": "hu", "ایسلند": "is", "هند": "in",
"اندونزی": "id", "ایران": "ir", "عراق": "iq", "ایرلند": "ie",
"اسرائیل": "il", "ایتالیا": "it", "ژاپن": "jp", "اردن": "jo", "قزاقستان": "kz",
"کره جنوبی": "kr", "لتونی": "lv", "لیتوانی": "lt", "لوکزامبورگ": "lu", "مالزی": "my",
"مالت": "mt", "مکزیک": "mx", "مولداوی": "md", "هلند": "nl", "نیوزیلند": "nz",
"مقدونیه شمالی": "mk", "نروژ": "no", "نامشخص": "un",
"عمان": "om", "پاکستان": "pk", "پاراگوئه": "py", "پرو": "pe", "فیلیپین": "ph",
"لهستان": "pl", "پرتغال": "pt", "پورتوریکو": "pr", "رومانی": "ro", "روسیه": "ru",
"صربستان": "rs", "سیشل": "sc", "سنگاپور": "sg", "اسلواکی": "sk", "اسلوونی": "si",
"آفریقای جنوبی": "za", "اسپانیا": "es", "سوئد": "se", "سوئیس": "ch", "تایوان": "tw",
"تایلند": "th", "ترکیه": "tr", "اوکراین": "ua", "امارات متحده عربی": "ae",
"بریتانیا": "gb", "ایالات متحده": "us", "ویتنام": "vn"
};
// اطلاعات مبدلهای لینک اشتراک
const subscriptionConverters = [
{
name: "مبدل گیتهاب پیجز",
description: "نسخه آنلاین مبدل لینک اشتراک، قابل دسترسی از طریق GitHub Pages.",
link: "https://10ium.github.io/sub-converter_farsi",
icon: `data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M2 6.5l8 4.5 8-4.5'/><path d='M2 17.5l8-4.5 8 4.5'/><path d='M10 6L2 12l8 6' stroke-dasharray='3 3'/><path d='M14 18l8-6-8-6' stroke-dasharray='3 3'/><circle cx='12' cy='12' r='2' fill='currentColor'/></svg>`
},
{
name: "مبدل گیتهاب اکشن",
description: "مبدل لینک اشتراک مبتنی بر GitHub Actions، برای تبدیل و مدیریت لینکها.",
link: "https://github.com/10ium/subconverter",
icon: `data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M12 20v-6m0-6V2'/><path d='M12 8a2 2 0 100-4 2 2 0 000 4z'/><path d='M20 12h-6m-6 0H2'/><path d='M8 12a2 2 0 10-4 0 2 2 0 004 0z'/><path d='M12 22a2 2 0 100-4 2 2 0 000 4z'/><path d='M22 12a2 2 0 10-4 0 2 2 0 004 0z'/></svg>`
},
{
name: "مبدل آفلاین ویندوز",
description: "نسخه تقریباً آفلاین مبدل پروکسی برای ویندوز، مناسب برای استفاده محلی.",
link: "https://github.com/10ium/OfflineProxyConverter",
icon: `data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='2' y='3' width='20' height='14' rx='2' ry='2'/><path d='M8 21h8'/><path d='M12 17v4'/><path d='M12 12l-2-2m4 0l-2 2'/><path d='M10 10l2 2'/></svg>`
}
];
// اطلاعات ابزارهای دیگر
const otherTools = [
{
name: "LAN-Yar",
description: "ابزاری برای ساخت کانفیگ میهومو (کلش متا) و به اشتراکگذاری اینترنت فیلترشکن روی شبکه محلی با دستگاههای دیگر.",
sub_descriptions: [
"با این ابزار میتوانید اینترنتی که از فیلترشکن رد شده را روی شبکه به اشتراک بگذارید.",
"با دستگاههای دیگر (مثلاً گوشی اندروید به کامپیوتر یا آیفون) به اینترنت به اشتراک گذاشته شده متصل شوید."
],
link: "https://10ium.github.io/LAN-Yar/",
icon: `data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M4.93 19.07a10 10 0 010-14.14'/><path d='M7.76 16.24a6 6 0 010-8.48'/><path d='M10.59 13.41a2 2 0 010-2.82'/><path d='M12 12h.01'/><rect x='16' y='10' width='6' height='4' rx='1'/><line x1='19' y1='14' x2='19' y2='17'/></svg>`
},
{
name: "SubConfigModifier",
description: "این ابزار به شما کمک میکند تا لینکهای اشتراک VPN خود را مدیریت و سفارشی کنید.",
sub_descriptions: [
"قابلیت محدود کردن تعداد کانفیگها و انواع پروتکلها را دارد.",
"قابلیت اینو دارد که کانفیگهای پشت CDN کلادفلر را شناسایی کند.",
"برای تغییر، حذف یا اضافه کردن تنظیمات به لینکهای اشتراک خود استفاده کنید.",
"مناسب برای کاربرانی که نیاز به کنترل دقیق بر روی لینک های اشتراک خود دارند."
],
link: "https://vpnclashfa-backup.github.io/SubConfigModifier",
icon: `data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><line x1='4' y1='21' x2='4' y2='14'/><line x1='4' y1='10' x2='4' y2='3'/><line x1='12' y1='21' x2='12' y2='12'/><line x1='12' y1='8' x2='12' y2='3'/><line x1='20' y1='21' x2='20' y2='16'/><line x1='20' y1='12' x2='20' y2='3'/><line x1='1' y1='14' x2='7' y2='14'/><line x1='9' y1='8' x2='15' y2='8'/><line x1='17' y1='16' x2='23' y2='16'/></svg>`
},
{
name: "Public-DNS-Collector",
description: "لیست انواع مختلف دی ان اس",
sub_descriptions: [
"تو این مخزن از 9 تا منبع مختلف انواع دی ان اس جمع اوری میشن",
"دی ان اس ها به لیست های مختلفی تقسیم بندی میشن مثلا انواع پروتکل و انواع نوع فیلترینگ"
],
link: "https://github.com/10ium/Public-DNS-Collector",
icon: `data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><path d='M12 2a14.5 14.5 0 000 20 14.5 14.5 0 000-20'/><path d='M2 12h20'/></svg>`
},
{
name: "WG-to-Clash Converter",
description: "ابزاری برای تبدیل کانفیگهای WireGuard به فرمت Clash.",
sub_descriptions: [
"به راحتی کانفیگهای WireGuard خود را به فرمت قابل استفاده در کلاینتهای Clash تبدیل کنید.",
"این ابزار برای سادهسازی استفاده از پروتکل WireGuard در محیط Clash طراحی شده است."
],
link: "https://10ium.github.io/wg-to-clash/",
icon: `data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z'/><path d='M15.5 8.5 L19 12 L15.5 15.5'/><path d='M5 12H19'/></svg>`
}
];
// اطلاعات پرامپتها
const promptsData = [
{
name: "Coldwater Clarity Companion",
description: "یک پرامپت تحلیلی-همدلانه با نقش روانشناس حمایتی و فیلسوف منطقی/اخلاقی که پاسخهای علمی، مکالمهای و مبتنی بر شواهد میدهد.",
link: "https://github.com/10ium/free-config/blob/main/prompt/Coldwater%20Clarity%20Companion.txt",
icon: `data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M12 2a5.5 5.5 0 015.5 5.5c0 1.99-1.39 3.65-3.23 4.38'/><path d='M12 2a5.5 5.5 0 00-5.5 5.5c0 1.99 1.39 3.65 3.23 4.38'/><path d='M12 22a5.5 5.5 0 005.5-5.5c0-1.99-1.39-3.65-3.23-4.38'/><path d='M12 22a5.5 5.5 0 01-5.5-5.5c0-1.99 1.39 3.65 3.23 4.38'/><path d='M17.5 12a5.5 5.5 0 01-5.5 5.5c-1.99 0-3.65-1.39-4.38-3.23'/><path d='M6.5 12a5.5 5.5 0 005.5 5.5c1.99 0 3.65-1.39 4.38-3.23'/><path d='M6.5 12a5.5 5.5 0 015.5-5.5c1.99 0 3.65 1.39 4.38 3.23'/><path d='M17.5 12a5.5 5.5 0 00-5.5-5.5c-1.99 0-3.65 1.39-4.38 3.23'/><line x1='12' y1='1' x2='12' y2='4'/><line x1='12' y1='20' x2='12' y2='23'/></svg>`
},
{
name: "Coldwater Coder",
description: "یک متخصص کدنویسی اختصاصی و مجری دستورات فنی برای توسعهدهندگان.",
link: "https://github.com/10ium/free-config/blob/main/prompt/Coldwater%20Coder.txt",
icon: `data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='16 18 22 12 16 6'/><polyline points='8 6 2 12 8 18'/></svg>`
},
{
name: "Coldwater Translator",
description: "مترجم تخصصی زیرنویس فیلم، سریال و انیمیشن به زبان فارسی گفتاری و روان.",
link: "https://github.com/10ium/free-config/blob/main/prompt/Coldwater%20Translator.txt",
icon: `data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z'/><text x='7' y='14' font-family='Arial' font-size='7' fill='currentColor'>EN</text><text x='14' y='14' font-family='Vazirmatn' font-size='7' fill='currentColor'>FA</text></svg>`
}
];
// اطلاعات ورکرها
const workersData = [
{
name: "Ayeneh-ye Link",
description: "یک ورکر برای میرور کردن محتوای متنی لینکها، با قابلیت میرور کردن پروکسی و رول پروایدر داخلی فایلهای Clash.",
link: "https://github.com/10ium/free-config/blob/main/worker/Ayeneh-ye%20Link.txt",
icon: `data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.72'/><path d='M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.72-1.72'/><path d='M20.24 12.24a8 8 0 00-5.66-5.66'/><path d='M3.76 11.76a8 8 0 005.66 5.66'/></svg>`
},
{
name: "Iran Proxy Worker",
description: "یک ورکر برای جمعآوری و ارائه پروکسیهای http و socks ایران.",
link: "https://github.com/10ium/free-config/blob/main/worker/iran_proxy.txt",
icon: `data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='2' y='9' width='20' height='6' rx='1'/><path d='M12 3v6'/><path d='M12 15v6'/><path d='M6 3v18'/><path d='M18 3v18'/></svg>`
},
{
name: "GitHub Asset Worker",
description: "یک ورکر برای دانلود راحت تر فایلهای منتشر شده از صفحات GitHub Release.",
link: "https://github.com/10ium/free-config/blob/main/worker/GitHub_Asset.txt",
icon: `data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4'/><polyline points='7 10 12 15 17 10'/><line x1='12' y1='15' x2='12' y2='3'/></svg>`
}
];
// اطلاعات ابزارهای دیگران
const otherPeopleToolsData = [
{
name: "ابزارهای itsyebekhe",
description: "مجموعهای از ابزارهای مفید و کاربردی ساخته شده توسط itsyebekhe.",
link: "https://itsyebekhe.github.io/itsyebekhe/",
icon: `data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M14.7 6.3a1 1 0 000 1.4l1.6 1.6a1 1 0 001.4 0l3.77-3.77a6 6 0 01-7.94 7.94l-6.91 6.91a2.12 2.12 0 01-3-3l6.91-6.91a6 6 0 017.94-7.94l-3.76 3.76z'/></svg>`
},
{
name: "سایت فیلترشکن GhostOfSarina",
description: "مجموعهای از ابزارهای فیلترشکن و راهنمای ساخت کانفیگ شخصی.",
link: "https://filtershekan.sbs/",
icon: `data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z'/></svg>`
},
{
name: "ابزارهای ÐΛɌ₭ᑎΞ𐒡𐒡|𓄂𓆃",
description: "مجموعهای از ابزارهای فیلترشکن و کانفیگ رایگان.",
link: "https://darknessshade.github.io/Sub/",
icon: `data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z'/><polyline points='3.27 6.96 12 12.01 20.73 6.96'/><line x1='12' y1='22.08' x2='12' y2='12'/></svg>`
},
{
name: "سایت اینترنت آزاد (IRCF.Space)",
description: "مجموعهای از ابزارها، راهنماها و منابع مربوط به اینترنت آزاد و فیلترینگ.",
link: "https://ircf.space",
icon: `data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><line x1='2' y1='12' x2='22' y2='12'/><path d='M12 2a15.3 15.3 0 015 10 15.3 15.3 0 01-5 10 15.3 15.3 0 01-5-10 15.3 15.3 0 015-10z'/></svg>`
}
];
// نگاشت تعداد ستونها به اندازه فونت متناسب
const fontSizeMap = {
1: '1.3rem',
2: '1.1rem',
3: '1.0rem',
4: '0.9rem',
5: '0.8rem'
};
/**
* تابعی برای دریافت URL تصویر پرچم بر اساس نام کشور (با یا بدون اموجی)
* @param {string} countryNameWithEmoji - نام کشور که ممکن است شامل اموجی پرچم باشد
* @returns {string|null} URL تصویر پرچم یا null اگر یافت نشد
*/
function getFlagImageUrl(countryNameWithEmoji) {
// حذف اموجیهای پرچم از رشته برای یافتن نام کشور خالص
const cleanName = countryNameWithEmoji.replace(/[\u{1F1E6}-\u{1F1FF}\u{1F3F4}\u{E0067}-\u{E007F}]/gu, '').trim();
const countryCode = countryFlagMap[cleanName];
if (countryCode) {
// استفاده از flagcdn.com برای دریافت تصاویر پرچم (عرض 20 پیکسل)
return `https://flagcdn.com/w20/${countryCode.toLowerCase()}.png`;
}
return null;
}
/**
* تابعی برای دریافت URL آیکون Cloudflare
* @returns {string} URL تصویر آیکون Cloudflare
*/
function getCloudflareIconUrl() {
return 'https://www.cloudflare.com/favicon.ico'; // یا هر آیکون دیگری که ترجیح میدهید
}
/**
* تابع کمکی برای انتخاب تصادفی یک آیتم از آرایه
* @param {Array<string>} arr - آرایهای از رشتهها (لینکهای عکس)
* @returns {string} یک لینک عکس تصادفی
*/
function getRandomImage(arr) {
if (!arr || arr.length === 0) {
return ''; // یا یک تصویر پیشفرض
}
const randomIndex = Math.floor(Math.random() * arr.length);
return arr[randomIndex];
}
/**
* تابع برای تنظیم پسزمینه تصویری بر اساس تم
* @param {string} themeName - نام تم ('light' یا 'dark')
*/
function setBackgroundImage(themeName) {
let imageUrl;
if (themeName === 'dark') {
imageUrl = getRandomImage(nightBackgrounds);
} else {
imageUrl = getRandomImage(dayBackgrounds);
}
document.body.style.backgroundImage = `url('${imageUrl}')`;
}
/**
* تابع برای تنظیم تم (روشن یا تیره)
* @param {string} themeName - نام تم ('light' یا 'dark')
*/
function setTheme(themeName) {
document.documentElement.setAttribute('data-theme', themeName);
localStorage.setItem('theme', themeName); // ذخیره تم در Local Storage
setBackgroundImage(themeName); // تنظیم پسزمینه بر اساس تم جدید
}
/**
* تنظیم تم اولیه بر اساس Local Storage یا زمان فعلی تهران
*/
function setInitialTheme() {
const savedTheme = localStorage.getItem('theme');
if (savedTheme) {
setTheme(savedTheme); // اگر تم ذخیره شده بود، آن را اعمال کن
} else {
// تعیین زمان فعلی تهران برای تصمیمگیری در مورد تم شب/روز
const tehranTime = new Date().toLocaleString("en-US", {timeZone: "Asia/Tehran"});
const hour = new Date(tehranTime).getHours();
// شب: 7 عصر (19) تا 6 صبح - روز: 6 صبح تا 7 عصر (19)
const isNight = hour >= 19 || hour < 6;
if (isNight) {
setTheme('dark');
} else {
setTheme('light');
}
}
}
/**
* تغییر تم بین روشن و تیره
*/
function toggleTheme() {
const currentTheme = document.documentElement.getAttribute('data-theme');
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
setTheme(newTheme);
}
/**
* پر کردن منوی کشویی دستهبندی با نام دستهها از آبجکت subscriptionsData
*/
function populateCategorySelect() {
// اطمینان از وجود subscriptionsData
if (typeof subscriptionsData === 'undefined' || Object.keys(subscriptionsData).length === 0) {
console.warn("subscriptionsData is not defined or is empty. Cannot populate categories.");
const placeholder = document.createElement('option');
placeholder.textContent = "دادهای برای دستهها یافت نشد";
placeholder.disabled = true;
categorySelect.appendChild(placeholder);
return;
}
for (const categoryName of Object.keys(subscriptionsData)) {
const option = document.createElement('option');
option.value = categoryName;
// در منوی کشویی، فقط نام تمیز کشور را نمایش میدهیم (بدون اموجی)
option.textContent = categoryName.replace(/[\u{1F1E6}-\u{1F1FF}\u{1F3F4}\u{E0067}-\u{E007F}]/gu, '').trim();
categorySelect.appendChild(option);
}
}
/**
* نمایش آیتمهای مربوط به یک دسته
* @param {string} categoryName - نام دسته
*/
function showCategoryItems(categoryName) {
const items = subscriptionsData[categoryName];
if (!items) {
itemsContainer.innerHTML = '<p class="placeholder-text">دادهای برای این دسته یافت نشد.</p>';
return;
}
let itemsHTML = '<div class="items-list">';
for (const itemName of Object.keys(items)) {
let itemDisplayContent = itemName.replace(/[\u{1F1E6}-\u{1F1FF}\u{1F3F4}\u{E0067}-\u{E007F}]/gu, '').trim(); // نام تمیز
const link = items[itemName]; // دریافت لینک واقعی برای بررسی Cloudflare
const flagUrl = getFlagImageUrl(itemName); // دریافت URL پرچم
const isCloudflareLink = link.toLowerCase().includes('cloudflare'); // بررسی وجود 'cloudflare' در لینک
itemsHTML += `
<button class="item-button" data-category="${categoryName}" data-item="${itemName}">
`;
if (flagUrl) {
itemsHTML += `<img src="${flagUrl}" alt="${itemDisplayContent} flag" class="item-flag-icon">`;
}
if (isCloudflareLink) {
itemsHTML += `<img src="${getCloudflareIconUrl()}" alt="Cloudflare icon" class="item-cloudflare-icon">`;
}
itemsHTML += `<span>${itemDisplayContent}</span>
</button>
`;
}
itemsHTML += '</div>';
itemsContainer.innerHTML = itemsHTML;
// اضافه کردن Event Listener به دکمههای آیتم جدید
document.querySelectorAll('.item-button').forEach(button => {
button.addEventListener('click', function() {
const category = this.getAttribute('data-category');
const item = this.getAttribute('data-item');
const link = subscriptionsData[category][item];
showLink(link); // نمایش لینک انتخاب شده
});
});
}
/**
* نمایش لینک انتخابی
* @param {string} link - لینک مورد نظر برای نمایش
*/
function showLink(link) {
selectedLink.textContent = link;
linkDisplay.classList.remove('hidden');
// اسکرول نرم به بخش نمایش لینک
linkDisplay.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
/**
* کپی کردن لینک به کلیپبورد
*/
function copyLink() {
const link = selectedLink.textContent;
if (!link) return;
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(link).then(() => {
showNotification();
}).catch(err => {
console.error('Failed to copy using Clipboard API: ', err);
fallbackCopyTextToClipboard(link);
});
} else {
fallbackCopyTextToClipboard(link);
}
}
/**
* روش جایگزین برای کپی کردن متن به کلیپبورد (برای مرورگرهای قدیمیتر)
* @param {string} text - متنی که باید کپی شود
*/
function fallbackCopyTextToClipboard(text) {
const textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.top = '0';
textArea.style.left = '0';
textArea.style.width = '2em';
textArea.style.height = '2em';
textArea.style.padding = '0';
textArea.style.border = 'none';
textArea.style.outline = 'none';
textArea.style.boxShadow = 'none';
textArea.style.background = 'transparent';
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
document.execCommand('copy');
showNotification();
} catch (err) {
console.error('Fallback: Oops, unable to copy', err);
}
document.body.removeChild(textArea);
}
/**
* نمایش نوتیفیکیشن کپی موفقیتآمیز
*/
function showNotification() {
notification.classList.add('show');
setTimeout(() => {
notification.classList.remove('show');
}, 2500);
}
/**
* اسکرول به بالای صفحه
*/
function scrollToTop() {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
}
/**
* اسکرول به پایین صفحه
*/
function scrollToBottom() {
window.scrollTo({
top: document.body.scrollHeight,
behavior: 'smooth'
});
}
/**
* تنظیم تعداد ستونهای گرید و اندازه فونت آیتمها
* @param {number} count - تعداد ستونها
*/
function setGridColumns(count) {
// این تابع متغیر CSS را تنظیم میکند که سپس توسط CSS Grid استفاده میشود.
document.documentElement.style.setProperty('--grid-columns', count);
// تنظیم اندازه فونت بر اساس تعداد ستونها
const fontSize = fontSizeMap[count] || fontSizeMap[2]; // اگر مقدار نامعتبر بود، از پیشفرض (2 ستون) استفاده کن
document.documentElement.style.setProperty('--item-font-size', fontSize);
}
/**
* پر کردن فیلترهای هسته و سیستم عامل
*/
function populateClientFilters() {
const coreTypes = new Set();
const osTypes = new Set();
suggestedClients.forEach(client => {
if (client.core_type) {
coreTypes.add(client.core_type);
}
if (client.download) {
for (const os in client.download) {
let displayOsName = os.charAt(0).toUpperCase() + os.slice(1);
if (os === "router_os") displayOsName = "Router OS";
if (os === "tvos") displayOsName = "tvOS";
osTypes.add(displayOsName);
}
}
});
// 1. تنظیم فیلتر هسته
coreFilterSelect.innerHTML = '';
const placeholderCore = document.createElement('option');
placeholderCore.value = "";
placeholderCore.textContent = "--- انتخاب هسته ---";
placeholderCore.selected = true;
placeholderCore.disabled = true;
coreFilterSelect.appendChild(placeholderCore);
// اضافه کردن گزینه "همه"
const allCoreOption = document.createElement('option');
allCoreOption.value = "all";
allCoreOption.textContent = "همه هستهها";
coreFilterSelect.appendChild(allCoreOption);
coreTypes.forEach(type => {
const option = document.createElement('option');
option.value = type;
option.textContent = type;
coreFilterSelect.appendChild(option);
});
// 2. تنظیم فیلتر سیستم عامل
osFilterSelect.innerHTML = '';
const placeholderOs = document.createElement('option');
placeholderOs.value = "";
placeholderOs.textContent = "--- انتخاب سیستم عامل ---";
placeholderOs.selected = true;
placeholderOs.disabled = true;
osFilterSelect.appendChild(placeholderOs);
// اضافه کردن گزینه "همه"
const allOsOption = document.createElement('option');
allOsOption.value = "all";
allOsOption.textContent = "همه سیستمعاملها";
osFilterSelect.appendChild(allOsOption);
osTypes.forEach(type => {
const option = document.createElement('option');
option.value = type;
option.textContent = type;
osFilterSelect.appendChild(option);
});
}
/**
* رندر کردن کلاینتهای پیشنهادی در رابط کاربری بر اساس فیلترها
*/
function renderClients() {
if (!clientsContainer) {
console.error("Clients container not found.");
return;
}
if (!suggestedClients || suggestedClients.length === 0) {
clientsContainer.innerHTML = '<p class="placeholder-text">اطلاعات کلاینتها در دسترس نیست.</p>';
return;
}
const selectedCore = coreFilterSelect ? coreFilterSelect.value : "";
const selectedOs = osFilterSelect ? osFilterSelect.value : "";
clientsContainer.innerHTML = '';
// اگر یکی از فیلترها روی مقدار پیشفرض خالی باشد، رندر نکن.
if (selectedCore === "" || selectedOs === "") {
clientsContainer.innerHTML = '<p class="placeholder-text">لطفاً ابتدا فیلترهای هسته و سیستم عامل را انتخاب کنید تا کلاینتها نمایش داده شوند.</p>';
return;
}
const filteredClients = suggestedClients.filter(client => {
const matchesCore = selectedCore === "all" || client.core_type === selectedCore;
const matchesOs = selectedOs === "all" || (client.download && Object.keys(client.download).some(osKey => {
let displayOsName = osKey.charAt(0).toUpperCase() + osKey.slice(1);
if (osKey === "router_os") displayOsName = "Router OS";
if (osKey === "tvos") displayOsName = "tvOS";
return displayOsName === selectedOs;
}));
return matchesCore && matchesOs;
});
if (filteredClients.length === 0) {
clientsContainer.innerHTML = '<p class="placeholder-text">هیچ کلاینتی با فیلترهای انتخاب شده یافت نشد.</p>';
return;
}
filteredClients.forEach(client => {
const clientCard = document.createElement('div');
clientCard.classList.add('client-card');
const clientHeader = document.createElement('div');
clientHeader.classList.add('client-header');
if (client.core_icon) {
const coreIcon = document.createElement('img');
coreIcon.src = client.core_icon;
coreIcon.alt = `${client.name} core icon`;
coreIcon.classList.add('core-icon');
coreIcon.onerror = function() { this.style.display='none'; };
clientHeader.appendChild(coreIcon);
}
const clientName = document.createElement('h3');
clientName.textContent = client.name;
clientHeader.appendChild(clientName);
clientCard.appendChild(clientHeader);
const clientDescription = document.createElement('p');
clientDescription.classList.add('client-description');
clientDescription.textContent = client.description;
clientCard.appendChild(clientDescription);
const osIconsContainer = document.createElement('div');
osIconsContainer.classList.add('os-icons-container');
if (client.os_icons) {
for (const osKey in client.download) { // از client.download استفاده میکنیم تا مطمئن شویم آیکون برای پلتفرم موجود است
if (client.os_icons[osKey]) {
const osIcon = document.createElement('img');
osIcon.src = client.os_icons[osKey];
osIcon.alt = osKey;
osIcon.title = osKey.charAt(0).toUpperCase() + osKey.slice(1); // نمایش نام سیستم عامل در هاور
osIcon.onerror = function() { this.style.display='none'; };
osIconsContainer.appendChild(osIcon);
}
}
}
clientCard.appendChild(osIconsContainer);
const downloadLinksDiv = document.createElement('div');
downloadLinksDiv.classList.add('download-links');
if (client.download) {
for (const platform in client.download) {
const downloadLink = document.createElement('a');
downloadLink.href = client.download[platform];
downloadLink.target = "_blank";
downloadLink.rel = "noopener noreferrer";
let displayPlatformName = platform.charAt(0).toUpperCase() + platform.slice(1);
if (platform === "router_os") displayPlatformName = "Router OS";
if (platform === "tvos") displayPlatformName = "tvOS";
downloadLink.textContent = `دانلود برای ${displayPlatformName}`;
downloadLinksDiv.appendChild(downloadLink);
}
}
clientCard.appendChild(downloadLinksDiv);
clientsContainer.appendChild(clientCard);
});
}
/**
* رندر کردن مبدلهای لینک اشتراک در رابط کاربری
*/
function renderConverters() {
if (!convertersContainer) {
console.error("Converters container not found.");
return;
}
if (!subscriptionConverters || subscriptionConverters.length === 0) {
convertersContainer.innerHTML = '<p class="placeholder-text">اطلاعات مبدلها در دسترس نیست.</p>';
return;
}
convertersContainer.innerHTML = '';
subscriptionConverters.forEach(converter => {
const converterCard = document.createElement('div');
converterCard.classList.add('converter-card');
if (converter.icon) {
const icon = document.createElement('img');
icon.src = converter.icon;
icon.alt = `${converter.name} icon`;
icon.classList.add('card-icon');
icon.onerror = function() { this.style.display='none'; };
converterCard.appendChild(icon);
}
const converterName = document.createElement('h3');
converterName.textContent = converter.name;
converterCard.appendChild(converterName);
const converterDescription = document.createElement('p');
converterDescription.textContent = converter.description;
converterCard.appendChild(converterDescription);
const converterLink = document.createElement('a');
converterLink.href = converter.link;
converterLink.target = "_blank";
converterLink.rel = "noopener noreferrer";
converterLink.classList.add('button');
converterLink.textContent = "مشاهده مبدل";
converterCard.appendChild(converterLink);
convertersContainer.appendChild(converterCard);
});
}
/**
* تابعی برای تبدیل لینکهای Markdown به HTML
* @param {string} markdownText - متنی که شامل لینکهای Markdown است
* @returns {string} متنی با لینکهای HTML
*/
function convertMarkdownLinksToHtml(markdownText) {
// استفاده از regex برای پیدا کردن لینکهای Markdown و تبدیل آنها به تگ <a>
const regex = /\[([^\]]+)\]\((https?:\/\/[^\s]+)\)/g;
return markdownText.replace(regex, '<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>');
}
/**
* رندر کردن ابزارهای دیگر در رابط کاربری
*/
function renderOtherTools() {
if (!toolsContainer) {
console.error("Tools container not found.");
return;
}
if (!otherTools || otherTools.length === 0) {
toolsContainer.innerHTML = '<p class="placeholder-text">اطلاعات ابزارها در دسترس نیست.</p>';
return;
}
toolsContainer.innerHTML = '';
otherTools.forEach(tool => {
const toolCard = document.createElement('div');
toolCard.classList.add('tool-card');
if (tool.icon) {
const icon = document.createElement('img');
icon.src = tool.icon;
icon.alt = `${tool.name} icon`;
icon.classList.add('card-icon');
icon.onerror = function() { this.style.display='none'; };
toolCard.appendChild(icon);
}
const toolName = document.createElement('h3');
toolName.textContent = tool.name;
toolCard.appendChild(toolName);
const toolDescription = document.createElement('p');
toolDescription.textContent = tool.description;
toolCard.appendChild(toolDescription);
if (tool.sub_descriptions && tool.sub_descriptions.length > 0) {
const subDescriptionsList = document.createElement('ul');
tool.sub_descriptions.forEach(subDesc => {
const listItem = document.createElement('li');
// تبدیل لینکهای Markdown در توضیحات فرعی به HTML
listItem.innerHTML = convertMarkdownLinksToHtml(subDesc);
subDescriptionsList.appendChild(listItem);
});
toolCard.appendChild(subDescriptionsList);
}
const toolLink = document.createElement('a');
toolLink.href = tool.link;
toolLink.target = "_blank";
toolLink.rel = "noopener noreferrer";
toolLink.classList.add('button');
toolLink.textContent = "مشاهده ابزار";
toolCard.appendChild(toolLink);
toolsContainer.appendChild(toolCard);
});
}
/**
* تابع عمومی برای رندر کردن کارتهای با ساختار ساده (پرامپتها، ورکرها و ابزارهای دیگران)
* @param {HTMLElement} container - عنصر نگهدارنده کارتها
* @param {Array<Object>} dataArray - آرایهای از دادهها برای رندر
* @param {string} placeholderText - متن جایگزین در صورت خالی بودن دادهها
* @param {string} buttonText - متن دکمه لینک
*/
function renderSimpleCards(container, dataArray, placeholderText, buttonText) {
if (!container) {
console.error("Container not found for rendering simple cards.");
return;
}
if (!dataArray || dataArray.length === 0) {
container.innerHTML = `<p class="placeholder-text">${placeholderText}</p>`;
return;
}
container.innerHTML = '';
dataArray.forEach(item => {
const itemCard = document.createElement('div');
itemCard.classList.add('tool-card'); // استفاده مجدد از استایل tool-card
if (item.icon) {
const icon = document.createElement('img');
icon.src = item.icon;
icon.alt = `${item.name} icon`;
icon.classList.add('card-icon');
icon.onerror = function() { this.style.display='none'; };
itemCard.appendChild(icon);
}
const itemName = document.createElement('h3');
itemName.textContent = item.name;
itemCard.appendChild(itemName);
const itemDescription = document.createElement('p');
itemDescription.textContent = item.description;
itemCard.appendChild(itemDescription);
const itemLink = document.createElement('a');
itemLink.href = item.link;
itemLink.target = "_blank";
itemLink.rel = "noopener noreferrer";
itemLink.classList.add('button');
itemLink.textContent = buttonText;
itemCard.appendChild(itemLink);
container.appendChild(itemCard);
});
}
// Event Listeners (شنوندههای رویداد)
if (categorySelect) {
categorySelect.addEventListener('change', function() {
const selectedCategory = this.value;
if (selectedCategory) {
showCategoryItems(selectedCategory);
if (linkDisplay) linkDisplay.classList.add('hidden');
} else {
if (itemsContainer) itemsContainer.innerHTML = '<p class="placeholder-text">لطفاً یک دسته را انتخاب کنید</p>';
if (linkDisplay) linkDisplay.classList.add('hidden');
}
});
} else {
console.warn("Element with ID 'category-select' not found.");
}
if (copyBtn) {
copyBtn.addEventListener('click', copyLink);
} else {
console.warn("Element with ID 'copy-btn' not found.");
}
if (themeToggle) {
themeToggle.addEventListener('click', toggleTheme);
} else {
console.warn("Element with ID 'theme-toggle' not found.");
}
if (scrollTopBtn) {
scrollTopBtn.addEventListener('click', scrollToTop);
} else {
console.warn("Element with ID 'scroll-top' not found.");
}
if (scrollBottomBtn) {
scrollBottomBtn.addEventListener('click', scrollToBottom);
} else {
console.warn("Element with ID 'scroll-bottom' not found.");
}
if (rowCountSelect) {
rowCountSelect.addEventListener('change', function() {
const count = parseInt(this.value, 10);
if (!isNaN(count) && count >= 1 && count <= 5) {
setGridColumns(count);
} else {
console.warn("ورودی تعداد سطر نامعتبر است. باید بین 1 تا 5 باشد.");
}
});
} else {
console.error("Element with ID 'row-count' not found. Row count functionality may not work.");
}
if (coreFilterSelect) {
// تغییر event listener برای اطمینان از اعمال فیلتر
coreFilterSelect.addEventListener('change', renderClients);
} else {
console.warn("Element with ID 'core-filter' not found. Client filtering by core may not work.");
}
if (osFilterSelect) {
// تغییر event listener برای اطمینان از اعمال فیلتر
osFilterSelect.addEventListener('change', renderClients);
} else {
console.warn("Element with ID 'os-filter' not found. Client filtering by OS may not work.");
}
// راهاندازی اولیه برنامه
setInitialTheme();
populateCategorySelect();
// تنظیم تعداد ستونهای پیشفرض بر اساس اندازه صفحه
if (rowCountSelect) {
const isMobile = window.innerWidth <= 768;
rowCountSelect.value = isMobile ? '1' : '3';
setGridColumns(parseInt(rowCountSelect.value, 10));
} else {
// اگر select وجود نداشت، مستقیماً ستونها را تنظیم کن
setGridColumns(window.innerWidth <= 768 ? 1 : 3);
}
// مقداردهی اولیه فیلترها و رندر اولیه (که اکنون با فیلتر خالی، کلاینتها را نشان نمیدهد)
populateClientFilters();
renderClients();
renderConverters();
renderOtherTools();
renderSimpleCards(promptsContainer, promptsData, "اطلاعات پرامپتها در دسترس نیست.", "مشاهده پرامپت");
renderSimpleCards(workersContainer, workersData, "اطلاعات ورکرها در دسترس نیست.", "مشاهده ورکر");
renderSimpleCards(otherPeopleToolsContainer, otherPeopleToolsData, "اطلاعات ابزارهای دیگران در دسترس نیست.", "مشاهده ابزار");
});