-
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathduckduckgpt.user.js
More file actions
2813 lines (2555 loc) · 178 KB
/
duckduckgpt.user.js
File metadata and controls
2813 lines (2555 loc) · 178 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
// ==UserScript==
// @name DuckDuckGPT 🤖
// @description Add AI answers to DuckDuckGo (powered by GPT-4o!)
// @description:af Voeg AI-antwoorde by DuckDuckGo (aangedryf deur GPT-4o!)
// @description:am የ DuckDuckGo ውስጥ AI መልቀቅን አድርግ፣ (GPT-4o በመሣሪያዎቹ ውስጥ!)
// @description:ar يضيف إجابات AI إلى DuckDuckGo (مدعوم بواسطة GPT-4o!)
// @description:as DuckDuckGo-লৈ AI উত্তৰ যোগ দিয়ে (GPT-4o দ্বাৰা পাওৱা হৈছে!)
// @description:az DuckDuckGo-ya AI cavablarını əlavə edir (GPT-4o tərəfindən dəstəklənir!)
// @description:be Дадае ІА адказы на DuckDuckGo (падтрымліваецца GPT-4o!)
// @description:bg Добавя ИИ отговори в DuckDuckGo (поддържан от GPT-4o!)
// @description:bn DuckDuckGo-ত AI উত্তর যোগ করে (GPT-4o দ্বারা প্রচালিত!)
// @description:bs Dodaje AI odgovore na DuckDuckGo (pokreće GPT-4o!)
// @description:ca Afegeix respostes d'IA a DuckDuckGo (impulsat per GPT-4o!)
// @description:ceb Nagdugang ug mga tubag AI ngadto sa DuckDuckGo (gipadagan sa GPT-4o!)
// @description:co Aggiunge risposte AI a DuckDuckGo (supportate da GPT-4o!)
// @description:cs Přidává AI odpovědi do DuckDuckGo (poháněno GPT-4o!)
// @description:cy Ychwanegu atebion AI i DuckDuckGo (a yrrir gan GPT-4o!)
// @description:da Tilføjer AI-svar til DuckDuckGo (drevet af GPT-4o!)
// @description:de Fügt AI-Antworten zu DuckDuckGo hinzu (betrieben von GPT-4o!)
// @description:el Προσθέτει απαντήσεις AI στο DuckDuckGo (τροφοδοτούμενο από GPT-4o!)
// @description:en Add AI answers to DuckDuckGo (powered by GPT-4o!)
// @description:eo Aldonas AI-respondojn al DuckDuckGo (ebligita de GPT-4o!)
// @description:es Añade respuestas de IA a DuckDuckGo (impulsado por GPT-4o!)
// @description:et Lisab AI-vastused DuckDuckGo'le (juhitud GPT-4o-ga!)
// @description:eu Gehitu IA erantzunak DuckDuckGo-n (GPT-4o-k bultzatuta!)
// @description:fa پاسخهای هوشمصنوعی به DuckDuckGo اضافه میشود (توسط GPT-4o پشتیبانی میشود!)
// @description:fi Lisää tekoälyvastauksia DuckDuckGo:hun (ohjattu GPT-4o:lla!)
// @description:fil Nagdaragdag ng mga sagot ng AI sa DuckDuckGo (pinapagana ng GPT-4o!)
// @description:fo Bætir AI svar við DuckDuckGo (drifin af GPT-4o!)
// @description:fr Ajoute des réponses IA à DuckDuckGo (propulsé par GPT-4o!)
// @description:fr-CA Ajoute des réponses IA à DuckDuckGo (propulsé par GPT-4o!)
// @description:fy Foeget AI-antwurden ta oan DuckDuckGo (dreaun troch GPT-4o!)
// @description:ga Cuirtear freagraí AI le DuckDuckGo (dírítear ag GPT-4o!)
// @description:gd Cur freagairtichean AI ris an DuckDuckGo (air a thug seachad le GPT-4o!)
// @description:gl Engade respostas de IA a DuckDuckGo (impulsado por GPT-4o!)
// @description:gu DuckDuckGo માટે AI જવાબો ઉમેરે છે (GPT-4o દ્વારા પોવરેડ!)
// @description:ha Ƙaddara takardun AI zu DuckDuckGo (da aka fi GPT-4o!)
// @description:haw Hoʻohui aku i nā hoʻopiʻi AI iā DuckDuckGo (hoʻohui ʻia e GPT-4o!)
// @description:he מוסיף תשובות AI ל-DuckDuckGo (מופעל על ידי GPT-4o!)
// @description:hi DuckDuckGo में AI उत्तर जोड़ता है (GPT-4o द्वारा संचालित!)
// @description:hmn Ntxig AI nruab nruab rau DuckDuckGo (pab cuam GPT-4o!)
// @description:hr Dodaje AI odgovore na DuckDuckGo (pokreće GPT-4o!)
// @description:ht Ajoute repons AI nan DuckDuckGo (pòte pa GPT-4o!)
// @description:hu AI válaszokat ad hozzá a DuckDuckGo-hoz (GPT-4o által hajtva!)
// @description:hy Ավելացնում է AI պատասխաններ DuckDuckGo-ում (աջակցված է GPT-4o-ով!)
// @description:ia Adde responas AI a DuckDuckGo (propulsate per GPT-4o!)
// @description:id Menambahkan jawaban AI ke DuckDuckGo (didukung oleh GPT-4o!)
// @description:ig Tinye ihe ndekọ AI n'ụzọ ọgụgụ DuckDuckGo (n'efu na GPT-4o!)
// @description:ii DuckDuckGo ᐸᔦᒪᔪᐃᓃᑦ AI ᓇᑕᐅᒪᐃᑦᓯ (GPT-4o ᓂᑕᔪᑦᓯᐏᑦᑕᒥᔭ!)
// @description:is Bætir AI svar við DuckDuckGo (keyrir á GPT-4o!)
// @description:it Aggiunge risposte AI a DuckDuckGo (alimentato da GPT-4o!)
// @description:iu DuckDuckGo ᑲᑎᒪᔪᖅᑐᖅᑐᐃᓐᓇᓂᒃ AI ᑎᑎᕋᖃᕐᓯᒪᓂᖏᓐ (GPT-4o ᑐᑭᒧᑦᑖᑦ!)
// @description:ja DuckDuckGo に AI 回答を追加します (GPT-4o で動作!)
// @description:jv Nambéhi pirangga AI nganti DuckDuckGo (diduweni déning GPT-4o!)
// @description:ka ამატებს AI პასუხებს DuckDuckGo-ს (იმართება GPT-4o!)
// @description:kk DuckDuckGo-ға AI жауаптарын қосады (GPT-4o арқылы жұмыс істейді!)
// @description:kl DuckDuckGo-mi AI-t Kalaallit Nunaanni iluani (GPT-4o! -nip ilaanni!)
// @description:km បន្ថែមចម្លើយ AI ទៅ DuckDuckGo (ដំណើរការដោយ GPT-4o!)
// @description:kn DuckDuckGo ಗೆ AI ಉತ್ತರಗಳನ್ನು ಸೇರಿಸುತ್ತದೆ (GPT-4o ನಿಂದ ನಡೆಸಲ್ಪಡುತ್ತಿದೆ!)
// @description:ko DuckDuckGo에 AI 답변을 추가합니다(GPT-4o 제공!)
// @description:ku Bersivên AI-ê li DuckDuckGo zêde dike (ji hêla GPT-4o ve hatî hêzdar kirin!)
// @description:ky DuckDuckGo'го AI жоопторун кошот (GPT-4o тарабынан иштейт!)
// @description:la Addit AI responsa DuckDuckGo (powered per GPT-4o!)
// @description:lb Füügt AI Äntwerten op DuckDuckGo (ugedriwwen duerch GPT-4o!)
// @description:lg Yambula emisomo ey'ensobi ku DuckDuckGo (enkuuma GPT-4o!)
// @description:ln Ebakisi biyano ya AI na DuckDuckGo (ezali na nguya ya GPT-4o!)
// @description:lo ເພີ່ມຄໍາຕອບ AI ໃຫ້ກັບ DuckDuckGo (ຂັບເຄື່ອນໂດຍ GPT-4o!)
// @description:lt Prideda AI atsakymus į „DuckDuckGo“ (maitina GPT-4o!)
// @description:lv Pievieno AI atbildes DuckDuckGo (darbina GPT-4o!)
// @description:mg Manampy valiny AI amin'ny DuckDuckGo (nampiasain'ny GPT-4o!)
// @description:mi Ka taapirihia nga whakautu AI ki a DuckDuckGo (whakamahia e GPT-4o!)
// @description:mk Додава одговори со вештачка интелигенција на DuckDuckGo (напојувано од GPT-4o!)
// @description:ml DuckDuckGo-യിലേക്ക് AI ഉത്തരങ്ങൾ ചേർക്കുന്നു (GPT-4o നൽകുന്നതാണ്!)
// @description:mn DuckDuckGo-д AI хариултуудыг нэмдэг (GPT-4o-оор ажилладаг!)
// @description:mr DuckDuckGo ला AI उत्तरे जोडते (GPT-4o द्वारे समर्थित!)
// @description:ms Menambahkan jawapan AI pada DuckDuckGo (dikuasakan oleh GPT-4o!)
// @description:mt Iżżid it-tweġibiet AI għal DuckDuckGo (mħaddma minn GPT-4o!)
// @description:my DuckDuckGo (GPT-4o ဖြင့် စွမ်းဆောင်ထားသည့်) တွင် AI အဖြေများကို ပေါင်းထည့်သည်
// @description:na Aeta AI teroma i DuckDuckGo (ira GPT-4o reke akea!)
// @description:nb Legger til AI-svar på DuckDuckGo (drevet av GPT-4o!)
// @description:nd Iyatholakala amaswelelo e-AI kuDuckDuckGo (kuyatholakala ngokulawula uGPT-4o!)
// @description:ne DuckDuckGo मा AI जवाफहरू थप्छ (GPT-4o द्वारा संचालित!)
// @description:ng Ondjova mbelelo dha AI moDuckDuckGo (uumbuli nguGPT-4o!)
// @description:nl Voegt AI-antwoorden toe aan DuckDuckGo (mogelijk gemaakt door GPT-4o!)
// @description:nn Legg til AI-svar på DuckDuckGo (drevet av GPT-4o!)
// @description:no Legger til AI-svar til DuckDuckGo (drevet av GPT-4o!)
// @description:nso Ya go etela ditshenyegi tsa AI mo DuckDuckGo (e dirwang ke GPT-4o!)
// @description:ny Imawonjezera mayankho a AI ku DuckDuckGo (yoyendetsedwa ndi GPT-4o!)
// @description:oc Ajusta de respòstas d'IA a DuckDuckGo (amb GPT-4o!)
// @description:om Deebii AI DuckDuckGo (GPT-4o'n kan hojjetu!) irratti dabalata.
// @description:or DuckDuckGo କୁ AI ଉତ୍ତର ଯୋଗ କରେ (GPT-4o ଦ୍ୱାରା ଚାଳିତ!)
// @description:pa DuckDuckGo (GPT-4o ਦੁਆਰਾ ਸੰਚਾਲਿਤ!) ਵਿੱਚ AI ਜਵਾਬ ਸ਼ਾਮਲ ਕਰਦਾ ਹੈ
// @description:pl Dodaje odpowiedzi AI do DuckDuckGo (obsługiwane przez GPT-4o!)
// @description:ps DuckDuckGo ته د AI ځوابونه اضافه کوي (د GPT-4o لخوا پرمخ وړل کیږي!)
// @description:pt Adiciona respostas de IA ao DuckDuckGo (desenvolvido por GPT-4o!)
// @description:pt-BR Adiciona respostas de IA ao DuckDuckGo (desenvolvido por GPT-4o!)
// @description:qu DuckDuckGo (GPT-4o nisqawan kallpachasqa!) nisqaman AI kutichiykunata yapan.
// @description:rm Agiuntescha respostas d'IA a DuckDuckGo (propulsà da GPT-4o!)
// @description:rn Abafasha inyandiko z'IA ku DuckDuckGo (yashyizweho na GPT-4o!)
// @description:ro Adaugă răspunsuri AI la DuckDuckGo (alimentat de GPT-4o!)
// @description:ru Добавляет ответы ИИ в DuckDuckGo (на базе GPT-4o!)
// @description:rw Ongeraho ibisubizo bya AI kuri DuckDuckGo (ikoreshwa na GPT-4o!)
// @description:sa DuckDuckGo (GPT-4o द्वारा संचालितम्!) इत्यत्र AI उत्तराणि योजयति ।
// @description:sat DuckDuckGo ar AI jawab khon ojantok (GPT-4o! sebadha manju)
// @description:sc Agiungit rispostas de IA a DuckDuckGo (motorizadu da GPT-4o!)
// @description:sd شامل ڪري ٿو AI جوابن کي DuckDuckGo (GPT-4o پاران طاقتور!)
// @description:se Lávdegáhtii AI vástid DuckDuckGo (GPT-4o! vuosttas!)
// @description:sg Nâ tî-kûzâ mái vêdáara AI mbi DuckDuckGo (ngâ GPT-4o!)
// @description:si DuckDuckGo වෙත AI පිළිතුරු එක් කරයි (GPT-4o මගින් බලගන්වයි!)
// @description:sk Pridáva odpovede AI do DuckDuckGo (poháňané GPT-4o!)
// @description:sl Dodaja odgovore AI v DuckDuckGo (poganja GPT-4o!)
// @description:sm Faʻaopoopo tali AI ile DuckDuckGo (faʻamalosia e GPT-4o!)
// @description:sn Inowedzera mhinduro dzeAI kuDuckDuckGo (inofambiswa neGPT-4o!)
// @description:so Waxay ku dartay jawaabaha AI DuckDuckGo (waxaa ku shaqeeya GPT-4o!)
// @description:sq Shton përgjigjet e AI në DuckDuckGo (mundësuar nga GPT-4o!)
// @description:sr Додаје АИ одговоре у DuckDuckGo (покреће ГПТ-4о!)
// @description:ss Iphendvulela izindlela zezilungiselelo ku-DuckDuckGo (izenzakalo nge-GPT-4o!)
// @description:st E kopanetse diqoqo tsa AI ka DuckDuckGo (ka sebelisoa ke GPT-4o!)
// @description:su Nambahkeun jawaban AI kana DuckDuckGo (dikuatkeun ku GPT-4o!)
// @description:sv Lägger till AI-svar till DuckDuckGo (driven av GPT-4o!)
// @description:sw Inaongeza majibu ya AI kwa DuckDuckGo (inaendeshwa na GPT-4o!)
// @description:ta DuckDuckGo க்கு AI பதில்களைச் சேர்க்கிறது (GPT-4o மூலம் இயக்கப்படுகிறது!)
// @description:te DuckDuckGoకి AI సమాధానాలను జోడిస్తుంది (GPT-4o ద్వారా ఆధారితం!)
// @description:tg Ба DuckDuckGo ҷавобҳои AI илова мекунад (аз ҷониби GPT-4o!)
// @description:th เพิ่มคำตอบ AI ให้กับ DuckDuckGo (ขับเคลื่อนโดย GPT-4o!)
// @description:ti ናብ DuckDuckGo (ብGPT-4o ዝሰርሕ!) ናይ AI መልስታት ይውስኸሉ።
// @description:tk DuckDuckGo-a AI jogaplaryny goşýar (GPT-4o bilen işleýär!)
// @description:tl Nagdadagdag ng mga sagot ng AI sa DuckDuckGo (pinapatakbo ng GPT-4o!)
// @description:tn O amogela dipotso tsa AI mo DuckDuckGo (e a nang le GPT-4o!)
// @description:to Tambisa mabizo a AI ku DuckDuckGo (mukutenga na GPT-4o!)
// @description:tr DuckDuckGo'ya yapay zeka yanıtları ekler (GPT-4o tarafından desteklenmektedir!)
// @description:ts Ku engetela tinhlamulo ta AI eka DuckDuckGo (leyi fambiwaka hi GPT-4o!)
// @description:tt DuckDuckGo'ка AI җаваплары өсти (GPT-4o белән эшләнгән!)
// @description:tw Ɔde AI mmuae ka DuckDuckGo (a GPT-4o na ɛma ahoɔden!) ho.
// @description:ug DuckDuckGo ۋەبسېتكە AI جاۋابلار قوشۇدۇ (GPT-4o تەكشۈرگۈچى بىلەن!)
// @description:uk Додає відповіді штучного інтелекту в DuckDuckGo (на базі GPT-4o!)
// @description:ur DuckDuckGo میں AI جوابات شامل کرتا ہے (GPT-4o کے ذریعے تقویت یافتہ!)
// @description:uz DuckDuckGo-ga AI javoblarini qo'shadi (GPT-4o tomonidan quvvatlanadi!)
// @description:vi Thêm câu trả lời AI vào DuckDuckGo (được cung cấp bởi GPT-4o!)
// @description:xh Yongeza iimpendulo ze-AI kwi-DuckDuckGo (ixhaswe yi-GPT-4o!)
// @description:yi לייגט אַי ענטפֿערס צו DuckDuckGo (Powered דורך GPT-4o!)
// @description:yo Ṣe afikun awọn idahun AI si DuckDuckGo (agbara nipasẹ GPT-4o!)
// @description:zh 为 DuckDuckGo 添加 AI 答案(由 GPT-4o 提供支持!)
// @description:zh-CN 为 DuckDuckGo 添加 AI 答案(由 GPT-4o 提供支持!)
// @description:zh-HK 為 DuckDuckGo 添加 AI 答案(由 GPT-4o 提供支援!)
// @description:zh-SG 为 DuckDuckGo 添加 AI 答案(由 GPT-4o 提供支持!)
// @description:zh-TW 為 DuckDuckGo 添加 AI 答案(由 GPT-4o 提供支援!)
// @description:zu Yengeza izimpendulo ze-AI ku-DuckDuckGo (inikwa amandla yi-GPT-4o!)
// @author KudoAI
// @namespace https://kudoai.com
// @version 2026.3.5
// @license MIT
// @icon https://assets.ddgpt.com/images/icons/app/icon48.png?v=533ce0f
// @icon64 https://assets.ddgpt.com/images/icons/app/icon64.png?v=533ce0f
// @compatible brave
// @compatible chrome
// @compatible chromebeta
// @compatible chromecanary
// @compatible chromedev
// @compatible edge
// @compatible edgebeta
// @compatible edgecanary
// @compatible edgedev
// @compatible fennec
// @compatible firefox
// @compatible firefoxbeta
// @compatible firefoxnightly
// @compatible ghost
// @compatible iceraven
// @compatible ironfox
// @compatible lemur
// @compatible librewolf
// @compatible mises
// @compatible opera after allowing userscript manager access to search page results in opera://extensions
// @compatible operaair after allowing userscript manager access to search page results in opera://extensions
// @compatible operagx after allowing userscript manager access to search page results in opera://extensions
// @compatible qq
// @compatible quetta
// @compatible safari
// @compatible orion
// @compatible vivaldi
// @compatible waterfox
// @compatible whale
// @match *://duckduckgo.com/?*
// @include https://auth0.openai.com
// @connect api.binjie.fun
// @connect api.openai.com
// @connect api11.gptforlove.com
// @connect cdn.jsdelivr.net
// @connect chat-share.kudoai.workers.dev
// @connect chatai.mixerbox.com
// @connect chatgpt.com
// @connect ddgpt.com
// @connect duckduckgpt.com
// @connect fanyi.sogou.com
// @connect raw.githubusercontent.com
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.9.0/dist/chatgpt.min.js#sha256-XyrLEk81vg4/zgOeYDWtugRQKJvrWEefACp0EfwMVHE=
// @require https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.2.0/crypto-js.min.js#sha256-dppVXeVTurw1ozOPNE3XqhYmDJPOosfbKQcHyQSE58w=
// @require https://cdn.jsdelivr.net/npm/json5@2.2.3/dist/index.min.js#sha256-S7ltnVPzgKyAGBlBG4wQhorJqYTehj5WQCrADCKJufE=
// @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@30ce038/assets/js/chatbot/components/buttons.js#sha256-bam0MF6WM+Lyt5Wgop3rfHPYZHmOPXq4ZxbUXort2+M=
// @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@30ce038/assets/js/chatbot/components/icons.js#sha256-nAcuQD4FVFzUN1pS6pOjw2V3IvkDwYV+P3m5IN8nsdo=
// @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@787f07b/assets/js/chatbot/components/menus.js#sha256-YaV3USVJvvChUwPjoF2jwRwbKVBdjoFfLS6ThEnZchE=
// @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@30ce038/assets/js/chatbot/components/replyBubble.js#sha256-zN/oMInc63biUtC+qNfP48vntQiEw2zyCIVszeBxLmg=
// @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@30ce038/assets/js/chatbot/components/tooltip.js#sha256-/xPw7DnS8F9dBH/s0ffMrErweHgFBeKpkUM4tUDy4vo=
// @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@787f07b/assets/js/chatbot/lib/api.js#sha256-9mC3x8yqdVp3WpWMreBsTzunXu1+VSm0bXvVOQz3ODs=
// @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@30ce038/assets/js/chatbot/lib/feedback.js#sha256-ri8OzNa/8sQINDn7bW84F2OuVYZxubMSm/Zpli/cPnQ=
// @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@30ce038/assets/js/chatbot/lib/log.js#sha256-puXwoSKgog6EhgDzlJrAzMnGRM6kLMTT8NF0jYncIt8=
// @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@30ce038/assets/js/chatbot/lib/prompts.js#sha256-Z9QsKpAcqSoclxyPTkPfe8/K3s9eDrbSYgumr/GYyLc=
// @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@30ce038/assets/js/chatbot/lib/session.js#sha256-cH2e3l2bZQRekQHxaeSShdNguqD41evEOkMrrVIydHQ=
// @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@30ce038/assets/js/chatbot/lib/themes.js#sha256-NSiOkXoRC/fF8zdmnbIk9XL5tKWWP5MU2NOfdJ9G0NU=
// @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@30ce038/assets/js/chatbot/lib/ui.js#sha256-+UnPhc4zxrdWEuLU8PFrnpAW9TFS2c1hOGbcby2HlEU=
// @require https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@30ce038/assets/js/chatbot/lib/userscript.js#sha256-DTD+Tj/9angBw8/Q4e8PMz2SBwueqvNzeY8PwZlMgbs=
// @require https://cdn.jsdelivr.net/gh/adamlui/userscripts@ff2baba/assets/js/lib/css.js/dist/css.min.js#sha256-zf9s8C0cZ/i+gnaTIUxa0+RpDYpsJVlyuV5L2q4KUdA=
// @require https://cdn.jsdelivr.net/gh/adamlui/userscripts@ff2baba/assets/js/lib/dom.js/dist/dom.min.js#sha256-nTc2by3ZAz6AR7B8fOqjloJNETvjAepe15t2qlghMDo=
// @require https://cdn.jsdelivr.net/npm/generate-ip@2.8.2/dist/generate-ip.min.js#sha256-oHi8Wlz9pH20TZ8mC8prlbKedtonwKtR2mS6jaESANo=
// @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js#sha256-g3pvpbDHNrUrveKythkPMF2j/J7UFoHbUyFQcFe1yEY=
// @require https://cdn.jsdelivr.net/npm/katex@0.16.10/dist/katex.min.js#sha256-n0UwfFeU7SR6DQlfOmLlLvIhWmeyMnIDp/2RmVmuedE=
// @require https://cdn.jsdelivr.net/npm/katex@0.16.10/dist/contrib/auto-render.min.js#sha256-e1fUJ6xicGd9r42DgN7SzHMzb5FJoWe44f4NbvZmBK4=
// @require https://cdn.jsdelivr.net/npm/marked@12.0.2/marked.min.js#sha256-Ffq85bZYmLMrA/XtJen4kacprUwNbYdxEKd0SqhHqJQ=
// @require https://unpkg.com/tone@15.1.22/build/Tone.js#sha256-4pCVL6Q9mnp4AYKoPG/M9E15y3riy6EC7x8rnZgSTiI=
// @resource ddgptIcon https://cdn.jsdelivr.net/gh/KudoAI/duckduckgpt@8482c4b/assets/images/icons/duckduckgpt/icon64.png.b64#sha256-k7hl9PAq+HAKG2vS9wlKmu3EEvdE3k2Z2KR/SRkk6D4=
// @resource ddgptLSlogo https://cdn.jsdelivr.net/gh/KudoAI/duckduckgpt@8482c4b/assets/images/logos/duckduckgpt/lightmode/logo697x122.png.b64#sha256-7O4AxPinoZ6h36KHuJVa4vwfTEOYTwT+lKiDbf/jjkg=
// @resource ddgptDSlogo https://cdn.jsdelivr.net/gh/KudoAI/duckduckgpt@8482c4b/assets/images/logos/duckduckgpt/darkmode/logo697x122.png.b64#sha256-lSd4M3RPT4+SjjBk8PKGFoyM9p3rZHgxt0NgoKqQkiM=
// @resource hljsCSS https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/base16/railscasts.min.css#sha256-nMf0Oxaj3sYJiwGCsfqNpGnBbcofnzk+zz3xTxtdLEQ=
// @resource rpgCSS https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@727feff/assets/styles/rising-particles/dist/gray.min.css#sha256-48sEWzNUGUOP04ur52G5VOfGZPSnZQfrF3szUr4VaRs=
// @resource rpwCSS https://cdn.jsdelivr.net/gh/adamlui/ai-web-extensions@727feff/assets/styles/rising-particles/dist/white.min.css#sha256-6xBXczm7yM1MZ/v0o1KVFfJGehHk47KJjq8oTktH4KE=
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_deleteValue
// @grant GM_cookie
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// @grant GM_getResourceText
// @grant GM_xmlhttpRequest
// @grant GM.xmlHttpRequest
// @noframes
// @downloadURL https://gm.ddgpt.com
// @updateURL https://gm.ddgpt.com
// @homepageURL https://www.duckduckgpt.com
// @supportURL https://support.duckduckgpt.com
// @contributionURL https://github.com/sponsors/KudoAI
// ==/UserScript==
// Dependencies:
// ✓ chatgpt.js (https://chatgpt.js.org) © 2023–2026 KudoAI & contributors under the MIT license
// ✓ dom.js © 2023–2026 Adam Lui under the MIT license
// ✓ generate-ip (https://generate-ip.org) © 2024–2026 Adam Lui & contributors under the MIT license
// ✓ highlight.js (https://highlightjs.org) © 2006 Ivan Sagalaev under the BSD 3-Clause license
// ✓ KaTeX (https://katex.org) © 2013–2020 Khan Academy & other contributors under the MIT license
// ✓ Marked (https://marked.js.org) © 2018+ MarkedJS © 2011–2018 Christopher Jeffrey under the MIT license
// ✓ Tone.js (https://tonejs.github.io) © 2014–2026 Yotam Mann under the MIT license
// Documentation: https://docs.ddgpt.com
// Requires components/replyBubble.js + lib/<dom|Tone>.js + <app|get|prompts|show|tooltip|xhr>
(async () => {
'use strict'
// Init DATA
window.env = {
browser: { language: chatgpt.getUserLanguage() },
scriptManager: {
name: (() => { try { return GM_info.scriptHandler } catch (err) { return 'unknown' }})(),
version: (() => { try { return GM_info.version } catch (err) { return 'unknown' }})()
}
} ; ['Chromium', 'Firefox', 'Chrome', 'Edge', 'Brave', 'Mobile'].forEach(platform =>
env.browser[`is${ platform == 'Firefox' ? 'FF' : platform }`] = chatgpt.browser['is' + platform]())
Object.assign(env.browser, { get isCompact() { return innerWidth <= 480 }})
env.userLocale = env.browser.language.includes('-') ? env.browser.language.split('-')[1].toLowerCase() : ''
env.scriptManager.supportsStreaming = /Tampermonkey|ScriptCat/.test(env.scriptManager.name)
env.scriptManager.supportsTooltips = env.scriptManager.name == 'Tampermonkey'
&& parseInt(env.scriptManager.version.split('.')[0]) >= 5
window.inputEvents = {} ; ['down', 'move', 'up'].forEach(action =>
inputEvents[action] = ( window.PointerEvent ? 'pointer' : env.browser.isMobile ? 'touch' : 'mouse' ) + action)
window.xhr = typeof GM != 'undefined' && GM.xmlHttpRequest || GM_xmlhttpRequest
window.app = {
version: GM_info.script.version, chatgptjsVer: /chatgpt\.js@([\d.]+)/.exec(GM_info.scriptMetaStr)[1],
commitHashes: {
app: 'f4fcbdd', // for cached <app|messages>.json
aiweb: '02c1241' // for cached ai-chat-apis.json5 + <code-languages|katex-delimiters|sogou-tts-lang-codes>.json
},
config: {}
}
app.urls = { resourceHost: `https://cdn.jsdelivr.net/gh/KudoAI/duckduckgpt@${app.commitHashes.app}` }
const remoteData = {
app: await new Promise(resolve => xhr({
method: 'GET', url: `${app.urls.resourceHost}/assets/data/app.json`,
onload: ({ responseText }) => resolve(JSON.parse(responseText))
})),
msgs: await new Promise(resolve => {
const msgBaseURL = `${app.urls.resourceHost}/greasemonkey/_locales`,
locale = `${ env.browser.language ? env.browser.language.replace('-', '_') : 'en' }`
let msgURL = `${msgBaseURL}/${locale}/messages.json`, msgFetchesTried = 0
function fetchMsgs() { xhr({ method: 'GET', url: msgURL, onload: handleMsgs })}
function handleMsgs(resp) {
try { // to return localized messages.json
const msgs = JSON.parse(resp.responseText), flatMsgs = {}
for (const key in msgs) // remove need to ref nested keys
if (typeof msgs[key] == 'object' && 'message' in msgs[key])
flatMsgs[key] = msgs[key].message
resolve(flatMsgs)
} catch (err) { // if bad response
msgFetchesTried++ ; if (msgFetchesTried == 3) return resolve({}) // try original/region-stripped/EN only
msgURL = env.browser.language.includes('-') && msgFetchesTried == 1 ? // if regional lang on 1st try...
msgURL.replace(/(_locales\/[^_]+)_[^_]+(\/)/, '$1$2') // ...strip region before retrying
: `${msgBaseURL}/en/messages.json` // else use default English messages
fetchMsgs()
}
}
fetchMsgs()
})
}
Object.assign(app, { ...remoteData.app, urls: { ...app.urls, ...remoteData.app.urls }, msgs: remoteData.msgs })
app.urls.aiwebAssets = app.urls.aiwebAssets.replace('@latest', `@${app.commitHashes.aiweb}`)
app.alerts = {
waitingResponse: `${app.msgs.alert_waitingFor} ${app.name} ${app.msgs.alert_response}...`,
login: `${app.msgs.alert_login} @ `,
checkCloudflare: `${app.msgs.alert_checkCloudflare} @ `,
tooManyRequests: `${app.msgs.alert_tooManyRequests}.`,
parseFailed: `${app.msgs.alert_parseFailed}.`,
proxyNotWorking: `${app.msgs.mode_proxy} ${app.msgs.alert_notWorking}.`,
apiNotWorking: `API ${app.msgs.alert_notWorking}.`,
suggestProxy: `${app.msgs.alert_try} ${app.msgs.alert_switchingOn} ${app.msgs.mode_proxy}`,
suggestDiffAPI: `${app.msgs.alert_try} ${app.msgs.alert_selectingDiff} API`,
suggestOpenAI: `${app.msgs.alert_try} ${app.msgs.alert_switchingOff} ${app.msgs.mode_proxy}`
}
app.katexDelimiters = await new Promise(resolve => xhr({ // used in show.reply()
method: 'GET', onload: ({ responseText }) => resolve(JSON.parse(responseText)),
url: `${app.urls.aiwebAssets}/data/katex-delimiters.json`
}))
window.apis = Object.assign(Object.create(null), await new Promise(resolve => xhr({
method: 'GET', onload: ({ responseText }) => resolve(Object.fromEntries(
Object.entries(JSON5.parse(responseText)).filter(([, api]) => !api.disabled))),
url: `${app.urls.aiwebAssets}/data/ai-chat-apis.json5`
})))
apis.AIchatOS.userID = `#/chat/${Date.now()}`
// Init SETTINGS
app.config ??= {}
window.settings = {
load(...keys) {
keys.flat().forEach(key =>
app.config[key] = processKey(key, GM_getValue(`${app.configKeyPrefix}_${key}`, undefined)))
function processKey(key, val) {
const ctrl = settings.controls?.[key]
if (val != undefined && ( // validate stored val
(ctrl?.type == 'toggle' && typeof val != 'boolean')
|| (ctrl?.type == 'slider' && isNaN(parseFloat(val)))
)) val = undefined
return val ?? (ctrl?.defaultVal ?? (ctrl?.type == 'slider' ? 100 : false))
}
},
save(key, val) { GM_setValue(`${app.configKeyPrefix}_${key}`, val) ; app.config[key] = val },
typeIsEnabled(key) {
const reInvertFlags = /disabled|hidden/i
return reInvertFlags.test(key) // flag in control key name
&& !reInvertFlags.test(this.controls[key]?.label || '') // but not in label msg key name
? !app.config[key] : app.config[key] // so invert since flag reps opposite type state, else don't
}
}
settings.load('debugMode') ; log.debug('Initializing settings...')
Object.assign(settings, { controls: { // displays top-to-bottom, left-to-right in Settings modal
proxyAPIenabled: { type: 'toggle', icon: 'sunglasses', defaultVal: false,
label: app.msgs.menuLabel_proxyAPImode,
helptip: app.msgs.helptip_proxyAPImode },
preferredAPI: { type: 'modal', icon: 'lightning', defaultVal: false,
label: `${app.msgs.menuLabel_preferred} API`,
helptip: app.msgs.helptip_preferredAPI },
streamingDisabled: { type: 'toggle', icon: 'signalStream', defaultVal: false,
label: app.msgs.mode_streaming,
helptip: app.msgs.helptip_streamingMode },
autoGet: { type: 'toggle', icon: 'speechBalloonLasso', defaultVal: true,
label: app.msgs.menuLabel_autoAnswer,
helptip: app.msgs.helptip_autoGetAnswers },
autoSummarize: { type: 'toggle', icon: 'summarize', defaultVal: false,
label: app.msgs.menuLabel_autoSummarizeResults,
helptip: app.msgs.helptip_autoSummarizeResults },
autoFocusChatbarDisabled: { type: 'toggle', mobile: false, icon: 'caretsInward', defaultVal: true,
label: app.msgs.menuLabel_autoFocusChatbar,
helptip: app.msgs.helptip_autoFocusChatbar },
autoScroll: { type: 'toggle', mobile: false, icon: 'arrowsDown', defaultVal: false,
label: `${app.msgs.mode_autoScroll} (${app.msgs.menuLabel_whenStreaming})`,
helptip: app.msgs.helptip_autoScroll },
rqDisabled: { type: 'toggle', icon: 'speechBalloons', defaultVal: false,
label: `${app.msgs.menuLabel_show} ${app.msgs.menuLabel_relatedQueries}`,
helptip: app.msgs.helptip_showRelatedQueries },
prefixEnabled: { type: 'toggle', icon: 'slash', defaultVal: false,
label: `${app.msgs.menuLabel_require} "/" ${app.msgs.menuLabel_beforeQuery}`,
helptip: app.msgs.helptip_prefixMode },
suffixEnabled: { type: 'toggle', icon: 'questionMark', defaultVal: false,
label: `${app.msgs.menuLabel_require} "?" ${app.msgs.menuLabel_afterQuery}`,
helptip: app.msgs.helptip_suffixMode },
widerSidebar: { type: 'toggle', mobile: false, centered: false, icon: 'widescreenTall', defaultVal: false,
label: app.msgs.menuLabel_widerSidebar,
helptip: app.msgs.helptip_widerSidebar },
stickySidebar: { type: 'toggle', mobile: false, centered: false, icon: 'sidebar', defaultVal: false,
label: app.msgs.menuLabel_stickySidebar,
helptip: app.msgs.helptip_stickySidebar },
anchored: { type: 'toggle', mobile: false, centered: false, icon: 'anchor', defaultVal: false,
label: app.msgs.mode_anchor,
helptip: app.msgs.helptip_anchorMode },
bgAnimationsDisabled: { type: 'toggle', icon: 'sparkles', defaultVal: false,
label: `${app.msgs.menuLabel_background} ${app.msgs.menuLabel_animations}`,
helptip: app.msgs.helptip_bgAnimations },
fgAnimationsDisabled: { type: 'toggle', icon: 'sparkles', defaultVal: false,
label: `${app.msgs.menuLabel_foreground} ${app.msgs.menuLabel_animations}`,
helptip: app.msgs.helptip_fgAnimations },
replyLang: { type: 'prompt', icon: 'languageChars',
label: app.msgs.menuLabel_replyLanguage,
helptip: app.msgs.helptip_replyLanguage },
scheme: { type: 'modal', icon: 'scheme',
label: app.msgs.menuLabel_colorScheme,
helptip: app.msgs.helptip_colorScheme },
debugMode: { type: 'toggle', icon: 'bug', defaultVal: false,
label: app.msgs.mode_debug,
helptip: app.msgs.helptip_debugMode },
about: { type: 'modal', icon: 'questionMarkCircle',
label: `${app.msgs.menuLabel_about} ${app.name}...` }
}})
Object.assign(app.config, { lineHeightRatio: 1.28, maxFontSize: 24, minFontSize: 11 })
settings.load(Object.keys(settings.controls), 'expanded', 'fontSize', 'minimized', 'aiSafetyWarned')
if (!app.config.replyLang) settings.save('replyLang', env.browser.language) // init reply language if unset
if (!app.config.fontSize) settings.save('fontSize', 14.948771158854168) // init reply font size if unset
if (!env.scriptManager.supportsStreaming) settings.save('streamingDisabled', true) // disable Streaming in unspported env
log.debug(`Success! app.config = ${log.prettifyObj(app.config)}`)
// Define UI functions
window.update = {
appBottomPos() { app.div.style.bottom = `${ app.config.minimized ? 55 - app.div.offsetHeight : -7 }px` },
appStyle() { // used in toggle.animations() + update.scheme() + main's app init
const { scheme: appScheme } = env.ui.app,
isParticlizedDS = env.ui.app.scheme == 'dark' && !app.config.bgAnimationsDisabled
modals.stylize() // update modal styles
if (!app.styles?.isConnected) document.head.append(app.styles ||= dom.create.style())
app.styles.textContent = (
// Init vars
`:root {
--app-bg-color-light-scheme: white ; --app-bg-color-dark-scheme: #1c1c1c ;
--pre-bg-color-light-scheme: #b7b7b736 ; --pre-bg-color-dark-scheme: #3a3a3a ;
--reply-header-bg-color-light-scheme: #d7d4d4 ;
--reply-header-bg-color-dark-scheme: ${ !isParticlizedDS ? '#545454' : '#0e0e0e24' };
--reply-header-fg-color-light-scheme: white ; --reply-header-fg-color-dark-scheme: white ;
--chatbar-btn-color-light-scheme: lightgrey ; --chatbar-btn-color-dark-scheme: #fff ;
--chatbar-btn-hover-color-light-scheme: #638ed4 ; --chatbar-btn-hover-color-dark-scheme: #fff ;
--font-color-light-scheme: #4e4e4e ; --font-color-dark-scheme: #e3e3e3 ;
--app-border: ${ isParticlizedDS ? 'none'
: `1px solid #${ appScheme == 'light' ? 'e5e5e5' : '3b3b3b' }`};
--app-gradient-bg: linear-gradient(180deg, ${
appScheme == 'dark' ? '#99a8a6 -245px, black 185px' : '#b6ebff -163px, white 65px' }) ;
--app-anchored-shadow: 0 15px 52px rgb(0,0,${ appScheme == 'light' ? '7,0.06' : '11,0.22' }) ;
--app-transition: opacity 0.5s ease, transform 0.5s ease, /* for 1st fade-in */
bottom 0.1s cubic-bezier(0,0,0.2,1), /* smoothen Anchor Y min/restore */
width 0.167s cubic-bezier(0,0,0.2,1) ; /* smoothen Anchor X expand/shrink */
--standby-btn-zoom: scale(1.015) ; --standby-btn-transition: all 0.18s ease ;
--btn-transition: transform 0.15s ease, /* for hover-zoom */
opacity 0.25s ease-in-out ; /* + btn-zoom-fade-out + .app-hover-only shows */
--font-size-slider-thumb-transition: transform 0.05s ease ; /* for hover-zoom */
--reply-pre-transition: max-height 0.167s cubic-bezier(0, 0, 0.2, 1) ; /* for Anchor changes */
--rq-transition: opacity 0.55s ease, transform 0.1s ease !important ; /* for fade-in + hover-zoom */
--fade-in-transition: opacity 0.4s ease ;
--fade-in-less-transition: opacity 0.2s ease } /* used by Font Size slider + Pin menu */`
// Animations
+ `.fade-in {
opacity: 0 ; transform: translateY(10px) ;
transition: var(--fade-in-less-transition) ;
-webkit-transition: var(--fade-in-transition) ;
-moz-transition: var(--fade-in-transition) ;
-o-transition: var(--fade-in-transition) ;
-ms-transition: var(--fade-in-transition)
}
.fade-in-less {
opacity: 0 ;
transition: var(--fade-in-less-transition) ;
-webkit-transition: var(--fade-in-less-transition) ;
-moz-transition: var(--fade-in-less-transition) ;
-o-transition: var(--fade-in-less-transition) ;
-ms-transition: var(--fade-in-less-transition)
}
.fade-in.active, .fade-in-less.active { opacity: 1 ; transform: translateY(0) }
@keyframes btn-zoom-fade-out {
0% { opacity: 1 } 55% { opacity: 0.25 ; transform: scale(1.85) }
75% { opacity: 0.05 ; transform: scale(2.15) } 100% { opacity: 0 ; transform: scale(6.85) }}
@keyframes icon-scroll { 0% { transform: translateX(0) } 100% { transform: translateX(-14px) }}
@keyframes pulse { 0%, to { opacity: 1 } 50% { opacity: .5 }}
@keyframes rotate { from { transform: rotate(0deg) } to { transform: rotate(360deg) }}
@keyframes spinY { 0% { transform: rotateY(0deg) } 100% { transform: rotateY(360deg) }}`
// Main styles
+ `.no-user-select {
-webkit-user-select: none ; -moz-user-select: none ;
-ms-user-select: none ; user-select: none }
.no-mobile-tap-outline { outline: none ; -webkit-tap-highlight-color: transparent }
#${app.slug} * { scrollbar-width: thin } /* make scrollbars thin in Firefox */
.cursor-overlay { /* for fontSizeSlider.createAppend() drag listeners to show resize cursor everywhere */
position: fixed ; top: 0 ; left: 0 ; width: 100% ; height: 100% ;
z-index: 9999 ; cursor: ew-resize }
#${app.slug} { /* main app div */
color: var(--font-color-${appScheme}-scheme) ;
background: var(--app-bg-color-${appScheme}-scheme) ;
position: sticky ; z-index: 104 ; padding: 17px 26px 16px ; border-radius: 8px ;
width: auto ; word-wrap: break-word ; white-space: pre-wrap ;
transition: var(--app-transition) ;
-webkit-transition: var(--app-transition) ; -moz-transition: var(--app-transition) ;
-o-transition: var(--app-transition) ; -ms-transition: var(--app-transition) }
#${app.slug}:has(.${app.slug}-alert) { /* app alerts */
border: var(--app-border) ; background-image: var(--app-gradient-bg) }
#${app.slug} .app-hover-only { /* hide app-hover-only elems */
position: absolute ; left: -9999px ; opacity: 0 ; /* using position to support transitions */
width: 0 } /* to support width calcs */
/* show app-hover-only elems on hover + Font Size button when slider visible */
#${app.slug}:hover .app-hover-only, #${app.slug}:active .app-hover-only,
#${app.slug}:has([id$=font-size-slider-track].active) [id$=font-size-btn] {
position: relative ; left: auto ; width: auto ; opacity: 1 }
#${app.slug} p { margin: 0 }
#${app.slug} .alert-link {
color: ${ appScheme == 'light' ? '#190cb0' : 'white ; text-decoration: underline' }}
.${app.slug}-name, .${app.slug}-name:hover {
font-size: 1.5rem ; font-weight: 700 ; text-decoration: none ;
color: ${ appScheme == 'dark' ? 'white' : 'black' }}
.byline { /* header byline */
position: relative ; bottom: 2.25px ; margin-left: 6px ; color: #aaa ; font-size: 13.1px ;
--byline-transition: 0.15s ease-in-out ; transition: var(--byline-transition) ;
-webkit-transition: var(--byline-transition) ; -moz-transition: var(--byline-transition) ;
-o-transition: var(--byline-transition) ; -ms-transition: var(--byline-transition) }
.byline a, .byline a:visited { color: #aaa ; text-decoration: none !important }
.byline a:hover {
color: ${ appScheme == 'dark' ? 'white' : 'black' };
transition: var(--byline-transition) ;
-webkit-transition: var(--byline-transition) ; -moz-transition: var(--byline-transition) ;
-o-transition: var(--byline-transition) ; -ms-transition: var(--byline-transition) }
#${app.slug}-header-btns { display: flex ; direction: rtl ; gap: 2px ; float: right ; margin-top: 2px }
.${app.slug}-header-btn {
float: right ; cursor: pointer ; position: relative ; top: 4px ;
${ appScheme == 'dark' ? 'fill: white ; stroke: white' : 'fill: #adadad ; stroke: #adadad' }}
.${app.slug}-header-btn:hover svg { /* highlight/zoom header button on hover */
${ appScheme == 'dark' ? 'fill: #d9d9d9 ; stroke: #d9d9d9' : 'fill: black ; stroke: black' };
${ env.browser.isMobile ? '' : 'transform: scale(1.285)' }}
${ app.config.fgAnimationsDisabled ? '' :
`.${app.slug}-header-btn, .${app.slug}-header-btn svg { /* smooth header button fade-in + hover-zoom */
transition: var(--btn-transition) ;
-webkit-transition: var(--btn-transition) ; -moz-transition: var(--btn-transition) ;
-o-transition: var(--btn-transition) ; -ms-transition: var(--btn-transition) }`}
.${app.slug}-header-btn:active {
${ appScheme == 'dark' ? 'fill: #999999 ; stroke: #999999'
: 'fill: #638ed4 ; stroke: #638ed4' }}
#${app.slug}-logo, .${app.slug}-header-btn svg {
filter: drop-shadow(${ appScheme == 'dark' ? '#7171714d 10px' : '#aaaaaa21 7px' } 7px 3px) }
#${app.slug} .loading {
color: #b6b8ba ; fill: #b6b8ba ; animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite }
#${app.slug} section.loading { padding-left: 5px } /* left-pad loading status when sending replies */
#${app.slug}-font-size-slider-track {
width: 98% ; height: 7px ; margin: -6px auto ${ env.browser.isCompact ? -5 : -10 }px ;
padding: 15px 0 ; background-color: #ccc ; box-sizing: content-box; background-clip: content-box ;
-webkit-background-clip: content-box }
#${app.slug}-font-size-slider-track::before { /* to add finger cursor to unpadded core only */
content: "" ; position: absolute ; top: 10px ; left: 0 ; right: 0 ;
height: calc(100% - 20px) ; cursor: pointer }
#${app.slug}-font-size-slider-tip {
z-index: 1 ; position: absolute ; bottom: 20px ;
border-left: 4.5px solid transparent ; border-right: 4.5px solid transparent ;
border-bottom: 16px solid #ccc }
#${app.slug}-font-size-slider-thumb {
z-index: 2 ; width: 7px ; height: 25px ; border-radius: 30% ; position: relative ;
top: -7.5px ; cursor: ew-resize ;
background-color: ${ appScheme == 'dark' ? 'white' : '#4a4a4a' };
--shadow: rgba(0,0,0,0.21) 1px 1px 9px 0 ;
box-shadow: var(--shadow) ; -webkit-box-shadow: var(--shadow) ; -moz-box-shadow: var(--shadow) ;
${ app.config.fgAnimationsDisabled ? '' : `transition: var(--font-size-slider-thumb-transition)
-webkit-transition: var(--font-size-slider-thumb-transition) ;
-moz-transition: var(--font-size-slider-thumb-transition) ;
-o-transition: var(--font-size-slider-thumb-transition) ;
-ms-transition: var(--font-size-slider-thumb-transition)` }}
${ env.browser.isMobile ? '' : `#${app.slug}-font-size-slider-thumb:hover { transform: scale(1.125) }`}
.${app.slug}-standby-btns { margin: 14px 0 -3px }
.${app.slug}-standby-btn {
--skew: skew(-13deg) ; --counter-skew: skew(13deg) ; border-radius: 8px ;
--content-color: ${ appScheme == 'dark' ? 'white' : 'black' };
display: flex ; align-items: center ; justify-content: center ; gap: 8px ;
width: 90% ; height: 51px ; margin-bottom: 9px ; padding: 12px 0 ;
cursor: pointer ; transform: var(--skew) ; border: 1px solid var(--content-color) ;
background: none ; box-shadow: #aaaaaa12 7px 7px 3px 0px ; color: var(--content-color) ;
${ app.config.fgAnimationsDisabled ? ''
: `will-change: transform ;
transition: var(--standby-btn-transition) ;
-webkit-transition: var(--standby-btn-transition) ;
-moz-transition: var(--standby-btn-transition) ;
-o-transition: var(--standby-btn-transition) ;
-ms-transition: var(--standby-btn-transition)` }}
.${app.slug}-standby-btn:hover {
color: var(--content-color) ; border-radius: 2px ; transform: var(--skew) var(--standby-btn-zoom) }
.${app.slug}-standby-btn > span { transform: var(--counter-skew) }
.${app.slug}-standby-btn > svg {
position: relative ; stroke: var(--content-color) ; fill: stroke: var(--content-color) ;
transform: var(--counter-skew) }
.${app.slug}-standby-btn:nth-child(odd) { margin-right: 10% }
.${app.slug}-standby-btn:nth-child(even) { margin-left: 10% ; margin-bottom: 19px }
.${app.slug}-standby-btn:first-of-type svg { /* Query button icon */
width: 11px ; height: 11px ; top: -1.5px ; right: -1.5px }
.${app.slug}-standby-btn:nth-of-type(2) svg { /* Summarize button icon */
width: 17.5px ; height: 17.5px }`
// AI reply elem styles
+ `#${app.slug} .reply-tip {
content: "" ; position: relative ; border: 7px solid transparent ;
float: left ; left: 9px ; margin: 2px -13px 0 -1px ; /* positioning */
border-bottom-style: solid ; border-bottom-width: 20px ; border-top: 0 ; border-bottom-color:
${ // hide reply tip for terminal aesthetic
isParticlizedDS ? '#0000' : `var(--reply-header-bg-color-${appScheme}-scheme)` }}
#${app.slug} .reply-header {
display: flex ; align-items: center ; position: relative ; box-sizing: border-box ; width: 100% ;
top: 14px ; padding: 15px 14px ; height: 18px ; border-radius: 12px 12px 0 0 ;
${ appScheme == 'light' ? 'border-bottom: 1px solid white'
: isParticlizedDS ? 'border: 1px solid ; border-bottom-color: transparent' : '' };
background: var(--reply-header-bg-color-${appScheme}-scheme) ;
color: var(--reply-header-fg-color-${appScheme}-scheme) ;
fill: var(--reply-header-fg-color-${appScheme}-scheme) ;
stroke: var(--reply-header-fg-color-${appScheme}-scheme) }
#${app.slug} .api-btn { cursor: pointer ; padding: 5px ; margin: 0 -4px 0 -7px }
#${app.slug} .reply-header-txt { flex-grow: 1 ; font-size: 12px ; font-family: monospace }
#${app.slug} .reply-header-btns { margin: 7.5px -5px 0 }
#${app.slug} .reply-pre {
font-size: ${app.config.fontSize}px ; white-space: pre-wrap ; min-width: 0 ;
line-height: ${ app.config.fontSize * app.config.lineHeightRatio }px ; overscroll-behavior: contain ;
position: relative ; z-index: 1 ; /* allow top-margin to overlap header in light scheme */
margin: ${ appScheme == 'light' ? 11 : 13 }px 0 7px 0 ; padding: 1.25em 1.25em 0 1.25em ;
border-radius: 0 0 12px 12px ; overflow: auto ;
${ app.config.bgAnimationsDisabled ? // classic opaque bg
`background: var(--pre-bg-color-${appScheme}-scheme) ;
color: var(--font-color-${appScheme}-scheme)`
: appScheme == 'dark' ? // slightly tranluscent bg
'background: #2b3a40cf ; color: var(--font-color-dark-scheme) ; border: 1px solid white'
: /* light scheme */ `background: var(--pre-bg-color-light-scheme) ;
color: var(--font-color-light-scheme) ; border: none` };
${ app.config.fgAnimationsDisabled ? '' : // smoothen Anchor mode expand/shrink
`transition: var(--reply-pre-transition) ;
-webkit-transition: var(--reply-pre-transition) ;
-moz-transition: var(--reply-pre-transition) ;
-o-transition: var(--reply-pre-transition) ;
-ms-transition: var(--reply-pre-transition)` }}
#${app.slug} .reply-pre a, #${app.slug} .reply-pre a:visited { color: #4495d4 }
#${app.slug} .reply-pre a:hover { color: ${ appScheme == 'dark' ? 'white' : '#ea7a28' }}
#${app.slug} .code-header {
display: flex ; direction: rtl ; gap: 9px ; align-items: center ;
height: 11px ; margin: 3px -2px 0 }
#${app.slug} .code-header btn { cursor: pointer }
#${app.slug} .code-header svg { height: 13px ; width: 13px ; fill: white }`
// Rendered markdown styles
+ `#${app.slug} .reply-pre h1 { font-size: 1.8em }
#${app.slug} .reply-pre h2 { font-size: 1.65em }
#${app.slug} .reply-pre h3 { font-size: 1.4em ; line-height: 1.25 }
#${app.slug} .reply-pre h1, #${app.slug} .reply-pre h2, #${app.slug} .reply-pre h3 {
margin-bottom: -15px } /* reduce gap after headings */
#${app.slug} .reply-pre ol { margin: -16px 0 -20px 7px }
#${app.slug} .reply-pre ol > li { margin: -10px 0 -6px 1.6em ; list-style: decimal }
#${app.slug} .reply-pre ol > li::marker { font-size: 0.9em } /* shrink number markers */
#${app.slug} .reply-pre ul { margin: -14px 0 -16px } /* reduce v-padding */
#${app.slug} .reply-pre ul > li { /* reduce v-padding, show hollow bullets */
margin: -10px 0 0 1.2em ; list-style: circle }
#${app.slug} .reply-pre ul ul { margin-top: 0 } /* push sub-lists down */
#${app.slug} .reply-pre ul ul > li { list-style: disc } /* fill sub-bullets */`
// Rendered code styles
+ `#${app.slug} ${GM_getResourceText('hljsCSS') // color code
.replace(/\/\*[^*]+\*\//g, '') // strip comments
.trim().replace(/([,}])(.)(?![^{]*\})/g, `$1#${app.slug} $2`)} /* scope selectors to app */
#${app.slug} pre:has(> code) { padding: 0 } /* remove padded border around code blocks */
#${app.slug} code { font-size: 0.85em } /* shrink code vs. regular text */`
// Rendered math styles
+ '.katex-html { display: none } /* hide unrendered math */'
// Chatbar styles
+ `#${app.slug}-chatbar {
border: solid 1px ${ isParticlizedDS ? '#aaa' : appScheme == 'dark' ? '#777' : '#555' };
border-radius: 12px 13px 12px 0 ; margin: 3px 0 15px 0 ; padding: 13px 57px 9px 10px ;
font-size: 0.92rem ; height: 19px ; width: 82.6% ; max-height: 200px ; resize: none ;
position: relative ; z-index: 555 ; color: #${ appScheme == 'dark' ? 'eee' : '222' };
background: ${ appScheme == 'light' ? '#eeeeee9e'
: `#515151${ app.config.bgAnimationsDisabled ? '' : '9e' }`};
${ appScheme == 'dark' ? '' :
`--chatbar-inset-shadow: 0 1px 2px rgba(15,17,17,0.1) inset ;
box-shadow: var(--chatbar-inset-shadow) ; -webkit-box-shadow: var(--chatbar-inset-shadow) ;
-moz-box-shadow: var(--chatbar-inset-shadow) ;` }
transition: box-shadow 0.15s ease ;
-webkit-transition: box-shadow 0.15s ease ; -moz-transition: box-shadow 0.15s ease ;
-o-transition: box-shadow 0.15s ease ; -ms-transition: box-shadow 0.15s ease }
${ isParticlizedDS ? '' : ` /* chatbar hover styles */
#${app.slug}-chatbar:hover:not(:focus),
div:has(.${app.slug}-chatbar-btn:hover) #${app.slug}-chatbar:not(:focus) {
outline: ${ appScheme == 'light' ? 'black' : 'white' } auto 5px ;
--chatbar-hover-inset-shadow: 0 ${
appScheme == 'dark' ? '3px 2px' : '1px 7px' } rgba(15,17,17,0.15) inset ;
box-shadow: var(--chatbar-hover-inset-shadow) ;
-webkit-box-shadow: var(--chatbar-hover-inset-shadow) ;
-moz-box-shadow: var(--chatbar-hover-inset-shadow) ;
transition: box-shadow 0.25s ease ;
-webkit-transition: box-shadow 0.25s ease ; -moz-transition: box-shadow 0.25s ease ;
-o-transition: box-shadow 0.25s ease ; -ms-transition: box-shadow 0.25s ease }`}
#${app.slug}-chatbar:focus-visible { /* fallback outline chatbar + reduce inset shadow on focus */
outline: -webkit-focus-ring-color auto 1px ;
${ isParticlizedDS ? '' :
`--inset-shadow: 0 ${ appScheme == 'dark' ? '3px -1px' : '1px 2px' } rgba(0,0,0,0.3) inset ;
box-shadow: var(--inset-shadow) ;
-webkit-box-shadow: var(--inset-shadow) ; -moz-box-shadow: var(--inset-shadow)` }
}
.${app.slug}-chatbar-btn {
z-index: 560 ; border: none ; float: right ; position: relative ; background: none ;
cursor: pointer ; bottom: ${ env.browser.isFF ? 50 : 53.5 }px ;
transform: scale(1.05) ; margin-right: 3px ; /* zoom 'em a bit */
color: var(--chatbar-btn-color-${appScheme}-scheme) ;
fill: var(--chatbar-btn-color-${appScheme}-scheme) ;
stroke: var(--chatbar-btn-color-${appScheme}-scheme)
}
.${app.slug}-chatbar-btn:hover {
color: var(--chatbar-btn-hover-color-${appScheme}-scheme) ;
fill: var(--chatbar-btn-hover-color-${appScheme}-scheme) ;
stroke: var(--chatbar-btn-hover-color-${appScheme}-scheme)
}`
// Related Queries styles
+ `.${app.slug}-related-queries {
display: flex ; flex-wrap: wrap ; width: 100% ; position: relative ; padding: 0 5px ;
overflow: visible ; /* allow unclipped hover-zoom of large queries */
${ env.browser.isFF ? 'top: -20px ; margin: -3px 0 -10px' : 'top: -25px ; margin: -7px 0 -15px' }}
.${app.slug}-related-query {
font-size: 0.88em ; cursor: pointer ; will-change: transform ;
box-sizing: border-box ; width: fit-content ; max-width: 100% ; /* confine to outer div */
margin: 4px 12px 8px 0 ; padding: 4px 10px 5px 10px ;
color: ${ appScheme == 'dark' ? ( app.config.bgAnimationsDisabled ? '#ccc' : '#f2f2f2' )
: '#767676' };
background: ${ appScheme == 'dark' ? '#7e7e7e4f' : '#fdfdfdb0' };
border: 1px solid ${ appScheme == 'dark' ? (
app.config.bgAnimationsDisabled ? '#5f5f5f' : '#777' ) : '#e1e1e1' };
border-radius: 0 13px 12px 13px ; flex: 0 0 auto ;
--rq-shadow: 1px 4px 8px -6px rgba(169,169,169,0.75) ; box-shadow: var(--rq-shadow) ;
-webkit-box-shadow: var(--rq-shadow) ; -moz-box-shadow: var(--rq-shadow) ;
${ app.config.fgAnimationsDisabled ? '' : `transition: var(--rq-transition) ;
-webkit-transition: var(--rq-transition) ; -moz-transition: var(--rq-transition) ;
-o-transition: var(--rq-transition) ; -ms-transition: var(--rq-transition)` }}
.${app.slug}-related-query:hover, .${app.slug}-related-query:focus {
${ app.config.fgAnimationsDisabled ? '' : 'transform: scale(1.055) !important ;' }
background: ${ appScheme == 'dark' ? '#a2a2a270'
: '#dae5ffa3 ; color: #000000a8 ; border-color: #a3c9ff' }}
.${app.slug}-related-query svg { /* related query icon */
position: relative ; top: 4px ; margin-right: 6px ;
color: ${ appScheme == 'dark' ? '#aaa' : '#c1c1c1' }}`
// Footer styles
+ `#${app.slug} + footer {
font-size: 13px ; line-height: 1.25 ; text-align: right ;
display: block ; width: 100% ; margin: 14px 0 25px ; position: relative }
#${app.slug} + footer, #${app.slug} + footer a {
color: #${ appScheme == 'dark' ? 'ccc' : 'aaa' }}`
// Notif styles
+ `.chatgpt-notif {
fill: white ; stroke: white ; color: white ; padding: 7.5px 14px 6.5px 11.5px !important }
.notif-close-btn { display: none !important }` // hide notif close btn
// Menu styles
+ `.${app.slug}-menu {
position: absolute ; z-index: 2250 ;
padding: 3.5px 5px !important ; font-family: "Source Sans Pro", sans-serif ; font-size: 12px }
.${app.slug}-menu ul { margin: 0 ; padding: 0 ; list-style: none }
.${app.slug}-menu-item { padding: 0 5px ; line-height: 20.5px }
.${app.slug}-menu-item:not(.${app.slug}-menu-header):hover {
cursor: pointer ; background: white ; color: black ; fill: black }`
// Wider Sidebar styles
+ `section[data-area=sidebar]:has(#${app.slug}.wider) {
min-width: 530px !important ; flex-basis: 530px !important }
section[data-area=mainline]:has(~ section #${app.slug}.wider) { max-width: 590px !important }`
// Sticky Sidebar styles
+ `#${app.slug}.sticky { position: sticky ; top: 14px }
#${app.slug}.sticky ~ * { display: none } /* hide sidebar contents */
body:has(#${app.slug}.sticky), div.site-wrapper:has(#${app.slug}.sticky) {
overflow: clip }` // replace `overflow: hidden` to allow stickiness
// Anchor Mode styles
+ `#${app.slug}.anchored {
position: fixed ; bottom: -7px ; right: 35px ; width: 388px ; z-index: 8888 ;
border: var(--app-border) ; box-shadow: var(--app-anchored-shadow) ;
${ app.config.bgAnimationsDisabled ? `background: var(--app-bg-color-${appScheme}-scheme)`
: 'background-image: var(--app-gradient-bg)' }}
#${app.slug}.expanded { width: 528px !important }
#${app.slug}.anchored .anchored-hidden, #${app.slug}.anchored ~ .anchored-hidden {
/* hide non-Anchor elems in mode */ display: none }
#${app.slug}:not(.anchored) .anchored-only {
/* hide Anchor elems outside mode */ display: none }
body:has(#${app.slug}.anchored) [data-testid=feedback-prompt] {
/* hide blocking footer DDG feedback button */ display: none }`
// Touch device styles
+ `@media (hover: none) {
#${app.slug} .app-hover-only { /* show app-hover-only elems */
position: relative ; left: auto ; width: auto ; opacity: 1 }
#${app.slug} *:hover { transform: none !important } /* disable hover fx */
}`
// Phone styles
+ `@media screen and (max-width: 480px) {
#${app.slug} {
border: var(--app-border) ;
${ app.config.bgAnimationsDisabled ? `background: var(--app-bg-color-${appScheme}-scheme)`
: 'background-image: var(--app-gradient-bg)' }}
#${app.slug} #${app.slug}-logo { width: calc(100% - 118px) } /* widen logo till btns */
#${app.slug} .byline { display: none !important } /* hide byline */
#${app.slug} .reply-tip { display: none } /* hide reply tip */
.${app.slug}-related-queries { padding: 0 } /* remove RQ parent padding */
}`
)
themes.apply(app.config.theme)
},
bylineVisibility() {
if (env.browser.isCompact) return // since byline hidden by app.styles
// Init header elems
const headerElems = { byline: app.div.querySelector('.byline') }
if (!headerElems.byline) return // since in loading state
Object.assign(headerElems, {
btns: app.div.querySelectorAll(`#${app.slug}-header-btns > btn`),
logo: app.div.querySelector(`#${app.slug}-logo`)
})
// Calc/store widths of app/x-padding + header elems
const appDivStyle = getComputedStyle(app.div)
const widths = {
appDiv: app.div.getBoundingClientRect().width,
appDivXpadding: parseFloat(appDivStyle.paddingLeft) + parseFloat(appDivStyle.paddingRight)
}
Object.entries(headerElems).forEach(([key, elem]) => widths[key] = dom.get.computedWidth(elem))
// Hide/show byline based on space available
const availSpace = widths.appDiv - widths.appDivXpadding - widths.logo - widths.btns -10
Object.assign(headerElems.byline.style, widths.byline > availSpace ?
{ position: 'absolute', left: '-9999px', opacity: 0 } // hide using position to support transition
: { position: '', left: '', opacity: 1 } // show
)
},
chatbarWidth() {
const chatbar = app.div.querySelector(`#${app.slug}-chatbar`)
if (chatbar) chatbar.style.width = `${
app.config.widerSidebar && !app.config.anchored ? 85.6 : app.config.expanded ? 86.9 : 82.6 }%`
},
async footerContent() {
// Init advertisers data
const advertisersData = await get.json(
'https://cdn.jsdelivr.net/gh/KudoAI/ads-library/advertisers/index.json'
).catch(err => log.error(err.message)) ; if (!advertisersData) return
// Pick random advertiser
let chosenAdvertiser
for (const [advertiser, details] of shuffle(applyBoosts(Object.entries(advertisersData))))
if (details.campaigns.text) { chosenAdvertiser = advertiser ; break }
if (!chosenAdvertiser) return
// Init chosen advertiser's campaigns data
const campaignsData = await get.json(
`https://cdn.jsdelivr.net/gh/KudoAI/ads-library/advertisers/${chosenAdvertiser}/text/campaigns.json`
).catch(err => log.error(err.message)) ; if (!campaignsData) return
// Init vars for ad selection
const reAppName = new RegExp(app.name.toLowerCase(), 'i')
const currentDate = (() => { // in YYYYMMDD format
const today = new Date(), year = today.getFullYear(),
month = String(today.getMonth() + 1).padStart(2, '0'),
day = String(today.getDate()).padStart(2, '0')
return year + month + day
})() ; let adSelected = false
// Select random, active campaign
for (const [campaignName, campaign] of shuffle(applyBoosts(Object.entries(campaignsData)))) {
const campaignIsActive = campaign.active && (!campaign.endDate || currentDate <= campaign.endDate)
if (!campaignIsActive) continue // to next campaign since campaign inactive
// Select random active group
for (const [groupName, adGroup] of shuffle(applyBoosts(Object.entries(campaign.adGroups)))) {
// Skip disqualified groups
if ( // self-group for other apps
/^self$/i.test(groupName) && !reAppName.test(campaignName)
|| ( // non-self group for this app
reAppName.test(campaignName) && !/^self$/i.test(groupName))
|| adGroup.active == false // group explicitly disabled
|| adGroup.targetBrowsers && // target browser(s) exist...
!adGroup.targetBrowsers.some( // ...but doesn't match user's
browser => new RegExp(browser, 'i').test(navigator.userAgent))
|| adGroup.targetLocations && ( // target locale(s) exist...
// ...but user locale is missing or excluded
!env.userLocale || !adGroup.targetLocations.some(
loc => loc.includes(env.userLocale) || env.userLocale.includes(loc)))
) continue // to next group
// Filter out inactive ads, pick random active one
const activeAds = adGroup.ads.filter(ad => ad.active != false)
if (!activeAds.length) continue // to next group since no ads active
const chosenAd = activeAds[Math.floor(chatgpt.randomFloat() * activeAds.length)]
// Build destination URL
let destinationURL = chosenAd.destinationURL || adGroup.destinationURL || campaign.destinationURL || ''
if (destinationURL.includes('http')) { // insert UTM tags
const [baseURL, queryString] = destinationURL.split('?'),
queryParams = new URLSearchParams(queryString || '')
queryParams.set('utm_source', app.name.toLowerCase())
queryParams.set('utm_content', 'app_footer_link')
destinationURL = `${baseURL}?${queryParams.toString()}`
}
// Update footer content
app.footerContent.setAttribute('class', '') // reset for re-fade
const newFooterContent = destinationURL ? dom.create.anchor(destinationURL)
: dom.create.elem('span')
app.footerContent.replaceWith(newFooterContent) ; app.footerContent = newFooterContent
app.footerContent.classList.add('fade-in', 'anchored-hidden')
app.footerContent.textContent = chosenAd.text
app.footerContent.setAttribute('title', chosenAd.tooltip || '')
setTimeout(() => app.footerContent.classList.add('active'), 100) // to trigger fade
adSelected = true ; break
}
if (adSelected) break // out of campaign loop after ad selection
}
function shuffle(list) {
let currentIdx = list.length, tempValue, randomIdx
while (currentIdx != 0) { // elements remain to be shuffled
randomIdx = Math.floor(chatgpt.randomFloat() * currentIdx) ; currentIdx -=1
tempValue = list[currentIdx] ; list[currentIdx] = list[randomIdx] ; list[randomIdx] = tempValue
} return list
}
function applyBoosts(list) {
let boostedList = [...list],
boostedListLength = boostedList.length -1 // for applying multiple boosts
list.forEach(([name, data]) => { // check for boosts
if (data.boost) { // boost flagged entry's selection probability
const boostPercent = parseInt(data.boost) / 100
const entriesNeeded = Math.ceil(boostedListLength / (1 - boostPercent)) // total entries needed
* boostPercent -1 // reduced to boosted entries needed
for (let i = 0 ; i < entriesNeeded ; i++) boostedList.push([name, data]) // saturate list
boostedListLength += entriesNeeded // update for subsequent calculations
}})
return boostedList
}
},
replyPrefix() {
const firstP = app.div.querySelector('pre p') ; if (!firstP) return
const prefixNeeded = env.ui.app.scheme == 'dark'
&& !app.config.bgAnimationsDisabled && !/shuffle|summarize/.test(get.reply.src)
const prefixExists = firstP.textContent.startsWith('>> ')
if (prefixNeeded && !prefixExists) firstP.prepend('>> ')
else if (!prefixNeeded && prefixExists) firstP.textContent = firstP.textContent.replace(/^>> /, '')
},
risingParticles() {
['sm', 'med', 'lg'].forEach(size =>
document.querySelectorAll(`[id*=particles-${size}]`).forEach(particlesDiv =>
particlesDiv.id = app.config.bgAnimationsDisabled ? `particles-${size}-off`
: `${ env.ui.app.scheme == 'dark' ? 'white' : 'gray' }-particles-${size}`))
},
rqVisibility() {
const rqsDiv = app.div.querySelector(`.${app.slug}-related-queries`)
if (rqsDiv) // update visibility based on latest setting
rqsDiv.style.display = app.config.rqDisabled || app.config.anchored ? 'none' : 'flex'
},
scheme(newScheme) {
env.ui.app.scheme = newScheme ; logos.duckduckgpt.update() ; update.appStyle()
update.risingParticles() ; update.replyPrefix() ; modals.settings.updateSchemeStatus()
}
}
// Define TOGGLE functions
window.toggle = {
anchorMode(state = '') {
const prevState = app.config.anchored // for restraining notif if no change from Pin menu 'Sidebar' click
let sidebarModeToggled = false // to extend this notif duration
// Save new state + disable incompatible Sidebar modes
if (state == 'on' || !state && !app.config.anchored) {
settings.save('anchored', true)
;['sticky', 'wider'].forEach(mode => {
if (app.config[`${mode}Sidebar`]) { toggle.sidebar(mode) ; sidebarModeToggled = true }})
} else {