-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathbravegpt.user.js
4073 lines (3661 loc) · 249 KB
/
bravegpt.user.js
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 BraveGPT 🤖
// @description Adds AI answers to Brave Search (powered by GPT-4o!)
// @description:af Voeg AI-antwoorde by Brave Search (aangedryf deur GPT-4o!)
// @description:am የ Brave Search ውስጥ AI መልቀቅን አድርግ፣ (GPT-4o በመሣሪያዎቹ ውስጥ!)
// @description:ar يضيف إجابات AI إلى Brave Search (مدعوم بواسطة GPT-4o!)
// @description:as Brave Search-লৈ AI উত্তৰ যোগ দিয়ে (GPT-4o দ্বাৰা পাওৱা হৈছে!)
// @description:az Brave Search-ya AI cavablarını əlavə edir (GPT-4o tərəfindən dəstəklənir!)
// @description:be Дадае ІА адказы на Brave Search (падтрымліваецца GPT-4o!)
// @description:bg Добавя ИИ отговори в Brave Search (поддържан от GPT-4o!)
// @description:bn Brave Search-ত AI উত্তর যোগ করে (GPT-4o দ্বারা প্রচালিত!)
// @description:bs Dodaje AI odgovore na Brave Search (pokreće GPT-4o!)
// @description:ca Afegeix respostes d'IA a Brave Search (impulsat per GPT-4o!)
// @description:ceb Nagdugang ug mga tubag AI ngadto sa Brave Search (gipadagan sa GPT-4o!)
// @description:co Aggiunge risposte AI a Brave Search (supportate da GPT-4o!)
// @description:cs Přidává AI odpovědi do Brave Search (poháněno GPT-4o!)
// @description:cy Ychwanegu atebion AI i Brave Search (a yrrir gan GPT-4o!)
// @description:da Tilføjer AI-svar til Brave Search (drevet af GPT-4o!)
// @description:de Fügt AI-Antworten zu Brave Search hinzu (betrieben von GPT-4o!)
// @description:el Προσθέτει απαντήσεις AI στο Brave Search (τροφοδοτούμενο από GPT-4o!)
// @description:en Adds AI answers to Brave Search (powered by GPT-4o!)
// @description:eo Aldonas AI-respondojn al Brave Search (ebligita de GPT-4o!)
// @description:es Añade respuestas de IA a Brave Search (impulsado por GPT-4o!)
// @description:et Lisab AI-vastused Brave Search'le (juhitud GPT-4o-ga!)
// @description:eu Gehitu IA erantzunak Brave Search-n (GPT-4o-k bultzatuta!)
// @description:fa پاسخهای هوشمصنوعی به Brave Search اضافه میشود (توسط GPT-4o پشتیبانی میشود!)
// @description:fi Lisää tekoälyvastauksia Brave Search:hun (ohjattu GPT-4o:lla!)
// @description:fil Nagdaragdag ng mga sagot ng AI sa Brave Search (pinapagana ng GPT-4o!)
// @description:fo Bætir AI svar við Brave Search (drifin af GPT-4o!)
// @description:fr Ajoute des réponses IA à Brave Search (propulsé par GPT-4o!)
// @description:fr-CA Ajoute des réponses IA à Brave Search (propulsé par GPT-4o!)
// @description:fy Foeget AI-antwurden ta oan Brave Search (dreaun troch GPT-4o!)
// @description:ga Cuirtear freagraí AI le Brave Search (dírítear ag GPT-4o!)
// @description:gd Cur freagairtichean AI ris an Brave Search (air a thug seachad le GPT-4o!)
// @description:gl Engade respostas de IA a Brave Search (impulsado por GPT-4o!)
// @description:gu Brave Search માટે AI જવાબો ઉમેરે છે (GPT-4o દ્વારા પોવરેડ!)
// @description:ha Ƙaddara takardun AI zu Brave Search (da aka fi GPT-4o!)
// @description:haw Hoʻohui aku i nā hoʻopiʻi AI iā Brave Search (hoʻohui ʻia e GPT-4o!)
// @description:he מוסיף תשובות AI ל-Brave Search (מופעל על ידי GPT-4o!)
// @description:hi Brave Search में AI उत्तर जोड़ता है (GPT-4o द्वारा संचालित!)
// @description:hmn Ntxig AI nruab nruab rau Brave Search (pab cuam GPT-4o!)
// @description:hr Dodaje AI odgovore na Brave Search (pokreće GPT-4o!)
// @description:ht Ajoute repons AI nan Brave Search (pòte pa GPT-4o!)
// @description:hu AI válaszokat ad hozzá a Brave Search-hoz (GPT-4o által hajtva!)
// @description:hy Ավելացնում է AI պատասխաններ Brave Search-ում (աջակցված է GPT-4o-ով!)
// @description:ia Adde responas AI a Brave Search (propulsate per GPT-4o!)
// @description:id Menambahkan jawaban AI ke Brave Search (didukung oleh GPT-4o!)
// @description:ig Tinye ihe ndekọ AI n'ụzọ ọgụgụ Brave Search (n'efu na GPT-4o!)
// @description:ii Brave Search ᐸᔦᒪᔪᐃᓃᑦ AI ᓇᑕᐅᒪᐃᑦᓯ (GPT-4o ᓂᑕᔪᑦᓯᐏᑦᑕᒥᔭ!)
// @description:is Bætir AI svar við Brave Search (keyrir á GPT-4o!)
// @description:it Aggiunge risposte AI a Brave Search (alimentato da GPT-4o!)
// @description:iu Brave Search ᑲᑎᒪᔪᖅᑐᖅᑐᐃᓐᓇᓂᒃ AI ᑎᑎᕋᖃᕐᓯᒪᓂᖏᓐ (GPT-4o ᑐᑭᒧᑦᑖᑦ!)
// @description:ja Brave Search に AI 回答を追加します (GPT-4o で動作!)
// @description:jv Nambéhi pirangga AI nganti Brave Search (diduweni déning GPT-4o!)
// @description:ka ამატებს AI პასუხებს Brave Search-ს (იმართება GPT-4o!)
// @description:kk Brave Search-ға AI жауаптарын қосады (GPT-4o арқылы жұмыс істейді!)
// @description:kl Brave Search-mi AI-t Kalaallit Nunaanni iluani (GPT-4o! -nip ilaanni!)
// @description:km បន្ថែមចម្លើយ AI ទៅ Brave Search (ដំណើរការដោយ GPT-4o!)
// @description:kn Brave Search ಗೆ AI ಉತ್ತರಗಳನ್ನು ಸೇರಿಸುತ್ತದೆ (GPT-4o ನಿಂದ ನಡೆಸಲ್ಪಡುತ್ತಿದೆ!)
// @description:ko Brave Search에 AI 답변을 추가합니다(GPT-4o 제공!)
// @description:ku Bersivên AI-ê li Brave Search zêde dike (ji hêla GPT-4o ve hatî hêzdar kirin!)
// @description:ky Brave Search'го AI жоопторун кошот (GPT-4o тарабынан иштейт!)
// @description:la Addit AI responsa Brave Search (powered per GPT-4o!)
// @description:lb Füügt AI Äntwerten op Brave Search (ugedriwwen duerch GPT-4o!)
// @description:lg Yambula emisomo ey'ensobi ku Brave Search (enkuuma GPT-4o!)
// @description:ln Ebakisi biyano ya AI na Brave Search (ezali na nguya ya GPT-4o!)
// @description:lo ເພີ່ມຄໍາຕອບ AI ໃຫ້ກັບ Brave Search (ຂັບເຄື່ອນໂດຍ GPT-4o!)
// @description:lt Prideda AI atsakymus į „Brave Search“ (maitina GPT-4o!)
// @description:lv Pievieno AI atbildes Brave Search (darbina GPT-4o!)
// @description:mg Manampy valiny AI amin'ny Brave Search (nampiasain'ny GPT-4o!)
// @description:mi Ka taapirihia nga whakautu AI ki a Brave Search (whakamahia e GPT-4o!)
// @description:mk Додава одговори со вештачка интелигенција на Brave Search (напојувано од GPT-4o!)
// @description:ml Brave Search-യിലേക്ക് AI ഉത്തരങ്ങൾ ചേർക്കുന്നു (GPT-4o നൽകുന്നതാണ്!)
// @description:mn Brave Search-д AI хариултуудыг нэмдэг (GPT-4o-оор ажилладаг!)
// @description:mr Brave Search ला AI उत्तरे जोडते (GPT-4o द्वारे समर्थित!)
// @description:ms Menambahkan jawapan AI pada Brave Search (dikuasakan oleh GPT-4o!)
// @description:mt Iżżid it-tweġibiet AI għal Brave Search (mħaddma minn GPT-4o!)
// @description:my Brave Search (GPT-4o ဖြင့် စွမ်းဆောင်ထားသည့်) တွင် AI အဖြေများကို ပေါင်းထည့်သည်
// @description:na Aeta AI teroma i Brave Search (ira GPT-4o reke akea!)
// @description:nb Legger til AI-svar på Brave Search (drevet av GPT-4o!)
// @description:nd Iyatholakala amaswelelo e-AI kuBrave Search (kuyatholakala ngokulawula uGPT-4o!)
// @description:ne Brave Search मा AI जवाफहरू थप्छ (GPT-4o द्वारा संचालित!)
// @description:ng Ondjova mbelelo dha AI moBrave Search (uumbuli nguGPT-4o!)
// @description:nl Voegt AI-antwoorden toe aan Brave Search (mogelijk gemaakt door GPT-4o!)
// @description:nn Legg til AI-svar på Brave Search (drevet av GPT-4o!)
// @description:no Legger til AI-svar til Brave Search (drevet av GPT-4o!)
// @description:nso Ya go etela ditshenyegi tsa AI mo Brave Search (e dirwang ke GPT-4o!)
// @description:ny Imawonjezera mayankho a AI ku Brave Search (yoyendetsedwa ndi GPT-4o!)
// @description:oc Ajusta de respòstas d'IA a Brave Search (amb GPT-4o!)
// @description:om Deebii AI Brave Search (GPT-4o'n kan hojjetu!) irratti dabalata.
// @description:or Brave Search କୁ AI ଉତ୍ତର ଯୋଗ କରେ (GPT-4o ଦ୍ୱାରା ଚାଳିତ!)
// @description:pa Brave Search (GPT-4o ਦੁਆਰਾ ਸੰਚਾਲਿਤ!) ਵਿੱਚ AI ਜਵਾਬ ਸ਼ਾਮਲ ਕਰਦਾ ਹੈ
// @description:pl Dodaje odpowiedzi AI do Brave Search (obsługiwane przez GPT-4o!)
// @description:ps Brave Search ته د AI ځوابونه اضافه کوي (د GPT-4o لخوا پرمخ وړل کیږي!)
// @description:pt Adiciona respostas de IA ao Brave Search (desenvolvido por GPT-4o!)
// @description:pt-BR Adiciona respostas de IA ao Brave Search (desenvolvido por GPT-4o!)
// @description:qu Brave Search (GPT-4o nisqawan kallpachasqa!) nisqaman AI kutichiykunata yapan.
// @description:rm Agiuntescha respostas d'IA a Brave Search (propulsà da GPT-4o!)
// @description:rn Abafasha inyandiko z'IA ku Brave Search (yashyizweho na GPT-4o!)
// @description:ro Adaugă răspunsuri AI la Brave Search (alimentat de GPT-4o!)
// @description:ru Добавляет ответы ИИ в Brave Search (на базе GPT-4o!)
// @description:rw Ongeraho ibisubizo bya AI kuri Brave Search (ikoreshwa na GPT-4o!)
// @description:sa Brave Search (GPT-4o द्वारा संचालितम्!) इत्यत्र AI उत्तराणि योजयति ।
// @description:sat Brave Search ar AI jawab khon ojantok (GPT-4o! sebadha manju)
// @description:sc Agiungit rispostas de IA a Brave Search (motorizadu da GPT-4o!)
// @description:sd شامل ڪري ٿو AI جوابن کي Brave Search (GPT-4o پاران طاقتور!)
// @description:se Lávdegáhtii AI vástid Brave Search (GPT-4o! vuosttas!)
// @description:sg Nâ tî-kûzâ mái vêdáara AI mbi Brave Search (ngâ GPT-4o!)
// @description:si Brave Search වෙත AI පිළිතුරු එක් කරයි (GPT-4o මගින් බලගන්වයි!)
// @description:sk Pridáva odpovede AI do Brave Search (poháňané GPT-4o!)
// @description:sl Dodaja odgovore AI v Brave Search (poganja GPT-4o!)
// @description:sm Faʻaopoopo tali AI ile Brave Search (faʻamalosia e GPT-4o!)
// @description:sn Inowedzera mhinduro dzeAI kuBrave Search (inofambiswa neGPT-4o!)
// @description:so Waxay ku dartay jawaabaha AI Brave Search (waxaa ku shaqeeya GPT-4o!)
// @description:sq Shton përgjigjet e AI në Brave Search (mundësuar nga GPT-4o!)
// @description:sr Додаје АИ одговоре у Brave Search (покреће ГПТ-4о!)
// @description:ss Iphendvulela izindlela zezilungiselelo ku-Brave Search (izenzakalo nge-GPT-4o!)
// @description:st E kopanetse diqoqo tsa AI ka Brave Search (ka sebelisoa ke GPT-4o!)
// @description:su Nambahkeun jawaban AI kana Brave Search (dikuatkeun ku GPT-4o!)
// @description:sv Lägger till AI-svar till Brave Search (driven av GPT-4o!)
// @description:sw Inaongeza majibu ya AI kwa Brave Search (inaendeshwa na GPT-4o!)
// @description:ta Brave Search க்கு AI பதில்களைச் சேர்க்கிறது (GPT-4o மூலம் இயக்கப்படுகிறது!)
// @description:te Brave Searchకి AI సమాధానాలను జోడిస్తుంది (GPT-4o ద్వారా ఆధారితం!)
// @description:tg Ба Brave Search ҷавобҳои AI илова мекунад (аз ҷониби GPT-4o!)
// @description:th เพิ่มคำตอบ AI ให้กับ Brave Search (ขับเคลื่อนโดย GPT-4o!)
// @description:ti ናብ Brave Search (ብGPT-4o ዝሰርሕ!) ናይ AI መልስታት ይውስኸሉ።
// @description:tk Brave Search-a AI jogaplaryny goşýar (GPT-4o bilen işleýär!)
// @description:tl Nagdadagdag ng mga sagot ng AI sa Brave Search (pinapatakbo ng GPT-4o!)
// @description:tn O amogela dipotso tsa AI mo Brave Search (e a nang le GPT-4o!)
// @description:to Tambisa mabizo a AI ku Brave Search (mukutenga na GPT-4o!)
// @description:tr Brave Search'ya yapay zeka yanıtları ekler (GPT-4o tarafından desteklenmektedir!)
// @description:ts Ku engetela tinhlamulo ta AI eka Brave Search (leyi fambiwaka hi GPT-4o!)
// @description:tt Brave Search'ка AI җаваплары өсти (GPT-4o белән эшләнгән!)
// @description:tw Ɔde AI mmuae ka Brave Search (a GPT-4o na ɛma ahoɔden!) ho.
// @description:ug Brave Search ۋەبسېتكە AI جاۋابلار قوشۇدۇ (GPT-4o تەكشۈرگۈچى بىلەن!)
// @description:uk Додає відповіді штучного інтелекту в Brave Search (на базі GPT-4o!)
// @description:ur Brave Search میں AI جوابات شامل کرتا ہے (GPT-4o کے ذریعے تقویت یافتہ!)
// @description:uz Brave Search-ga AI javoblarini qo'shadi (GPT-4o tomonidan quvvatlanadi!)
// @description:vi Thêm câu trả lời AI vào Brave Search (được cung cấp bởi GPT-4o!)
// @description:xh Yongeza iimpendulo ze-AI kwi-Brave Search (ixhaswe yi-GPT-4o!)
// @description:yi לייגט אַי ענטפֿערס צו Brave Search (Powered דורך GPT-4o!)
// @description:yo Ṣe afikun awọn idahun AI si Brave Search (agbara nipasẹ GPT-4o!)
// @description:zh 为 Brave Search 添加 AI 答案(由 GPT-4o 提供支持!)
// @description:zh-CN 为 Brave Search 添加 AI 答案(由 GPT-4o 提供支持!)
// @description:zh-HK 為 Brave Search 添加 AI 答案(由 GPT-4o 提供支援!)
// @description:zh-SG 为 Brave Search 添加 AI 答案(由 GPT-4o 提供支持!)
// @description:zh-TW 為 Brave Search 添加 AI 答案(由 GPT-4o 提供支援!)
// @description:zu Yengeza izimpendulo ze-AI ku-Brave Search (inikwa amandla yi-GPT-4o!)
// @author KudoAI
// @namespace https://kudoai.com
// @version 2025.1.25.19
// @license MIT
// @icon https://assets.bravegpt.com/images/icons/bravegpt/icon48.png?v=df624b0
// @icon64 https://assets.bravegpt.com/images/icons/bravegpt/icon64.png?v=df624b0
// @compatible chrome except for Streaming Mode w/ Tampermonkey (use ScriptCat instead)
// @compatible firefox
// @compatible edge except for Streaming Mode w/ Tampermonkey (use ScriptCat instead)
// @compatible opera after allowing userscript manager access to search page results in opera://extensions
// @compatible brave except for Streaming Mode w/ Tampermonkey (use ScriptCat instead)
// @compatible vivaldi except for Streaming Mode w/ Tampermonkey (use ScriptCat instead)
// @compatible waterfox
// @compatible librewolf
// @compatible ghost
// @compatible qq
// @compatible whale
// @compatible kiwi
// @compatible mask
// @compatible orion
// @match *://search.brave.com/search*
// @include https://auth0.openai.com
// @connect am.aifree.site
// @connect api.binjie.fun
// @connect api.openai.com
// @connect api11.gptforlove.com
// @connect assets.aiwebextensions.com
// @connect cdn.jsdelivr.net
// @connect chatai.mixerbox.com
// @connect chatgpt.com
// @connect fanyi.sogou.com
// @connect gm.bravegpt.com
// @connect raw.githubusercontent.com
// @connect toyaml.com
// @require https://cdn.jsdelivr.net/npm/@kudoai/[email protected]/dist/chatgpt.min.js#sha256-+C0x4BOFQc38aZB3pvUC2THu+ZSvuCxRphGdtRLjCDg=
// @require https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.2.0/crypto-js.min.js#sha256-dppVXeVTurw1ozOPNE3XqhYmDJPOosfbKQcHyQSE58w=
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/generate-ip.min.js#sha256-aQQKAQcMgCu8IpJp9HKs387x0uYxngO+Fb4pc5nSF4I=
// @require https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js#sha256-g3pvpbDHNrUrveKythkPMF2j/J7UFoHbUyFQcFe1yEY=
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js#sha256-n0UwfFeU7SR6DQlfOmLlLvIhWmeyMnIDp/2RmVmuedE=
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js#sha256-e1fUJ6xicGd9r42DgN7SzHMzb5FJoWe44f4NbvZmBK4=
// @require https://cdn.jsdelivr.net/npm/[email protected]/marked.min.js#sha256-Ffq85bZYmLMrA/XtJen4kacprUwNbYdxEKd0SqhHqJQ=
// @resource bgptIcon https://assets.bravegpt.com/images/icons/bravegpt/icon64.png.b64?v=a76e718#sha256-Abqr6XIwT+g72ig2haUUkniR89b5UlxL28cAI6BVT/c=
// @resource bgptLSlogo https://assets.bravegpt.com/images/logos/bravegpt/lightmode/logo730x155.png.b64?v=a76e718#sha256-gGomHdYcs/AE4Ep8dAJhPFbCX6uyHmb38vi9hWYJZLI=
// @resource bgptDSlogo https://assets.bravegpt.com/images/logos/bravegpt/darkmode/logo730x155.png.b64?v=a76e718#sha256-2Qx4bTS8s7dKj4m2dsJdPnijThaYRwYQMi30+KjtopI=
// @resource hljsCSS https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/dark.min.css#sha256-v0N76BFFkH0dCB8bUr4cHSVN8A/zCaOopMuSmJWV/5w=
// @resource brsCSS https://assets.aiwebextensions.com/styles/rising-stars/dist/black.min.css?v=3289404#sha256-CTj6Ndngq+TsPlNpQ6Ej39PQKSDpmxyKUFohhc91ruQ=
// @resource wrsCSS https://assets.aiwebextensions.com/styles/rising-stars/dist/white.min.css?v=3289404#sha256-tOOIvIe6O5/x2A5E7s9kP4+zw0d4EEDfRgXQLq2KwLs=
// @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.bravegpt.com
// @updateURL https://gm.bravegpt.com
// @homepageURL https://www.bravegpt.com
// @supportURL https://support.bravegpt.com
// @contributionURL https://github.com/sponsors/KudoAI
// ==/UserScript==
// Dependencies:
// ✓ chatgpt.js (https://chatgpt.js.org) © 2023–2025 KudoAI & contributors under the MIT license
// ✓ generate-ip (https://generate-ip.org) © 2024–2025 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
// Documentation: https://docs.bravegpt.com
(async () => {
// Init ENV context
const 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]())
env.browser.isPortrait = env.browser.isMobile && (window.innerWidth < window.innerHeight)
env.browser.isPhone = env.browser.isMobile && window.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
const xhr = typeof GM != 'undefined' && GM.xmlHttpRequest || GM_xmlhttpRequest
// Init APP data
const app = {
name: 'BraveGPT', version: GM_info.script.version, symbol: '🦁',
configKeyPrefix: 'braveGPT', slug: 'bravegpt',
chatgptJSver: /chatgpt\.js@([\d.]+)/.exec(GM_info.scriptMetaStr)[1],
author: { name: 'KudoAI', url: 'https://kudoai.com' },
urls: {
app: 'https://www.bravegpt.com',
chatgptJS: 'https://chatgpt.js.org',
contributors: 'https://docs.bravegpt.com/#-contributors',
discuss: 'https://github.com/KudoAI/bravegpt/discussions',
gitHub: 'https://github.com/KudoAI/bravegpt',
publisher: 'https://www.kudoai.com',
relatedExtensions: 'https://github.com/adamlui/ai-web-extensions',
review: {
alternativeTo: 'https://alternativeto.net/software/bravegpt/about/',
productHunt: 'https://www.producthunt.com/products/bravegpt/reviews/new'
},
support: 'https://support.bravegpt.com',
update: 'https://gm.bravegpt.com'
},
latestResourceCommitHash: '908456f' // for cached messages.json
}
app.urls.resourceHost = app.urls.gitHub.replace('github.com', 'cdn.jsdelivr.net/gh') + `@${app.latestResourceCommitHash}`
app.msgs = {
appDesc: 'Adds ChatGPT answers to Brave Search sidebar (powered by GPT-4o!)',
menuLabel_proxyAPImode: 'Proxy API Mode',
menuLabel_autoGetAnswers: 'Auto-Get Answers',
menuLabel_autoFocusChatbar: 'Auto-Focus Chatbar',
menuLabel_whenStreaming: 'when streaming',
menuLabel_show: 'Show',
menuLabel_relatedQueries: 'Related Queries',
menuLabel_require: 'Require',
menuLabel_beforeQuery: 'before query',
menuLabel_afterQuery: 'after query',
menuLabel_widerSidebar: 'Wider Sidebar',
menuLabel_stickySidebar: 'Sticky Sidebar',
menuLabel_pinTo: 'Pin to',
menuLabel_top: 'Top',
menuLabel_sidebar: 'Sidebar',
menuLabel_bottom: 'Bottom',
menuLabel_background: 'Background',
menuLabel_foreground: 'Foreground',
menuLabel_animations: 'Animations',
menuLabel_replyLanguage: 'Reply Language',
menuLabel_colorScheme: 'Color Scheme',
menuLabel_auto: 'Auto',
menuLabel_about: 'About',
menuLabel_settings: 'Settings',
about_author: 'Author',
about_and: '&',
about_contributors: 'contributors',
about_version: 'Version',
about_poweredBy: 'Powered by',
about_openSourceCode: 'Open source code',
scheme_light: 'Light',
scheme_dark: 'Dark',
mode_proxy: 'Proxy Mode',
mode_streaming: 'Streaming Mode',
mode_autoScroll: 'Auto-Scroll',
mode_prefix: 'Prefix Mode',
mode_suffix: 'Suffix Mode',
mode_anchor: 'Anchor Mode',
mode_dev: 'Dev Mode',
tooltip_playAnswer: 'Play answer',
tooltip_fontSize: 'Font size',
tooltip_sendReply: 'Send reply',
tooltip_askRandQuestion: 'Ask random question',
tooltip_minimize: 'Minimize',
tooltip_restore: 'Restore',
tooltip_expand: 'Expand',
tooltip_shrink: 'Shrink',
tooltip_close: 'Close',
tooltip_copy: 'Copy',
tooltip_regen: 'Regenerate',
tooltip_reply: 'Reply',
tooltip_code: 'Code',
tooltip_sendRelatedQuery: 'Send related query',
helptip_proxyAPImode: 'Uses a Proxy API for no-login access to AI',
helptip_streamingMode: 'Receive replies in a continuous text stream',
helptip_autoGetAnswers: 'Auto-send queries to BraveGPT when using search engine',
helptip_autoFocusChatbar: 'Auto-focus chatbar whenever it appears',
helptip_autoScroll: 'Auto-scroll responses as they generate in Streaming Mode',
helptip_showRelatedQueries: 'Show related queries below chatbar',
helptip_prefixMode: 'Require "/" before queries for answers to show',
helptip_suffixMode: 'Require "?" after queries for answers to show',
helptip_widerSidebar: 'Horizontally expand search page sidebar',
helptip_stickySidebar: 'Makes BraveGPT visible in sidebar even as you scroll',
helptip_anchorMode: 'Anchor BraveGPT to bottom of window',
helptip_bgAnimations: 'Show animated backgrounds in UI components',
helptip_fgAnimations: 'Show foreground animations in UI components',
helptip_replyLanguage: 'Language for BraveGPT to reply in',
helptip_colorScheme: 'Scheme to display BraveGPT UI components in',
helptip_devMode: 'Show detailed logging in browser console',
placeholder_askSomethingElse: 'Ask something else',
placeholder_typeSomething: 'Type something',
prompt_updateReplyLang: 'Update reply language',
alert_langUpdated: 'Language updated',
alert_willReplyIn: 'will reply in',
alert_yourSysLang: 'your system language',
alert_choosePlatform: 'Choose a platform',
alert_updateAvail: 'Update available',
alert_newerVer: 'An update to',
alert_isAvail: 'is available',
alert_upToDate: 'Up-to-date',
alert_isUpToDate: 'is up-to-date',
alert_unavailable: 'unavailable',
alert_isOnlyAvailFor: 'is only available for',
alert_and: 'and',
alert_userscriptMgrNoStream: 'Your userscript manager does not support returning stream responses',
alert_isCurrentlyOnlyAvailBy: 'is currently only available by',
alert_openAIsupportSoon: 'Support for OpenAI API will be added shortly',
alert_waitingFor: 'Waiting for',
alert_response: 'response',
alert_login: 'Please login',
alert_thenRefreshPage: 'then refresh this page',
alert_tooManyRequests: 'ChatGPT is flooded with too many requests',
alert_parseFailed: 'Failed to parse response JSON',
alert_checkCloudflare: 'Please pass Cloudflare security check',
alert_notWorking: 'is not working',
alert_ifIssuePersists: 'If issue persists',
alert_try: 'Try',
alert_switchingOn: 'switching on',
alert_switchingOff: 'switching off',
notif_copiedToClipboard: 'Copied to clipboard',
btnLabel_sendQueryToApp: 'Send search query to BraveGPT',
btnLabel_moreAIextensions: 'More AI Extensions',
btnLabel_rateUs: 'Rate Us',
btnLabel_getSupport: 'Get Support',
btnLabel_checkForUpdates: 'Check for Updates',
btnLabel_update: 'Update',
btnLabel_dismiss: 'Dismiss',
link_viewChanges: 'View changes',
link_shareFeedback: 'Feedback',
prefix_exit: 'Exit',
state_on: 'On',
state_off: 'Off'
}
// Init API data
const apis = Object.assign(Object.create(null), await new Promise(resolve => xhr({
method: 'GET', url: 'https://assets.aiwebextensions.com/data/ai-chat-apis.json?v=b7a8a8b',
onload: resp => resolve(JSON.parse(resp.responseText))
})))
apis.AIchatOS.userID = '#/chat/' + Date.now()
// Init DEV Mode
const config = {}
const settings = {
load(...keys) {
keys.flat().forEach(key => {
config[key] = GM_getValue(`${app.configKeyPrefix}_${key}`,
this.controls?.[key]?.defaultVal ?? this.controls?.[key]?.type == 'toggle')
})
},
save(key, val) { GM_setValue(`${app.configKeyPrefix}_${key}`, val) ; config[key] = val }
}
settings.load('devMode')
// Define LOG props/functions
const log = {
styles: {
prefix: {
base: `color: white ; padding: 2px 3px 2px 5px ; border-radius: 2px ; ${
env.browser.isFF ? 'font-size: 13px ;' : '' }`,
info: 'background: linear-gradient(344deg, rgba(0,0,0,1) 0%,'
+ 'rgba(0,0,0,1) 39%, rgba(30,29,43,0.6026611328125) 93%)',
working: 'background: linear-gradient(342deg, rgba(255,128,0,1) 0%,'
+ 'rgba(255,128,0,0.9612045501794468) 57%, rgba(255,128,0,0.7539216370141807) 93%)' ,
success: 'background: linear-gradient(344deg, rgba(0,107,41,1) 0%,'
+ 'rgba(3,147,58,1) 39%, rgba(24,126,42,0.7735294801514356) 93%)',
warning: 'background: linear-gradient(344deg, rgba(255,0,0,1) 0%,'
+ 'rgba(232,41,41,0.9079832616640406) 57%, rgba(222,49,49,0.6530813008797269) 93%)',
caller: 'color: blue'
},
msg: { working: 'color: #ff8000', warning: 'color: red' }
},
regEx: {
greenVals: { caseInsensitive: /\b(?:true|\d+)\b|success\W?/i, caseSensitive: /\bON\b/ },
redVals: { caseInsensitive: /\bfalse\b|error\W?/i, caseSensitive: /\BOFF\b/ },
purpVals: /[ '"]\w+['"]?: / },
prettifyObj(obj) { return JSON.stringify(obj)
.replace(/([{,](?=")|":)/g, '$1 ') // append spaces to { and "
.replace(/((?<!\})\})/g, ' $1') // prepend spaces to }
.replace(/"/g, '\'') // replace " w/ '
},
toTitleCase(str) { return str.charAt(0).toUpperCase() + str.slice(1) }
} ; ['info', 'error', 'dev'].forEach(logType =>
log[logType] = function() {
if (logType == 'dev' && !config.devMode) return
const args = Array.from(arguments).map(arg => typeof arg == 'object' ? JSON.stringify(arg) : arg)
const msgType = args.some(arg => /\.{3}$/.test(arg)) ? 'working'
: args.some(arg => /\bsuccess\b|!$/i.test(arg)) ? 'success'
: args.some(arg => /\b(?:error|fail)\b/i.test(arg)) || logType == 'error' ? 'warning'
: 'info'
const prefixStyle = log.styles.prefix.base + log.styles.prefix[msgType]
const baseMsgStyle = log.styles.msg[msgType], msgStyles = []
// Combine regex
const allPatterns = Object.values(log.regEx).flatMap(val =>
val instanceof RegExp ? [val] : Object.values(val).filter(val => val instanceof RegExp))
const combinedPattern = new RegExp(allPatterns.map(pattern => pattern.source).join('|'), 'g')
// Combine args into finalMsg, color chars
let finalMsg = logType == 'error' && args.length == 1 ? 'ERROR: ' : ''
args.forEach((arg, idx) => {
finalMsg += idx > 0 ? (idx == 1 ? ': ' : ' ') : '' // separate multi-args
finalMsg += arg?.toString().replace(combinedPattern, match => {
const matched = (
Object.values(log.regEx.greenVals).some(val => {
if (val.test(match)) { msgStyles.push('color: green', baseMsgStyle) ; return true }})
|| Object.values(log.regEx.redVals).some(val => {
if (val.test(match)) { msgStyles.push('color: red', baseMsgStyle) ; return true }}))
if (!matched && log.regEx.purpVals.test(match)) { msgStyles.push('color: #dd29f4', baseMsgStyle) }
return `%c${match}%c`
})
})
console[logType == 'error' ? logType : 'info'](
`${app.symbol} %c${app.name}%c ${ log.caller ? `${log.caller} » ` : '' }%c${finalMsg}`,
prefixStyle, log.styles.prefix.caller, baseMsgStyle, ...msgStyles
)
}
)
// LOCALIZE app.msgs for non-English users
if (!env.browser.language.startsWith('en')) {
log.dev('Localizing app messages...')
const localizedMsgs = await new Promise(resolve => {
const msgHostDir = app.urls.resourceHost + '/greasemonkey/_locales/',
msgLocaleDir = ( env.browser.language ? env.browser.language.replace('-', '_') : 'en' ) + '/'
let msgHref = msgHostDir + msgLocaleDir + 'messages.json', msgXHRtries = 0
function fetchMsgs() { xhr({ method: 'GET', url: msgHref, 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
msgXHRtries++ ; if (msgXHRtries == 3) return resolve({}) // try original/region-stripped/EN only
msgHref = env.browser.language.includes('-') && msgXHRtries == 1 ? // if regional lang on 1st try...
msgHref.replace(/([^_]+_[^_]+)_[^/]*(\/.*)/, '$1$2') // ...strip region before retrying
: ( msgHostDir + 'en/messages.json' ) // else use default English messages
fetchMsgs()
}
}
fetchMsgs()
})
Object.assign(app.msgs, localizedMsgs)
log.dev(`Success! app.msgs = ${log.prettifyObj(app.msgs)}`)
}
// Init SETTINGS
log.dev('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 },
streamingDisabled: { type: 'toggle', icon: 'signalStream', defaultVal: false,
label: app.msgs.mode_streaming,
helptip: app.msgs.helptip_streamingMode },
autoGetDisabled: { type: 'toggle', icon: 'speechBalloonLasso', defaultVal: false,
label: app.msgs.menuLabel_autoGetAnswers,
helptip: app.msgs.helptip_autoGetAnswers },
autoFocusChatbarDisabled: { type: 'toggle', mobile: false, icon: 'caretsInward', defaultVal: false,
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, icon: 'widescreen', defaultVal: false,
label: app.msgs.menuLabel_widerSidebar,
helptip: app.msgs.helptip_widerSidebar },
stickySidebar: { type: 'toggle', mobile: false, icon: 'webCorner', defaultVal: false,
label: app.msgs.menuLabel_stickySidebar,
helptip: app.msgs.helptip_stickySidebar },
anchored: { type: 'toggle', mobile: 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 },
devMode: { type: 'toggle', icon: 'code', defaultVal: false,
label: app.msgs.mode_dev,
helptip: app.msgs.helptip_devMode },
about: { type: 'modal', icon: 'questionMarkCircle',
label: `${app.msgs.menuLabel_about} ${app.name}...` }
}})
Object.assign(config, { minFontSize: 11, maxFontSize: 24, lineHeightRatio: 1.313 })
settings.load([...Object.keys(settings.controls), 'expanded', 'fontSize', 'minimized'])
if (!config.replyLang) settings.save('replyLang', env.browser.language) // init reply language if unset
if (!config.fontSize) settings.save('fontSize', 16) // init reply font size if unset
if (!env.scriptManager.supportsStreaming) settings.save('streamingDisabled', true) // disable Streaming in unspported env
log.dev(`Success! config = ${log.prettifyObj(config)}`)
// Init INPUT EVENTS
const inputEvents = {} ; ['down', 'move', 'up'].forEach(action =>
inputEvents[action] = ( window.PointerEvent ? 'pointer' : env.browser.isMobile ? 'touch' : 'mouse' ) + action)
// Init ALERTS
Object.assign(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}.`,
openAInotWorking: `OpenAI API ${app.msgs.alert_notWorking}.`,
suggestProxy: `${app.msgs.alert_try} ${app.msgs.alert_switchingOn} ${app.msgs.mode_proxy}`,
suggestOpenAI: `${app.msgs.alert_try} ${app.msgs.alert_switchingOff} ${app.msgs.mode_proxy}`
}})
// Define MENU functions
const menu = {
ids: [], state: {
symbols: ['❌', '✔️'], separator: env.scriptManager.name == 'Tampermonkey' ? ' — ' : ': ',
words: [app.msgs.state_off.toUpperCase(), app.msgs.state_on.toUpperCase()]
},
register() {
// Add Proxy API Mode toggle
const pmLabel = menu.state.symbols[+config.proxyAPIenabled] + ' '
+ settings.controls.proxyAPIenabled.label + ' '
+ menu.state.separator + menu.state.words[+config.proxyAPIenabled]
menu.ids.push(GM_registerMenuCommand(pmLabel, toggle.proxyMode,
env.scriptManager.supportsTooltips ? { title: settings.controls.proxyAPIenabled.helptip } : undefined));
// Add About/Settings entries
['about', 'settings'].forEach(entryType => menu.ids.push(GM_registerMenuCommand(
entryType == 'about' ? `💡 ${settings.controls.about.label}` : `⚙️ ${app.msgs.menuLabel_settings}`,
() => modals.open(entryType), env.scriptManager.supportsTooltips ? { title: ' ' } : undefined
)))
},
refresh() {
if (typeof GM_unregisterMenuCommand == 'undefined') {
log.dev('GM_unregisterMenuCommand not supported.') ; return }
for (const id of menu.ids) { GM_unregisterMenuCommand(id) } menu.register()
}
}
function updateCheck() {
log.caller = 'updateCheck()'
log.dev(`currentVer = ${app.version}`)
// Fetch latest meta
log.dev('Fetching latest userscript metadata...')
xhr({
method: 'GET', url: app.urls.update + '?t=' + Date.now(),
headers: { 'Cache-Control': 'no-cache' },
onload: resp => {
log.dev('Success! Response received')
// Compare versions, alert if update found
log.dev('Comparing versions...')
app.latestVer = /@version +(.*)/.exec(resp.responseText)?.[1]
if (app.latestVer) for (let i = 0 ; i < 4 ; i++) { // loop thru subver's
const currentSubVer = parseInt(app.version.split('.')[i], 10) || 0,
latestSubVer = parseInt(app.latestVer.split('.')[i], 10) || 0
if (currentSubVer > latestSubVer) break // out of comparison since not outdated
else if (latestSubVer > currentSubVer) // if outdated
return modals.open('update', 'available')
}
// Alert to no update found, nav back to About
modals.open('update', 'unavailable')
}})
}
// Define FEEDBACK functions
function appAlert(...alerts) {
alerts = alerts.flat() // flatten array args nested by spread operator
appDiv.textContent = ''
const alertP = document.createElement('p')
alertP.id = `${app.slug}-alert` ; alertP.className = 'no-user-select'
alertP.style.marginBottom = '-20px' // counteract appDiv padding
alerts.forEach((alert, idx) => { // process each alert for display
let msg = app.alerts[alert] || alert // use string verbatim if not found in app.alerts
if (idx > 0) msg = ' ' + msg // left-pad 2nd+ alerts
if (msg.includes(app.alerts.login)) session.deleteOpenAIcookies()
if (msg.includes(app.alerts.waitingResponse)) alertP.classList.add('loading')
// Add login link to login msgs
if (msg.includes('@'))
msg += '<a class="alert-link" target="_blank" rel="noopener"'
+ ' href="https://chatgpt.com">chatgpt.com</a>,'
+ ` ${app.msgs.alert_thenRefreshPage}.`
+ ` (${app.msgs.alert_ifIssuePersists},`
+ ` ${( app.msgs.alert_try ).toLowerCase() }`
+ ` ${app.msgs.alert_switchingOn}`
+ ` ${app.msgs.mode_proxy})`
// Hyperlink app.msgs.alert_switching<On|Off>
const foundState = ['On', 'Off'].find(state =>
msg.includes(app.msgs['alert_switching' + state]) || new RegExp(`\\b${state}\\b`, 'i').test(msg))
if (foundState) { // hyperlink switch phrase for click listener to toggle.proxyMode()
const switchPhrase = app.msgs['alert_switching' + foundState] || 'switching ' + foundState.toLowerCase()
msg = msg.replace(switchPhrase, `<a class="alert-link" href="#">${switchPhrase}</a>`)
}
// Create/fill/append msg span
const msgSpan = document.createElement('span')
msgSpan.innerHTML = msg ; alertP.append(msgSpan)
// Activate toggle link if necessary
msgSpan.querySelector('[href="#"]')?.addEventListener('click', toggle.proxyMode)
})
appDiv.append(alertP)
}
function notify(msg, pos = '', notifDuration = '', shadow = 'shadow') {
// Strip state word to append styled one later
const foundState = menu.state.words.find(word => msg.includes(word))
if (foundState) msg = msg.replace(foundState, '')
// Show notification
chatgpt.notify(msg, pos, notifDuration, shadow)
const notif = document.querySelector('.chatgpt-notif:last-child')
// Prepend app icon
const notifIcon = icons.braveGPT.create()
notifIcon.style.cssText = 'width: 32px ; position: relative ; top: 6px ; margin-right: 6px'
notif.prepend(notifIcon)
// Append notif type icon
const iconStyles = 'width: 28px ; height: 28px ; position: relative ; top: 3px ; margin-left: 11px ;',
mode = Object.keys(settings.controls).find(key => settings.controls[key].label.includes(msg.trim()))
if (mode && !/(?:pre|suf)fix/.test(mode)) {
const modeIcon = icons[settings.controls[mode].icon].create()
modeIcon.style.cssText = iconStyles
+ ( /autoget|focus|scroll/i.test(mode) ? 'top: 0.5px' : '' ) // raise some icons
+ ( /animation/i.test(mode) ? 'width: 23px ; height: 23px' : '' ) // shrink Animations icon
notif.append(modeIcon)
}
// Append styled state word
if (foundState) {
const styledStateSpan = document.createElement('span')
styledStateSpan.style.cssText = `font-weight: bold ; color: ${
foundState == menu.state.words[0] ? '#ef4848 ; text-shadow: rgba(255,169,225,0.44) 2px 1px 5px'
: '#5cef48 ; text-shadow: rgba(255,250,169,0.38) 2px 1px 5px' }`
styledStateSpan.append(foundState) ; notif.insertBefore(styledStateSpan, notif.children[2])
}
}
// Define MODAL functions
const modals = {
stack: [], // of types of undismissed modals
class: `${app.slug}-modal`,
alert(title = '', msg = '', btns = '', checkbox = '', width = '') { // generic one from chatgpt.alert()
const alertID = chatgpt.alert(title, msg, btns, checkbox, width),
alert = document.getElementById(alertID).firstChild
this.init(alert) // add classes/listeners/hack bg/glowup btns
return alert
},
open(modalType, modalSubType) { // custom ones
const modal = modalSubType ? modals[modalType][modalSubType]()
: (modals[modalType].show || modals[modalType])()
if (!modal) return // since no div returned
if (settings.controls[modalType]?.type != 'prompt') { // add to stack
this.stack.unshift(modalSubType ? `${modalType}_${modalSubType}` : modalType)
log.dev(`Modal stack: ${JSON.stringify(modals.stack)}`)
}
this.init(modal) // add classes/listeners/hack bg/glowup btns
this.observeRemoval(modal, modalType, modalSubType) // to maintain stack for proper nav
if (!modals.handlers.dismiss.key.added) { // add key listener to dismiss modals
document.addEventListener('keydown', modals.handlers.dismiss.key)
modals.handlers.dismiss.key.added = true
}
},
init(modal) {
if (!this.styles) this.stylize() // to init/append stylesheet
// Add classes
modal.classList.add('no-user-select', this.class) ; modal.parentNode.classList.add(`${this.class}-bg`)
// Add listeners
modal.onwheel = modal.ontouchmove = event => event.preventDefault() // disable wheel/swipe scrolling
modal.onmousedown = modals.handlers.drag.mousedown // enable click-dragging
if (!modal.parentNode.className.includes('chatgpt-modal')) { // enable click-dismissing native modals
const dismissElems = [modal.parentNode, modal.querySelector('[class*=-close-btn]')]
dismissElems.forEach(elem => elem.onclick = modals.handlers.dismiss.click)
}
// Hack BG
dom.fillStarryBG(modal)
setTimeout(() => { // dim bg
modal.parentNode.style.backgroundColor = `rgba(67,70,72,${
env.ui.app.scheme == 'dark' ? 0.62 : 0.33 })`
modal.parentNode.classList.add('animated')
}, 100) // delay for transition fx
// Glowup btns
if (env.ui.app.scheme == 'dark' && !config.fgAnimationsDisabled) toggle.btnGlow()
},
stylize() {
if (!this.styles) {
this.styles = document.createElement('style') ; this.styles.id = `${this.class}-styles`
document.head.append(this.styles)
}
this.styles.innerText = (
':root {' // vars
+ '--transition: opacity 0.65s cubic-bezier(0.165,0.84,0.44,1),' // for modal fade-in
+ 'transform 0.55s cubic-bezier(0.165,0.84,0.44,1) !important ;' // for modal move-in
+ '--bg-transition: background-color 0.25s ease !important ;' // for modal bg dim
+ '--btn-transition: transform 0.15s ease ;' // for modal button hover-zoom
+ '--settings-transition: transform 0.1s ease }' // for Settings entry hover-zoom
// Main modal styles
+ '@keyframes modal-zoom-fade-out {'
+ '0% { opacity: 1 } 50% { opacity: 0.25 ; transform: scale(1.05) }'
+ '100% { opacity: 0 ; transform: scale(1.35) }}'
+ '.chatgpt-modal > div { background-color: white !important ; color: #202124 }'
+ '.chatgpt-modal p { margin: 14px 0 -20px 4px ; font-size: 18px }' // pos/size modal msg
+ `.chatgpt-modal a { color: #${ env.ui.app.scheme == 'dark' ? '00cfff' : '1e9ebb' } !important }`
+ '.modal-buttons {'
+ `margin: 38px 0 1px ${ env.browser.isMobile ? 0 : -7 }px !important ; width: 100% }`
+ '.chatgpt-modal button {' // alert buttons
+ 'font-size: 14px ; text-transform: uppercase ; min-width: 123px ; '
+ `padding: ${ env.browser.isMobile ? '5px' : '4px 3px' } !important ;`
+ 'cursor: pointer ; border-radius: 0 !important ; height: 39px ;'
+ 'border: 1px solid ' + ( env.ui.app.scheme == 'dark' ? 'white' : 'black' ) + ' !important }'
+ '.primary-modal-btn { background: black !important ; color: white !important }'
+ '.chatgpt-modal button:hover { background-color: #9cdaff !important ; color: black !important }'
+ ( env.ui.app.scheme == 'dark' ? // darkmode chatgpt.alert() styles
( '.chatgpt-modal > div, .chatgpt-modal button:not(.primary-modal-btn) {'
+ 'background-color: black !important ; color: white !important }'
+ '.primary-modal-btn { background: hsl(186 100% 69%) !important ; color: black !important }'
+ '.chatgpt-modal a { color: #00cfff !important }'
+ '.chatgpt-modal button:hover {'
+ 'background-color: #00cfff !important ; color: black !important }' ) : '' )
+ `.${modals.class} { display: grid ; place-items: center }` // for centered icon/logo
+ '[class*=modal-close-btn] {'
+ 'position: absolute !important ; float: right ; top: 14px !important ; right: 16px !important ;'
+ 'cursor: pointer ; width: 33px ; height: 33px ; border-radius: 20px }'
+ `[class*=modal-close-btn] path {${ env.ui.app.scheme == 'dark' ? 'stroke: white ; fill: white'
: 'stroke: #9f9f9f ; fill: #9f9f9f' }}`
+ ( env.ui.app.scheme == 'dark' ? // invert dark mode hover paths
'[class*=modal-close-btn]:hover path { stroke: black ; fill: black }' : '' )
+ '[class*=modal-close-btn]:hover { background-color: #f2f2f2 }' // hover underlay
+ '[class*=modal-close-btn] svg { margin: 11.5px }' // center SVG for hover underlay
+ '[class*=-modal] h2 {'
+ 'font-size: 26px ; line-height: 32px ; padding: 0 ; margin: 4px 0 -1px !important ;'
+ `${ env.browser.isMobile ? 'text-align: center' // center on mobile
: 'justify-self: start' }}` // left-align on desktop
+ '[class*=-modal] p { justify-self: start ; font-size: 20px }'
+ '[class*=-modal] button { font-size: 14px }'
+ '[class*=-modal-bg] {'
+ 'pointer-events: auto ;' // override any disabling from site modals
+ 'position: fixed ; top: 0 ; left: 0 ; width: 100% ; height: 100% ;' // expand to full view-port
+ 'display: flex ; justify-content: center ; align-items: center ; z-index: 9999 ;' // align
+ 'transition: var(--bg-transition) ;' // for bg dim
+ '-webkit-transition: var(--bg-transition) ; -moz-transition: var(--bg-transition) ;'
+ '-o-transition: var(--bg-transition) ; -ms-transition: var(--bg-transition) }'
+ '[class*=-modal-bg].animated > div {'
+ 'z-index: 13456 ; opacity: 0.98 ; transform: translateX(0) translateY(0) }'
+ '[class$=-modal] {' // native modals + chatgpt.alert()s
+ 'position: absolute ;' // to be click-draggable
+ 'opacity: 0 ;' // to fade-in
+ `background-image: linear-gradient(180deg, ${
env.ui.app.scheme == 'dark' ? '#99a8a6 -200px, black 200px' : '#b6ebff -296px, white 171px' }) ;`
+ `border: 1px solid ${ env.ui.app.scheme == 'dark' ? 'white' : '#b5b5b5' } !important ;`
+ `color: ${ env.ui.app.scheme == 'dark' ? 'white' : 'black' } ;`
+ 'transform: translateX(-3px) translateY(7px) ;' // offset to move-in from
+ 'transition: var(--transition) ;' // for fade-in + move-in
+ '-webkit-transition: var(--transition) ; -moz-transition: var(--transition) ;'
+ '-o-transition: var(--transition) ; -ms-transition: var(--transition) }'
+ ( config.fgAnimationsDisabled || env.browser.isMobile ? '' : (
'[class$=-modal] button:hover { transform: scale(1.055) }'
+ '[class$=-modal] button { transition: var(--btn-transition) ;'
+ '-webkit-transition: var(--btn-transition) ; -moz-transition: var(--btn-transition) ;'
+ '-o-transition: var(--btn-transition) ; -ms-transition: var(--btn-transition) }' ))
// Glowing modal btns
+ ':root { --glow-color: hsl(186 100% 69%) }'
+ '.glowing-btn {'
+ 'perspective: 2em ; font-weight: 900 ; animation: border-flicker 2s linear infinite ;'
+ '-webkit-box-shadow: inset 0 0 0.5em 0 var(--glow-color), 0 0 0.5em 0 var(--glow-color) ;'
+ 'box-shadow: inset 0 0 0.5em 0 var(--glow-color), 0 0 0.5em 0 var(--glow-color) ;'
+ '-moz-box-shadow: inset 0 0 0.5em 0 var(--glow-color), 0 0 0.5em 0 var(--glow-color) }'
+ '.glowing-txt {'
+ 'animation: text-flicker 3s linear infinite ;'
+ '-webkit-text-shadow: 0 0 0.125em hsl(0 0% 100% / 0.3), 0 0 0.45em var(--glow-color) ;'
+ '-moz-text-shadow: 0 0 0.125em hsl(0 0% 100% / 0.3), 0 0 0.45em var(--glow-color) ;'
+ 'text-shadow: 0 0 0.125em hsl(0 0% 100% / 0.3), 0 0 0.45em var(--glow-color) }'
+ '.faulty-letter {'
+ 'opacity: 0.5 ; animation: faulty-flicker 2s linear infinite }'
+ ( !env.browser.isMobile ? 'background: var(--glow-color) ;'
+ 'transform: translateY(120%) rotateX(95deg) scale(1, 0.35)' : '' ) + '}'
+ '.glowing-btn:hover { color: rgba(0,0,0,0.8) ; text-shadow: none ; animation: none }'
+ '.glowing-btn:hover .glowing-txt { animation: none }'
+ '.glowing-btn:hover .faulty-letter { animation: none ; text-shadow: none ; opacity: 1 }'
+ '.glowing-btn:hover:before { filter: blur(1.5em) ; opacity: 1 }'
+ '.glowing-btn:hover:after { opacity: 1 }'
+ '@keyframes faulty-flicker {'
+ '0% { opacity: 0.1 } 2% { opacity: 0.1 } 4% { opacity: 0.5 } 19% { opacity: 0.5 }'
+ '21% { opacity: 0.1 } 23% { opacity: 1 } 80% { opacity: 0.5 } 83% { opacity: 0.4 }'
+ '87% { opacity: 1 }}'
+ '@keyframes text-flicker {'
+ '0% { opacity: 0.1 } 2% { opacity: 1 } 8% { opacity: 0.1 } 9% { opacity: 1 }'
+ '12% { opacity: 0.1 } 20% { opacity: 1 } 25% { opacity: 0.3 } 30% { opacity: 1 }'
+ '70% { opacity: 0.7 } 72% { opacity: 0.2 } 77% { opacity: 0.9 } 100% { opacity: 0.9 }}'
+ '@keyframes border-flicker {'
+ '0% { opacity: 0.1 } 2% { opacity: 1 } 4% { opacity: 0.1 } 8% { opacity: 1 }'
+ '70% { opacity: 0.7 } 100% { opacity: 1 }}'
// Settings modal
+ `#${app.slug}-settings {`
+ 'font-family: var(--brand-font) ;'
+ `min-width: ${ env.browser.isPortrait ? 288 : 758 }px ; max-width: 75vw ; margin: 12px 23px ;`
+ 'word-wrap: break-word ; border-radius: 15px ; box-shadow: 0 30px 60px rgba(0,0,0,0.12) ;'
+ `${ env.ui.app.scheme == 'dark' ? 'stroke: white ; fill: white' : 'stroke: black ; fill: black' }}`
+ `#${app.slug}-settings-title {`
+ 'font-weight: bold ; line-height: 19px ; text-align: center ;'
+ `margin: 0 ${ env.browser.isMobile ? -31 : -6 }px -3px 0 }`
+ `#${app.slug}-settings-title h4 {`
+ `font-size: ${ env.browser.isPortrait ? 26 : 30 }px ; font-weight: bold ;`
+ 'margin: -31px 17px 7px 0 }'
+ `#${app.slug}-settings ul {`
+ 'list-style: none ; padding: 0 ; margin: 0 ;' // hide bullets, override Brave ul margins
+ `width: ${ env.browser.isPortrait ? 100 : 50 }% }` // set width based on column cnt
+ `#${app.slug}-settings li {`
+ `color: ${ env.ui.app.scheme == 'dark' ? 'rgb(255,255,255,0.65)' : 'rgba(0,0,0,0.45)' } ;`
+ `fill: ${ env.ui.app.scheme == 'dark' ? 'rgb(255,255,255,0.65)' : 'rgba(0,0,0,0.45)' } ;`
+ `stroke: ${ env.ui.app.scheme == 'dark' ? 'rgb(255,255,255,0.65)' : 'rgba(0,0,0,0.45)' } ;`
+ 'height: 37px ; padding: 7px 10px ; font-size: 14.5px ;'
+ `border-bottom: 1px dotted ${ env.ui.app.scheme == 'dark' ? 'white' : 'black' } ;` // add separators
+ 'border-radius: 3px ;' // slightly round highlight strip
+ 'transition: var(--settings-transition) ;' // for hover-zoom
+ '-webkit-transition: var(--settings-transition) ; -moz-transition: var(--settings-transition) ;'
+ '-o-transition: var(--settings-transition) ; -ms-transition: var(--settings-transition) }'
+ `#${app.slug}-settings li.active {`
+ `color: ${ env.ui.app.scheme == 'dark' ? 'rgb(255,255,255)' : 'rgba(0,0,0)' } ;` // for text
+ `fill: ${ env.ui.app.scheme == 'dark' ? 'rgb(255,255,255)' : 'rgba(0,0,0)' } ;` // for icons
+ `stroke: ${ env.ui.app.scheme == 'dark' ? 'rgb(255,255,255)' : 'rgba(0,0,0)' }}` // for icons
+ `#${app.slug}-settings li label { padding-right: 20px }` // right-pad labels so toggles don't hug
+ `#${app.slug}-settings li:last-of-type { border-bottom: none }` // remove last bottom-border
+ `#${app.slug}-settings li, #${app.slug}-settings li label { cursor: pointer }` // add finger on hover
+ `#${app.slug}-settings li:hover {`
+ 'opacity: 1 ;'
+ 'background: rgba(100,149,237,0.88) ; color: white ; fill: white ; stroke: white ;'
+ `${ config.fgAnimationsDisabled || env.browser.isMobile ? '' : 'transform: scale(1.15)' }}`
+ `#${app.slug}-settings li > input { float: right }` // pos toggles
+ '#scheme-settings-entry > span { margin: 0 -2px }' // align Scheme status
+ '#scheme-settings-entry > span > svg {' // v-align/left-pad Scheme status icon
+ 'position: relative ; top: 3px ; margin-left: 4px }'
+ ( config.fgAnimationsDisabled ? '' // spin cycle arrows icon when scheme is Auto
: ( '#scheme-settings-entry svg:has([d^="M204-318q-22"]),'
+ '.chatgpt-notif svg:has([d^="M204-318q-22"]) { animation: rotation 5s linear infinite }' ))
+ '@keyframes rotation { from { transform: rotate(0deg) } to { transform: rotate(360deg) }}'
+ `#about-settings-entry span { color: ${ env.ui.app.scheme == 'dark' ? '#28ee28' : 'green' }}`
+ '#about-settings-entry > span {' // outer About status span
+ `width: ${ env.browser.isPortrait ? '15vw' : '95px' } ; height: 20px ; overflow: hidden ;`
+ `${ config.fgAnimationsDisabled ? '' : ( // fade edges
'mask-image: linear-gradient('
+ 'to right, transparent, black 20%, black 89%, transparent) ;'
+ '-webkit-mask-image: linear-gradient('
+ 'to right, transparent, black 20%, black 89%, transparent)' )}}`
+ '#about-settings-entry > span > div {'
+ `text-wrap: nowrap ; ${
config.fgAnimationsDisabled ? '' : 'animation: ticker linear 60s infinite' }}`
+ '@keyframes ticker { 0% { transform: translateX(100%) } 100% { transform: translateX(-2000%) }}'
+ `.about-em { color: ${ env.ui.app.scheme == 'dark' ? 'white' : 'green' } !important }`
)
},
observeRemoval(modal, modalType, modalSubType) { // to maintain stack for proper nav
const modalBG = modal.parentNode
new MutationObserver(([mutation], obs) => {
mutation.removedNodes.forEach(removedNode => { if (removedNode == modalBG) {
if (modals.stack[0].includes(modalSubType || modalType)) { // new modal not launched so nav back
modals.stack.shift() // remove this modal type from stack 1st
const prevModalType = modals.stack[0]
if (prevModalType) { // open it
modals.stack.shift() // remove type from stack since re-added on open
modals.open(prevModalType)
}
}
obs.disconnect()
}})
}).observe(modalBG.parentNode, { childList: true, subtree: true })
},
hide(modal) {
const modalContainer = modal?.parentNode ; if (!modalContainer) return
modalContainer.style.animation = 'modal-zoom-fade-out 0.165s ease-out'
modalContainer.onanimationend = () => modalContainer.remove()
},
handlers: {
dismiss: { // to dismiss native modals
click(event) {
const clickedElem = event.target
if (clickedElem == event.currentTarget || clickedElem.closest('[class*=-close-btn]'))
modals.hide((clickedElem.closest('[class*=-modal-bg]') || clickedElem).firstChild)
},
key(event) {
if (event.key.startsWith('Esc') || event.keyCode == 27)
modals.hide(document.querySelector('[class$=-modal]'))
}
},
drag: {
mousedown(event) { // find modal, attach listeners, init XY offsets
if (event.button != 0) return // prevent non-left-click drag
if (getComputedStyle(event.target).cursor == 'pointer') return // prevent drag on interactive elems
modals.handlers.drag.draggableElem = event.currentTarget
modals.handlers.drag.draggableElem.style.cursor = 'grabbing'
event.preventDefault(); // prevent sub-elems like icons being draggable
['mousemove', 'mouseup'].forEach(eventType =>
document.addEventListener(eventType, modals.handlers.drag[eventType]))
const draggableElemRect = modals.handlers.drag.draggableElem.getBoundingClientRect()
modals.handlers.drag.offsetX = event.clientX - draggableElemRect.left +21
modals.handlers.drag.offsetY = event.clientY - draggableElemRect.top +12
},
mousemove(event) { // drag modal
if (modals.handlers.drag.draggableElem) {
const newX = event.clientX - modals.handlers.drag.offsetX,