ChatGPT Nekonečno ∞

Generujte nekonečné odpovědi od vševědoucího ChatGPT (v jakémkoli jazyce!)

  1. // ==UserScript==
  2. // @name ChatGPT Infinity ∞
  3. // @name:af ChatGPT Oneindig ∞
  4. // @name:ar دردشةGPT إنفينيتي ∞
  5. // @name:az ChatGPT Sonsuzluq ∞
  6. // @name:be ChatGPT Бясконцасць ∞
  7. // @name:bg ChatGPT Безкрайност ∞
  8. // @name:bn ChatGPT ইনফিনিটি ∞
  9. // @name:bo ChatGPT དག་སྐྱེས་ཡོད་པ་ ∞
  10. // @name:bs ChatGPT Beskrajnost ∞
  11. // @name:ca ChatGPT Infinit ∞
  12. // @name:ckb ChatGPT نەپێندییە ∞
  13. // @name:cs ChatGPT Nekonečno ∞
  14. // @name:cy ChatGPT Anfeidredd ∞
  15. // @name:da ChatGPT Uendelighed ∞
  16. // @name:de ChatGPT Unendlichkeit ∞
  17. // @name:dv ChatGPT ނުވަތަ ބާވައްޖޭގެން ∞
  18. // @name:dz ChatGPT རྩེད་སྒྲིབ་གཉིས་ ∞
  19. // @name:el ChatGPT Άπειρο ∞
  20. // @name:eo ChatGPT Infinito ∞
  21. // @name:es ChatGPT Infinito ∞
  22. // @name:et ChatGPT Lõpmatus ∞
  23. // @name:eu ChatGPT Infinitua ∞
  24. // @name:fa ChatGPT بینهایت ∞
  25. // @name:fi ChatGPT Ääretön ∞
  26. // @name:fo ChatGPT Óendanlighed ∞
  27. // @name:fr ChatGPT Infini ∞
  28. // @name:fr-CA ChatGPT Infini ∞
  29. // @name:gl ChatGPT Infinito ∞
  30. // @name:gu ChatGPT અનંત ∞
  31. // @name:haw ChatGPT Māhina ʻole ∞
  32. // @name:he ChatGPT אינסוף ∞
  33. // @name:hi ChatGPT अनंत ∞
  34. // @name:hr ChatGPT Beskrajnost ∞
  35. // @name:hu ChatGPT Végtelenség ∞
  36. // @name:hy ChatGPT Անվերջ ∞
  37. // @name:id ChatGPT Infinity ∞
  38. // @name:is ChatGPT Óendanleiki ∞
  39. // @name:it ChatGPT Infinito ∞
  40. // @name:ja ChatGPT 無限 ∞
  41. // @name:ka ChatGPT უსასრულობა ∞
  42. // @name:km ChatGPT អនឡាញ ∞
  43. // @name:kn ChatGPT ಅನಂತ ∞
  44. // @name:ko ChatGPT 무한 ∞
  45. // @name:ku ChatGPT Pêşangeh ∞
  46. // @name:ky ChatGPT Ички ∞
  47. // @name:la ChatGPT Infinitas ∞
  48. // @name:lb ChatGPT Unendlechkeet ∞
  49. // @name:lo ChatGPT ບໍ່ໄປສູ່ຈັກຂອງສາມຫວ່າງ ∞
  50. // @name:lt ChatGPT Begalybė ∞
  51. // @name:lv ChatGPT Bezgalība ∞
  52. // @name:mk ChatGPT Бесконечност ∞
  53. // @name:ml ChatGPT അനന്തത ∞
  54. // @name:mn ChatGPT Тэгш бус ∞
  55. // @name:mt ChatGPT Infinità ∞
  56. // @name:my ChatGPT မြင်ကွင်း ∞
  57. // @name:ne ChatGPT अनंत ∞
  58. // @name:nl ChatGPT Oneindigheid ∞
  59. // @name:no ChatGPT Uendelighet ∞
  60. // @name:pa ChatGPT ਇਨਫਿਨਿਟੀ ∞
  61. // @name:pl ChatGPT Nieskończoność ∞
  62. // @name:ps ChatGPT لامکان ∞
  63. // @name:pt ChatGPT Infinito ∞
  64. // @name:pt-BR ChatGPT Infinito ∞
  65. // @name:ro ChatGPT Infinitate ∞
  66. // @name:ru ChatGPT Бесконечность ∞
  67. // @name:si ChatGPT අනන්තය ∞
  68. // @name:sk ChatGPT Nekonečno ∞
  69. // @name:sl ChatGPT Neskončnost ∞
  70. // @name:so ChatGPT Qaybtiisa ∞
  71. // @name:sr ChatGPT Бескрајност ∞
  72. // @name:sv ChatGPT Oändlighet ∞
  73. // @name:ta ChatGPT முடிவிலிருந்து ∞
  74. // @name:te ChatGPT అనంతత ∞
  75. // @name:tg ChatGPT Беоҳӣ ∞
  76. // @name:th ChatGPT อนันต์ ∞
  77. // @name:ti ChatGPT መደመር ∞
  78. // @name:tk ChatGPT Sonsuzluk ∞
  79. // @name:tr ChatGPT Sonsuzluk ∞
  80. // @name:uk ChatGPT Нескінченність ∞
  81. // @name:ur ChatGPT بے انتہا ∞
  82. // @name:vi ChatGPT Vô cùng ∞
  83. // @name:yi ChatGPT אינפיניטי ∞
  84. // @name:zh ChatGPT 无限 ∞【支持免梯镜像版】
  85. // @name:zh-CN ChatGPT 无限 ∞【支持免梯镜像版】
  86. // @name:zh-HK ChatGPT 無限 ∞【支持免梯镜像版】
  87. // @name:zh-SG ChatGPT 无限 ∞【支持免梯镜像版】
  88. // @name:zh-TW ChatGPT 無限 ∞【支持免梯镜像版】
  89. // @description Generate endless answers from all-knowing ChatGPT (in any language!)
  90. // @description:af Genereer eindelose antwoorde van die alwetende ChatGPT (in enige taal!)
  91. // @description:am ሓበሬታይ ኣይነበርና መልእኽቲ ኣለኹም ኣሎኻዊ ያልኣይት ChatGPT (በቋንቋ!)
  92. // @description:ar قم بتوليد إجابات لا نهائية من ChatGPT المعرف بكل شيء (بأي لغة!)
  93. // @description:az Hər şeyi bilən ChatGPT-dən sonsuz cavablar yaradın (hər hansı bir dil ilə!)
  94. // @description:be Стварыце бясконцы адказы ад ўсеведучага ChatGPT (на любой мове!)
  95. // @description:bem Pamene mwaposa mafolosho a mʌnoze ChatGPT (mu lupiya lwa ndalama!)
  96. // @description:bg Генерирайте безкрайни отговори от всезнайния ChatGPT (на всяк език!)
  97. // @description:bn সর্বজ্ঞ চ্যাটজিপিটি থেকে অসীম উত্তর তৈরি করুন (যে কোন ভাষায়!)
  98. // @description:bo བཟོས་པ་བརྗོད་པའི་ChatGPTགི་གྲོས་པར་འགྲུབ་འདེམས་བསྐྱེད་མི་འོངས་པ། (ལས་སྐབས་ཀྱི་སྐད་ཡིག་གི་སྐད་!)
  99. // @description:bs Generišite beskonačne odgovore od sveznajućeg ChatGPT (na bilo kom jeziku!)
  100. // @description:ca Genereu respostes infinites des de l'omniscient ChatGPT (en qualsevol idioma!)
  101. // @description:ceb Sukdagon ang walay katapusan nga mga tubag gikan sa tanan-mahibaw-anong ChatGPT (sa bisan unsang pinulongan!)
  102. // @description:ckb پێشبینی چاتگپتەکە دیارییەکانی پێکراوەکان بنووسە (بە هەر زمانێکی دیکە!)
  103. // @description:cs Generujte nekonečné odpovědi od vševědoucího ChatGPT (v jakémkoli jazyce!)
  104. // @description:cy Cynhyrchwch atebion diddiwedd o ChatGPT y gŵr sy'n gwybod popeth (mewn unrhyw iaith!)
  105. // @description:da Generer endeløse svar fra den altvidende ChatGPT (på hvilket som helst sprog!)
  106. // @description:de Generieren Sie endlose Antworten von dem allwissenden ChatGPT (in beliebiger Sprache!)
  107. // @description:dv އެހެނދުކަޗެއްވެސީ ޗެއްސިސްޓޯނަށް ނިޔަލައިފައިވަނީ ސުރުކޮށް ފީހުން (ކަންއެވެސް ހަމަވެސް!)
  108. // @description:dz ཆགས་ཀྱིས་ལ་བརྟེན་གང་རུང་གི་ChatGPTགི་ཚོགས་པའི་སྐད་ཡིག་གྱི་སྐད་ཡིག་བྱེད་པ། (བླ་མའི་སྐད་ཡིག་!)
  109. // @description:el Δημιουργήστε ατελείωτες απαντήσεις από το γνώστη ChatGPT (σε οποιαδήποτε γλώσσα!)
  110. // @description:eo Kreu nesfinaĵajn respondojn el la ĉio-scianta ChatGPT (en ajn lingvo!)
  111. // @description:es Genera respuestas infinitas desde el ChatGPT omnisciente (¡en cualquier idioma!)
  112. // @description:et Loo lõputuid vastuseid kõike-teadvast ChatGPT-st (mis tahes keeles!)
  113. // @description:eu Sortu erantzun infinituak guztiz-arduratsuaren ChatGPT-tik (edozein hizkuntzan!)
  114. // @description:fa پاسخهای بیپایانی را از ChatGPT همهدانا تولید کنید (به هر زبانی!)
  115. // @description:fi Luo loputtomia vastauksia kaikkitietävästä ChatGPT:stä (millä tahansa kielellä!)
  116. // @description:fo Skapa endalaus svør frá altvitandi ChatGPT (á hvørjum málrøð!)
  117. // @description:fr Générez des réponses infinies à partir de ChatGPT qui sait tout (dans n'importe quelle langue!)
  118. // @description:fr-CA Générez des réponses infinies à partir de ChatGPT qui sait tout (dans n'importe quelle langue!)
  119. // @description:gd Cruthaich freagairtean gun crìoch à ChatGPT a tha a' faighneachd gach càil (ann an sam bith cànan!)
  120. // @description:gl Xere as respostas infinitas do ChatGPT que todo o sabe (en calquera lingua!)
  121. // @description:gu જ્ઞાનવાન ChatGPT થી અનંત જવાબો ઉત્પન કરો (કોઈ પણ ભાષામાં!)
  122. // @description:haw Haleleʻa i nā ʻōlelo pālulelo mai ke kupa ʻike loa o ChatGPT (i loko o kēlā ʻōlelo aku aʻe!)
  123. // @description:he יצרו תשובות אינסופיות מה-ChatGPT המבין הכל (בכל שפה!)
  124. // @description:hi सभी-जाननेवाले चैटजीपीटी से अनंत उत्तरों का उत्पादन करें (किसी भी भाषा में!)
  125. // @description:hr Generirajte beskrajne odgovore iz sveznajućeg ChatGPT-a (na bilo kojem jeziku!)
  126. // @description:ht Jenere repons san fen soti nan ChatGPT k-ap konnen tout bagay yo (nan nenpòt lang!)
  127. // @description:hu Végtelen válaszokat generáljon a mindentudó ChatGPT-ből (bármely nyelven!)
  128. // @description:hy Ստեղծեք անսահմանափակ պատասխաններ ամենագիտական ChatGPT-ից (ցանկացած լեզուն մեջ!)
  129. // @description:id Hasilkan jawaban tak terbatas dari ChatGPT yang tahu segalanya (dalam bahasa apa pun!)
  130. // @description:is Búið til endalaus svör frá allvissu ChatGPT (á hvaða tungumáli sem er!)
  131. // @description:it Genera risposte infinite dall'onnisciente ChatGPT (in qualsiasi lingua!)
  132. // @description:ja あらゆる言語で全知のChatGPTから無限の回答を生成します!
  133. // @description:jv Mbukak panggung jawaban saka ChatGPT kang suwénéh kabèh (kénging basa apapun!)
  134. // @description:ka შექმენით უსასრულო პასუხები ყველგანაწილებული ChatGPT-დან (ნელა ენაზე!)
  135. // @description:kab Kkes-as yidir seg yisem-asen n tafriqt ara ddunnit ChatGPT (di tifrat ara ddunit!)
  136. // @description:kk Барлық тілде бар білген ChatGPT-ден шексіз жауаптар жасау (қандай да тілде!)
  137. // @description:km បង្កើតចម្លើយមិនឃើញចប់ពី ChatGPT ដែលចែកសង្ស័យទាំងអស់ (ជាន់គ្រប់ភាសា!)
  138. // @description:kn ಎಲ್ಲರು ತಿಳಿದಿರುವ ಚಾಟ್ಜಿಪಿಟಿಯಿಂದ ಅನಂತ ಉತ್ತರಗಳನ್ನು ರಚಿಸಿ (ಯಾವುದೇ ಭಾಷೆಯಲ್ಲಿ!)
  139. // @description:ko 어떤 언어로든지 무궁무진한 답변을 만들어내는 ChatGPT입니다!
  140. // @description:ku Ji ChatGPT-ê, ku hemî tiştan dizane, bersiva li serbazên li dor qewî yên hilbijartin (bi hertiştî zimanek!)
  141. // @description:ky Түз билимдүү ChatGPT боюнча чыгармаларды жаса
  142. // @description:la Genera infinitas responsiones de ChatGPT omniscio (in qualibet lingua!)
  143. // @description:lb Generéiert endlos Äntwerten vum allwëssende ChatGPT (op jiddere Sprooch!)
  144. // @description:lo ສ້າງຜົນສົດທີ່ສາມາດເລືອກຈາກພາສາທີ່ຮູ້ບຸກກຳລັງ ChatGPT (ໃນພາສາໃດໜຶ່ງ!)
  145. // @description:lt Sugeneruokite begalinį atsakymų kiekį iš visai žinoančio ChatGPT (bet kuria kalba!)
  146. // @description:lv Ģenerē nebeidzamus atbilžu variantus no vissapratīgā ChatGPT (jebkurā valodā!)
  147. // @description:mg Mandoza ny valiny miaraka amin'ny ChatGPT mahalala ny zavatra rehetra (amin'ny fiteny iray kokoa!)
  148. // @description:mi Whakapūmau i ngā whakautu kore mutunga mai i te ChatGPT matau i ngā reo katoa!
  149. // @description:mk Генерирајте безброј одговори од сèзнаената ChatGPT (на било кој јазик!)
  150. // @description:ml എന്നെഴുതാൻ അനന്യനായ ChatGPT (ഏതെങ്കിലും ഭാഷയിൽ) ഇന്നേക്കും വേണ്ടി അവസാനിപ്പിക്കുക!
  151. // @description:mn Сүүлд үлдсэнээсээ хайрцаг болох ChatGPT (ямар ч хэл дээр) дээрхээр ярих
  152. // @description:ms Cipta pelbagai jawapan daripada ChatGPT yang tahu segala-galanya (dalam apa-apa bahasa!)
  153. // @description:mt Iġġenera risposti infiniti mill-ChatGPT li kollha jaf (f'xi lingwa!)
  154. // @description:my အားလုံးကိုသင်ရိုးရိုးဆွဲနိုင်သည့် ChatGPT (တစ်ခုမှာယူသုံးရန်!)
  155. // @description:ne सबै-ज्ञानी ChatGPT बाट अनंत उत्तरहरू उत्पन्न गर्नुहोस् (कुनै पनि भाषामा!)
  156. // @description:nl Genereer eindeloze antwoorden van alwetende ChatGPT (in elke taal!)
  157. // @description:no Generer endeløse svar fra allvitende ChatGPT (på hvilket som helst språk!)
  158. // @description:ny Galimoto mabwino a mtendere zosiyanasiyana kuchokera ku ChatGPT woyankhula zonse! (muyankhulitsa chilichonse!)
  159. // @description:pa ਸਭ ਜਾਣ ਵਾਲੇ ChatGPT ਤੋਂ ਲੰਬੇ ਉੱਤਰਾਂ ਨੂੰ ਬਣਾਓ (ਕਿਸੇ ਵੀ ਭਾਸ਼ਾ ਵਿੱਚ!)
  160. // @description:pap Hasi respuesta sinfin di ChatGPT ku tur sabi (na kua idioma!)
  161. // @description:pl Generuj nieskończone odpowiedzi od wszechwiedzącego ChatGPT (w dowolnym języku!)
  162. // @description:ps د هغوی چټکال ChatGPT لخوا نهایت جوابونه جوړه کړئ (د هر یوه ژبه کی!)
  163. // @description:pt Gere respostas infinitas do ChatGPT onisciente (em qualquer idioma!)
  164. // @description:pt-BR Gere respostas infinitas do ChatGPT onisciente (em qualquer idioma!)
  165. // @description:rn Basha inzira nk'itandukanye z'uko ChatGPT uzi (mu rurimi rwose!)
  166. // @description:ro Generează răspunsuri infinite de la ChatGPT omniscient (în orice limbă!)
  167. // @description:ru Генерируйте бесконечные ответы от всезнающего ChatGPT (на любом языке!)
  168. // @description:rw Banda inama z'imirimo isigaye zose z'umuco wa ChatGPT (mu rurimi rwose!)
  169. // @description:sg Tia ngamana nga mbetela ti ChatGPT tozuwa mitayi mingi (po wundi ndimi yo ngambo!)
  170. // @description:si සියළු දැනටමත් සහතිකපත්කරන තවත් සිතියම් සැකසුම් ලබා දෙන්නාවූ ChatGPT සෑදීම (ඕනෑම භාෂාවෙන්ම!)
  171. // @description:sk Generujte nekonečné odpovede od vševietajúceho ChatGPT (v akomkoľvek jazyku!)
  172. // @description:sl Generirajte neskončne odgovore iz vsevednega ChatGPT (v katerem koli jeziku!)
  173. // @description:sm Faia se faiga tele i le ChatGPT eseese (i nisi gagana!)
  174. // @description:sn Simudza mhinduro dzakawanda kubva kune ChatGPT ichiwanikwa chisarudzo! (mune rimwe nguva!)
  175. // @description:so Kor u qaado jawaabo kala duwan oo ka soo saar ChatGPT (luuqad ka mid ah!)
  176. // @description:sr Генеришите безброј одговора од свемоћног ChatGPT (на било ком језику!)
  177. // @description:sv Generera oändliga svar från allvetande ChatGPT (på valfritt språk!)
  178. // @description:sw Toa majibu yasiyokuwa na mwisho kutoka kwa ChatGPT mwenye maarifa yote (katika lugha yoyote!)
  179. // @description:ta அனைத்து தகவலையும் அறியப்பட்ட சொந்தமான ChatGPT இலிருந்து முடிவுகளை உருவாக்கவும் (எந்த மொழியிலும்!)
  180. // @description:te అన్నింటినీకింట మాటలు రాయండి ChatGPT గురించి అనేక జవాబాలను సృష్టించండి (ఏదైనా భాషలో!)
  181. // @description:tg Ҷавобҳои бесуданни ChatGPTи ҳамаифақат (дар як забони муайяни!)
  182. // @description:th สร้างคำตอบไม่สิ้นสุดจาก ChatGPT ที่รู้ทุกสิ่ง (ในภาษาใดก็ได้!)
  183. // @description:ti ክርስትን ለማውጣት ከገጽታውን ChatGPT የተከሳሽ አስተካክል አስተካክሎት (በእውነት ቋንቋ!)
  184. // @description:tk Şeýle anlaşylýan ChatGPT (her hili üçin) arasyndan bäşmüňhat jawaplar döret
  185. // @description:tn Hlela zitsha zwine zwiṱhiselela kha ChatGPT vhufudziṱe (muvhili wo vha u ite!)
  186. // @description:to Fakatonutonu ʻihe ngāuekesi mei he ChatGPT fakaongoongo toenga (i he lea faka-Tonga ia!)
  187. // @description:tpi Sanapim hamamasples long save olsem ChatGPT i masples (long wanpela tok ples!)
  188. // @description:tr Bilge ChatGPT'den sonsuz cevaplar üret (herhangi bir dilde!)
  189. // @description:uk Генеруйте безкінечні відповіді від усезнаючого ChatGPT (на будь-якій мові!)
  190. // @description:ur سب جاننے والے ChatGPT سے لامتناہی جوابات پیدا کریں (کسی بھی زبان میں!)
  191. // @description:uz Barcha biladigan ChatGPT dan cheklovli javoblar oling (hech qanday tilda ham)!
  192. // @description:vi Tạo ra vô số câu trả lời từ ChatGPT thông minh (bằng bất kỳ ngôn ngữ nào!)
  193. // @description:xh Bhala izinto ezingekwaziyo eziyimfihlo kusuka ku ChatGPT (ngolwimi lwanyanetha!)
  194. // @description:yi דזשענערייט סאָף ענטפֿערס פֿון אַלע-געוויסן ChatGPT (אין קיין שפּראַך!)
  195. // @description:zh 只添加了免梯镜像网站(login-gpt.com & webchat-ai.com)的支持,未做其他改动
  196. // @description:zh-CN 只添加了免梯镜像网站(login-gpt.com & webchat-ai.com)的支持,未做其他改动
  197. // @description:zh-HK 只添加了免梯镜像网站(login-gpt.com & webchat-ai.com)的支持,未做其他改动
  198. // @description:zh-SG 只添加了免梯镜像网站(login-gpt.com & webchat-ai.com)的支持,未做其他改动
  199. // @description:zh-TW 只添加了免梯镜像网站(login-gpt.com & webchat-ai.com)的支持,未做其他改动
  200. // @author Adam Lui
  201. // @namespace https://github.com/adamlui
  202. // @version 2024.8.29.1
  203. // @license MIT
  204. // @match *://chatgpt.com/*
  205. // @match *://chat.openai.com/*
  206. // @match *://login-gpt.com/*
  207. // @match *://www.login-gpt.com/*
  208. // @match *://webchat-ai.com/*
  209. // @match *://www.webchat-ai.com/*
  210. // @icon https://media.chatgptinfinity.com/images/icons/infinity-symbol/black/icon48.png?fa77d27
  211. // @icon64 https://media.chatgptinfinity.com/images/icons/infinity-symbol/black/icon64.png?fa77d27
  212. // @compatible chrome
  213. // @compatible firefox
  214. // @compatible edge
  215. // @compatible opera
  216. // @compatible brave
  217. // @compatible vivaldi
  218. // @compatible waterfox
  219. // @compatible librewolf
  220. // @compatible ghost
  221. // @compatible qq
  222. // @compatible whale
  223. // @compatible kiwi
  224. // @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.2.0/dist/chatgpt.min.js#sha256-GYFysy53+YoEcZjRVc9GQtL4VlmCpPpgXwjVgVm9rMk=
  225. // @connect cdn.jsdelivr.net
  226. // @connect greatest.deepsurf.us
  227. // @grant GM_setValue
  228. // @grant GM_getValue
  229. // @grant GM_registerMenuCommand
  230. // @grant GM_unregisterMenuCommand
  231. // @grant GM_xmlhttpRequest
  232. // @grant GM.xmlHttpRequest
  233. // @noframes
  234. // @homepageURL https://www.chatgptinfinity.com
  235. // @supportURL https://support.chatgptinfinity.com
  236. // @contributionURL https://github.com/sponsors/adamlui
  237. // ==/UserScript==
  238. // Documentation: https://docs.chatgptinfinity.com
  239. // NOTE: This script relies on the powerful chatgpt.js library @ https://chatgpt.js.org © 2023–2024 KudoAI & contributors under the MIT license.
  240. (async () => {
  241. // Init CONFIG
  242. const config = {
  243. appName: 'ChatGPT Infinity', appSymbol: '∞', keyPrefix: 'chatGPTinfinity',
  244. gitHubURL: 'https://github.com/adamlui/chatgpt-infinity',
  245. greasyForkURL: 'https://greatest.deepsurf.us/scripts/465051-chatgpt-infinity',
  246. mediaHostURL: 'https://media.chatgptinfinity.com/',
  247. latestAssetCommitHash: '7bbe0b5' } // for cached messages.json + navicon
  248. config.updateURL = config.greasyForkURL.replace('https://', 'https://update.')
  249. .replace(/(\d+)-?([a-zA-Z-]*)$/, (_, id, name) => `${ id }/${ !name ? 'script' : name }.meta.js`)
  250. config.supportURL = 'https://support.chatgptinfinity.com'
  251. config.assetHostURL = config.gitHubURL.replace('github.com', 'cdn.jsdelivr.net/gh') + `@${config.latestAssetCommitHash}/`
  252. config.userLanguage = chatgpt.getUserLanguage()
  253. loadSetting('autoScrollDisabled', 'autoStart', 'replyInterval', 'replyLanguage', 'replyTopic', 'toggleHidden')
  254. if (!config.replyLanguage) saveSetting('replyLanguage', config.userLanguage) // init reply language if unset
  255. if (!config.replyTopic) saveSetting('replyTopic', 'ALL') // init reply topic if unset
  256. if (!config.replyInterval) saveSetting('replyInterval', 7) // init refresh interval to 7 secs if unset
  257. // Init FETCHER
  258. const xhr = getUserscriptManager() == 'OrangeMonkey' ? GM_xmlhttpRequest : GM.xmlHttpRequest
  259. // Init MESSAGES
  260. let msgs = {}
  261. if (!config.userLanguage.startsWith('en')) msgs = await new Promise(resolve => {
  262. const msgHostDir = config.assetHostURL + 'greasemonkey/_locales/',
  263. msgLocaleDir = ( config.userLanguage ? config.userLanguage.replace('-', '_') : 'en' ) + '/'
  264. let msgHref = msgHostDir + msgLocaleDir + 'messages.json', msgXHRtries = 0
  265. xhr({ method: 'GET', url: msgHref, onload: onLoad })
  266. function onLoad(resp) {
  267. try { // to return localized messages.json
  268. const msgs = JSON.parse(resp.responseText), flatMsgs = {}
  269. for (const key in msgs) // remove need to ref nested keys
  270. if (typeof msgs[key] == 'object' && 'message' in msgs[key])
  271. flatMsgs[key] = msgs[key].message
  272. resolve(flatMsgs)
  273. } catch (err) { // if bad response
  274. msgXHRtries++ ; if (msgXHRtries == 3) return resolve({}) // try up to 3X (original/region-stripped/EN) only
  275. msgHref = config.userLanguage.includes('-') && msgXHRtries == 1 ? // if regional lang on 1st try...
  276. msgHref.replace(/([^_]+_[^_]+)_[^/]*(\/.*)/, '$1$2') // ...strip region before retrying
  277. : ( msgHostDir + 'en/messages.json' ) // else use default English messages
  278. xhr({ method: 'GET', url: msgHref, onload: onLoad })
  279. }
  280. }
  281. })
  282. // Init MENU objs
  283. const menuIDs = [] // to store registered cmds for removal while preserving order
  284. const menuState = {
  285. symbol: ['❌', '✔️'], word: ['OFF', 'ON'],
  286. separator: getUserscriptManager() == 'Tampermonkey' ? ' — ' : ': '
  287. }
  288. // Create browser TOOLBAR MENU or DISABLE SCRIPT if extension installed
  289. const extensionInstalled = await Promise.race([
  290. new Promise(resolve => {
  291. (function checkExtensionInstalled() {
  292. if (document.querySelector('[cif-extension-installed]')) resolve(true)
  293. else setTimeout(checkExtensionInstalled, 200)
  294. })()
  295. }), new Promise(resolve => setTimeout(() => resolve(false), 1500))])
  296. if (extensionInstalled) { // disable script/menu
  297. GM_registerMenuCommand(menuState.symbol[0] + ' ' + ( msgs.menuLabel_disabled || 'Disabled (extension installed)' ),
  298. () => { return }) // disable menu
  299. return // exit script
  300. } else registerMenu() // create functional menu
  301. // Define SCRIPT functions
  302. function loadSetting(...keys) { keys.forEach(key => { config[key] = GM_getValue(config.keyPrefix + '_' + key, false) })}
  303. function saveSetting(key, value) { GM_setValue(config.keyPrefix + '_' + key, value) ; config[key] = value }
  304. function safeWindowOpen(url) { window.open(url, '_blank', 'noopener') } // to prevent backdoor vulnerabilities
  305. function getUserscriptManager() { try { return GM_info.scriptHandler } catch(err) { return 'other' }}
  306. // Define MENU functions
  307. function registerMenu() {
  308. // Add command to toggle Infinity Mode
  309. const imLabel = menuState.symbol[+config.infinityMode] + ' '
  310. + ( msgs.menuLabel_infinityMode || 'Infinity Mode' ) + ' ∞ '
  311. + menuState.separator + menuState.word[+config.infinityMode]
  312. menuIDs.push(GM_registerMenuCommand(imLabel, () => { document.getElementById('infinity-toggle-label').click() }))
  313. // Add command to toggle Auto-Start
  314. const astLabel = menuState.symbol[+config.autoStart] + ' '
  315. + ( msgs.menuLabel_autoStart || 'Auto-Start' )
  316. + menuState.separator + menuState.word[+config.autoStart]
  317. menuIDs.push(GM_registerMenuCommand(astLabel, () => {
  318. saveSetting('autoStart', !config.autoStart)
  319. notify(( msgs.menuLabel_autoStart || 'Auto-Start' ) + ': '+ menuState.word[+config.autoStart])
  320. refreshMenu()
  321. }))
  322. // Add command to toggle visibility of toggle
  323. const tvLabel = menuState.symbol[+!config.toggleHidden] + ' '
  324. + ( msgs.menuLabel_toggleVis || 'Toggle Visibility' )
  325. + menuState.separator + menuState.word[+!config.toggleHidden]
  326. menuIDs.push(GM_registerMenuCommand(tvLabel, () => {
  327. saveSetting('toggleHidden', !config.toggleHidden)
  328. navToggleDiv.style.display = config.toggleHidden ? 'none' : 'flex' // toggle visibility
  329. notify(( msgs.menuLabel_toggleVis || 'Toggle Visibility' ) + ': '+ menuState.word[+!config.toggleHidden])
  330. refreshMenu()
  331. }))
  332. // Add command to toggle Auto-Scroll
  333. const ascLabel = menuState.symbol[+!config.autoScrollDisabled] + ' '
  334. + ( msgs.menuLabel_autoScroll || 'Auto-Scroll' )
  335. + menuState.separator + menuState.word[+!config.autoScrollDisabled]
  336. menuIDs.push(GM_registerMenuCommand(ascLabel, () => {
  337. saveSetting('autoScrollDisabled', !config.autoScrollDisabled)
  338. notify(( msgs.menuLabel_autoScroll || 'Auto-Scroll' ) + ': '+ menuState.word[+!config.autoScrollDisabled])
  339. refreshMenu()
  340. }))
  341. // Add command to set reply language
  342. const rlLabel = '🌐 ' + ( msgs.menuLabel_replyLang || 'Reply Language' )
  343. + menuState.separator + config.replyLanguage
  344. menuIDs.push(GM_registerMenuCommand(rlLabel, () => {
  345. while (true) {
  346. let replyLanguage = prompt(
  347. `${ msgs.prompt_updateReplyLang || 'Update reply language' }:`, config.replyLanguage)
  348. if (replyLanguage === null) break // user cancelled so do nothing
  349. else if (!/\d/.test(replyLanguage)) {
  350. replyLanguage = ( // auto-case for menu/alert aesthetics
  351. [2, 3].includes(replyLanguage.length) || replyLanguage.includes('-') ? replyLanguage.toUpperCase()
  352. : replyLanguage.charAt(0).toUpperCase() + replyLanguage.slice(1).toLowerCase() )
  353. saveSetting('replyLanguage', replyLanguage || config.userLanguage)
  354. siteAlert(( msgs.alert_replyLangUpdated || 'Language updated' ) + '!', // title
  355. ( msgs.appName || config.appName ) + ' ' // msg
  356. + ( msgs.alert_willReplyIn || 'will reply in' ) + ' '
  357. + ( replyLanguage || msgs.alert_yourSysLang || 'your system language') + '.')
  358. if (config.infinityMode) restartInNewChat() // using new reply language
  359. refreshMenu() ; break
  360. }}}))
  361. // Add command to set reply topic
  362. const re_all = new RegExp('^(' + ( msgs.menuLabel_all || 'all' ) + '|all|any|every)$', 'i'),
  363. rtLabel = '🧠 ' + ( msgs.menuLabel_replyTopic || 'Reply Topic' ) + menuState.separator
  364. + ( re_all.test(config.replyTopic) ? ( msgs.menuLabel_all || 'all' )
  365. : toTitleCase(config.replyTopic) )
  366. menuIDs.push(GM_registerMenuCommand(rtLabel, () => {
  367. const replyTopic = prompt(( msgs.prompt_updateReplyTopic || 'Update reply topic' )
  368. + ' (' + ( msgs.prompt_orEnter || 'or enter' ) + ' \'ALL\'):', config.replyTopic)
  369. if (replyTopic !== null) { // user didn't cancel
  370. const str_replyTopic = replyTopic.toString()
  371. saveSetting('replyTopic', !replyTopic || re_all.test(str_replyTopic) ? 'ALL' : str_replyTopic)
  372. siteAlert(( msgs.alert_replyTopicUpdated || 'Topic updated' ) + '!',
  373. ( msgs.appName || config.appName ) + ' '
  374. + ( msgs.alert_willAnswer || 'will answer questions' ) + ' '
  375. + ( !replyTopic || re_all.test(str_replyTopic)
  376. ? msgs.alert_onAllTopics || 'on ALL topics'
  377. : (( msgs.alert_onTopicOf || 'on the topic of' ) + ' ' + str_replyTopic ))
  378. + '!'
  379. )
  380. if (config.infinityMode) { // restart session using new reply topic
  381. chatgpt.stop() ; document.getElementById('infinity-toggle-label').click() // toggle off
  382. setTimeout(() => { document.getElementById('infinity-toggle-label').click() }, 500) } // toggle on
  383. refreshMenu()
  384. }}))
  385. // Add command to change reply interval
  386. const riLabel = '⌚ ' + ( msgs.menuLabel_replyInt || 'Reply Interval' )
  387. + menuState.separator + config.replyInterval + 's'
  388. menuIDs.push(GM_registerMenuCommand(riLabel, async () => {
  389. while (true) {
  390. const replyInterval = prompt(
  391. `${ msgs.prompt_updateReplyInt || 'Update reply interval (minimum 5 secs)' }:`, config.replyInterval)
  392. if (replyInterval === null) break // user cancelled so do nothing
  393. else if (!isNaN(parseInt(replyInterval, 10)) && parseInt(replyInterval, 10) > 4) { // valid int set
  394. saveSetting('replyInterval', parseInt(replyInterval, 10))
  395. siteAlert(( msgs.alert_replyIntUpdated || 'Interval updated' ) + '!', // title
  396. ( msgs.appName || config.appName ) + ' ' // msg
  397. + ( msgs.alert_willReplyEvery || 'will reply every' ) + ' '
  398. + replyInterval + ' ' + ( msgs.unit_seconds || 'seconds' ) + '.')
  399. if (config.infinityMode) resetInSameChat() // using new reply interval
  400. refreshMenu() ; break
  401. }}}))
  402. // Add command to launch About modal
  403. const aboutLabel = `💡 ${ msgs.menuLabel_about || 'About' } ${ msgs.appName || config.appName }`
  404. menuIDs.push(GM_registerMenuCommand(aboutLabel, launchAboutModal))
  405. }
  406. function refreshMenu() {
  407. if (getUserscriptManager() == 'OrangeMonkey') return
  408. for (const id of menuIDs) { GM_unregisterMenuCommand(id) } registerMenu()
  409. }
  410. function launchAboutModal() {
  411. // Show alert
  412. const chatgptJSver = (/chatgpt-([\d.]+)\.min/.exec(GM_info.script.header) || [null, ''])[1],
  413. headingStyle = 'font-size: 1.15rem',
  414. pStyle = 'position: relative ; left: 3px',
  415. pBrStyle = 'position: relative ; left: 4px ',
  416. aStyle = 'color: ' + ( chatgpt.isDarkMode() ? '#c67afb' : '#8325c4' ) // purple
  417. const aboutModalID = siteAlert(
  418. msgs.appName || config.appName, // title
  419. `<span style="${ headingStyle }"><b>🏷️ <i>${ msgs.about_version || 'Version' }</i></b>: </span>`
  420. + `<span style="${ pStyle }">${ GM_info.script.version }</span>\n`
  421. + `<span style="${ headingStyle }"><b>⚡ <i>${ msgs.about_poweredBy || 'Powered by' }</i></b>: </span>`
  422. + `<span style="${ pStyle }"><a style="${ aStyle }" href="https://chatgpt.js.org" target="_blank" rel="noopener">`
  423. + 'chatgpt.js</a>' + ( chatgptJSver ? ( ' v' + chatgptJSver ) : '' ) + '</span>\n'
  424. + `<span style="${ headingStyle }"><b>📜 <i>${ msgs.about_sourceCode || 'Source code' }</i></b>:</span>\n`
  425. + `<span style="${ pBrStyle }"><a href="${ config.gitHubURL }" target="_blank" rel="nopener">`
  426. + config.gitHubURL + '</a></span>',
  427. [ // buttons
  428. function checkForUpdates() { updateCheck() },
  429. function getSupport() { safeWindowOpen(config.supportURL) },
  430. function leaveAReview() { // show new modal
  431. const reviewModalID = chatgpt.alert(( msgs.alert_choosePlatform || 'Choose a Platform' ) + ':', '',
  432. [ function greasyFork() { safeWindowOpen(config.greasyForkURL + '/feedback#post-discussion') },
  433. function productHunt() { safeWindowOpen(
  434. 'https://www.producthunt.com/products/chatgpt-infinity/reviews/new') },
  435. function alternativeTo() { safeWindowOpen(
  436. 'https://alternativeto.net/software/chatgpt-infinity/about/') }])
  437. const reviewBtns = document.getElementById(reviewModalID).querySelectorAll('button')
  438. reviewBtns[0].style.display = 'none' // hide dismiss button
  439. reviewBtns[1].textContent = ( // remove spaces from AlternativeTo label
  440. reviewBtns[1].textContent.replace(/\s/g, '')) },
  441. function moreChatGPTapps() { safeWindowOpen('https://github.com/adamlui/chatgpt-apps') }
  442. ], '', 478 // set width
  443. )
  444. // Re-format buttons to include emoji + localized label + hide Dismiss button
  445. for (const button of document.getElementById(aboutModalID).querySelectorAll('button')) {
  446. if (/updates/i.test(button.textContent)) button.textContent = (
  447. '🚀 ' + ( msgs.btnLabel_updateCheck || 'Check for Updates' ))
  448. else if (/support/i.test(button.textContent)) button.textContent = (
  449. '🧠 ' + ( msgs.btnLabel_getSupport || 'Get Support' ))
  450. else if (/review/i.test(button.textContent)) button.textContent = (
  451. '⭐ ' + ( msgs.btnLabel_leaveReview || 'Leave Review' ))
  452. else if (/apps/i.test(button.textContent)) button.textContent = (
  453. '🤖 ' + ( msgs.btnLabel_moreApps || 'More ChatGPT Apps' ))
  454. else button.style.display = 'none' // hide Dismiss button
  455. }
  456. }
  457. function updateCheck() {
  458. // Fetch latest meta
  459. const currentVer = GM_info.script.version
  460. xhr({
  461. method: 'GET', url: config.updateURL + '?t=' + Date.now(),
  462. headers: { 'Cache-Control': 'no-cache' },
  463. onload: response => { const updateAlertWidth = 377
  464. // Compare versions
  465. const latestVer = /@version +(.*)/.exec(response.responseText)[1]
  466. for (let i = 0 ; i < 4 ; i++) { // loop thru subver's
  467. const currentSubVer = parseInt(currentVer.split('.')[i], 10) || 0,
  468. latestSubVer = parseInt(latestVer.split('.')[i], 10) || 0
  469. if (currentSubVer > latestSubVer) break // out of comparison since not outdated
  470. else if (latestSubVer > currentSubVer) { // if outdated
  471. // Alert to update
  472. const updateModalID = siteAlert(`🚀 ${ msgs.alert_updateAvail || 'Update available' }!`, // title
  473. `${ msgs.alert_newerVer || 'An update to' } ${ config.appName } `
  474. + ( msgs.appName || config.appName ) + ' '
  475. + `(v${ latestVer }) ${ msgs.alert_isAvail || 'is available' }! `
  476. + '<a target="_blank" rel="noopener" style="font-size: 0.7rem" '
  477. + 'href="' + config.gitHubURL + '/commits/main/greasemonkey/'
  478. + config.updateURL.replace(/.*\/(.*)meta\.js/, '$1user.js') + '"'
  479. + `> ${ msgs.link_viewChanges || 'View changes' }</a>`,
  480. function update() { // button
  481. safeWindowOpen(config.updateURL.replace('meta.js', 'user.js') + '?t=' + Date.now())
  482. }, '', updateAlertWidth
  483. )
  484. // Localize button labels if needed
  485. if (!config.userLanguage.startsWith('en')) {
  486. const updateAlert = document.querySelector(`[id="${ updateModalID }"]`),
  487. updateBtns = updateAlert.querySelectorAll('button')
  488. updateBtns[1].textContent = msgs.btnLabel_update || 'Update'
  489. updateBtns[0].textContent = msgs.btnLabel_dismiss || 'Dismiss'
  490. }
  491. return
  492. }}
  493. // Alert to no update, return to About modal
  494. siteAlert(( msgs.alert_upToDate || 'Up-to-date' ) + '!', // title
  495. `${ msgs.appName || config.appName } (v${ currentVer }) ` // msg
  496. + ( msgs.alert_isUpToDate || 'is up-to-date' ) + '!',
  497. '', '', updateAlertWidth
  498. )
  499. launchAboutModal()
  500. }})}
  501. function toTitleCase(str) {
  502. const words = str.toLowerCase().split(' ')
  503. for (let i = 0 ; i < words.length ; i++) // for each word
  504. words[i] = words[i][0].toUpperCase() + words[i].slice(1) // title-case it
  505. return words.join(' ') // join'em back together
  506. }
  507. // Define FEEDBACK functions
  508. function notify(msg, position = '', notifDuration = '', shadow = '') {
  509. // Strip state word to append colored one later
  510. const foundState = menuState.word.find(word => msg.includes(word))
  511. if (foundState) msg = msg.replace(foundState, '')
  512. // Show notification
  513. chatgpt.notify(`${ config.appSymbol } ${ msg }`, position, notifDuration, shadow || chatgpt.isDarkMode() ? '' : 'shadow')
  514. const notifs = document.querySelectorAll('.chatgpt-notif'),
  515. notif = notifs[notifs.length -1]
  516. // Append styled state word
  517. if (foundState) {
  518. const styledState = document.createElement('span')
  519. styledState.style.cssText = `color: ${
  520. foundState == menuState.word[0] ? '#ef4848 ; text-shadow: rgba(255, 169, 225, 0.44) 2px 1px 5px'
  521. : '#5cef48 ; text-shadow: rgba(255, 250, 169, 0.38) 2px 1px 5px' }`
  522. styledState.append(foundState) ; notif.append(styledState)
  523. }
  524. }
  525. function siteAlert(title = '', msg = '', btns = '', checkbox = '', width = '') {
  526. return chatgpt.alert(title, msg, btns, checkbox, width )}
  527. // Define UI functions
  528. async function insertToggle() {
  529. // Insert toggle
  530. const toggleParent = document.querySelector('nav')
  531. if (!toggleParent.contains(navToggleDiv))
  532. toggleParent.insertBefore(navToggleDiv, toggleParent.children[1])
  533. // Tweak styles
  534. navToggleDiv.style.flexGrow = 'unset' // overcome OpenAI .grow
  535. navToggleDiv.style.paddingLeft = '8px'
  536. document.getElementById('infinity-toggle-knob-span').style.boxShadow = (
  537. 'rgba(0, 0, 0, .3) 0 1px 2px 0' + ( chatgpt.isDarkMode() ? ', rgba(0, 0, 0, .15) 0 3px 6px 2px' : '' ))
  538. const navicon = document.getElementById('infinity-toggle-navicon')
  539. if (navicon) navicon.src = `${ // update navicon color in case scheme changed
  540. config.mediaHostURL}images/icons/infinity-symbol/`
  541. + `${ chatgpt.isDarkMode() ? 'white' : 'black' }/icon32.png?${config.latestAssetCommitHash}`
  542. }
  543. function updateToggleHTML() {
  544. // Create/size/position navicon
  545. const navicon = document.getElementById('infinity-toggle-navicon') || document.createElement('img')
  546. navicon.id = 'infinity-toggle-navicon'
  547. navicon.style.width = navicon.style.height = '1.25rem'
  548. navicon.style.marginLeft = '2px' ; navicon.style.marginRight = '4px'
  549. // Create/ID/disable/hide/update checkbox
  550. const toggleInput = document.getElementById('infinity-toggle-input') || document.createElement('input')
  551. toggleInput.id = 'infinity-toggle-input' ; toggleInput.type = 'checkbox' ; toggleInput.disabled = true
  552. toggleInput.style.display = 'none' ; toggleInput.checked = config.infinityMode
  553. // Create/ID/stylize switch
  554. const switchSpan = document.getElementById('infinity-switch-span') || document.createElement('span')
  555. switchSpan.id = 'infinity-switch-span'
  556. const switchStyles = {
  557. position: 'relative', left: `${ chatgpt.browser.isMobile() ? 211 : !firstLink ? 160 : isGPT4oUI ? 147 : 154 }px`,
  558. backgroundColor: toggleInput.checked ? '#ccc' : '#AD68FF', // init opposite final color
  559. bottom: `${ !firstLink ? -0.15 : isFirefox || !isGPT4oUI ? 0.05 : 0 }em`,
  560. width: '30px', height: '15px', '-webkit-transition': '.4s', transition: '0.4s', borderRadius: '28px'
  561. }
  562. Object.assign(switchSpan.style, switchStyles)
  563. // Create/stylize knob, append to switch
  564. const knobSpan = document.getElementById('infinity-toggle-knob-span') || document.createElement('span')
  565. knobSpan.id = 'infinity-toggle-knob-span'
  566. const knobWidth = 12
  567. const knobStyles = {
  568. position: 'absolute', left: '3px', bottom: '1.25px',
  569. width: `${knobWidth}px`, height: `${knobWidth}px`, content: '""', borderRadius: '28px',
  570. transform: toggleInput.checked ? // init opposite final pos
  571. 'translateX(0)' : 'translateX(13px) translateY(0)',
  572. backgroundColor: 'white', '-webkit-transition': '0.4s', transition: '0.4s'
  573. }
  574. Object.assign(knobSpan.style, knobStyles) ; switchSpan.append(knobSpan)
  575. // Create/stylize/fill label
  576. const toggleLabel = document.getElementById('infinity-toggle-label') || document.createElement('label')
  577. toggleLabel.id = 'infinity-toggle-label'
  578. if (!firstLink) { // add font size/weight since no firstLink to borrow from
  579. toggleLabel.style.fontSize = '0.875rem' ; toggleLabel.style.fontWeight = 600 }
  580. toggleLabel.style.marginLeft = `-${ !firstLink ? 23 : 41 }px` // left-shift to navicon
  581. toggleLabel.style.cursor = 'pointer' // add finger cursor on hover
  582. toggleLabel.style.width = `${ chatgpt.browser.isMobile() ? 201 : isGPT4oUI ? 145 : 148 }px` // to truncate overflown text
  583. toggleLabel.style.overflow = 'hidden' // to truncate overflown text
  584. toggleLabel.style.textOverflow = 'ellipsis' // to truncate overflown text
  585. toggleLabel.innerText = ( msgs.menuLabel_infinityMode || 'Infinity Mode' ) + ' '
  586. + ( toggleInput.checked ? ( msgs.state_enabled || 'enabled' )
  587. : ( msgs.state_disabled || 'disabled' ))
  588. // Append elements
  589. for (const elem of [navicon, toggleInput, switchSpan, toggleLabel]) navToggleDiv.append(elem)
  590. // Update visual state
  591. navToggleDiv.style.display = config.toggleHidden ? 'none' : 'flex'
  592. setTimeout(() => {
  593. switchSpan.style.backgroundColor = toggleInput.checked ? '#ad68ff' : '#ccc'
  594. switchSpan.style.boxShadow = toggleInput.checked ? '2px 1px 9px #d8a9ff' : 'none'
  595. knobSpan.style.transform = toggleInput.checked ? 'translateX(13px) translateY(0)' : 'translateX(0)'
  596. }, 1) // min delay to trigger transition fx
  597. }
  598. const infinityMode = {
  599. async activate() {
  600. notify(( msgs.menuLabel_infinityMode || 'Infinity Mode' ) + ': ON')
  601. if (chatgpt.browser.isMobile() && chatgpt.sidebar.isOn()) chatgpt.sidebar.hide()
  602. if (!new URL(document.location).pathname.startsWith('/g/')) // not on GPT page
  603. try { chatgpt.startNewChat() } catch (err) { return } // start new chat
  604. setTimeout(() => {
  605. chatgpt.send('Generate a single random question'
  606. + ( config.replyLanguage ? ( ' in ' + config.replyLanguage ) : '' )
  607. + ( ' on ' + ( config.replyTopic == 'ALL' ? 'ALL topics' : 'the topic of ' + config.replyTopic ))
  608. + ' then answer it. Don\'t type anything else.')
  609. }, 500)
  610. await chatgpt.isIdle()
  611. if (config.infinityMode && !infinityMode.isActive) // double-check in case de-activated before scheduled
  612. infinityMode.isActive = setTimeout(infinityMode.continue, parseInt(config.replyInterval, 10) * 1000)
  613. },
  614. async continue() {
  615. if (!config.autoScrollDisabled) try { chatgpt.scrollToBottom() } catch(err) {}
  616. await chatgpt.isIdle() // before starting delay till next iteration
  617. chatgpt.send('Do it again.')
  618. if (infinityMode.isActive) // replace timer
  619. infinityMode.isActive = setTimeout(infinityMode.continue, parseInt(config.replyInterval, 10) * 1000)
  620. },
  621. deactivate() {
  622. chatgpt.stop() ; clearTimeout(infinityMode.isActive) ; infinityMode.isActive = null
  623. document.getElementById('infinity-toggle-input').checked = false // for window listener
  624. notify(( msgs.menuLabel_infinityMode || 'Infinity Mode' ) + ': OFF')
  625. config.infinityMode = false // in case toggled by PV listener
  626. },
  627. toggle() { config.infinityMode ? infinityMode.activate() : infinityMode.deactivate() }
  628. }
  629. // Define INTERRUPT functions
  630. function restartInNewChat() {
  631. chatgpt.stop() ; document.getElementById('infinity-toggle-label').click() // toggle off
  632. setTimeout(() => { document.getElementById('infinity-toggle-label').click() }, 500) // toggle on
  633. }
  634. async function resetInSameChat() {
  635. clearTimeout(infinityMode.isActive) ; infinityMode.isActive = null ; await chatgpt.isIdle()
  636. if (config.infinityMode && !infinityMode.isActive) // double-check in case de-activated before scheduled
  637. infinityMode.isActive = setTimeout(infinityMode.continue, parseInt(config.replyInterval, 10) * 1000)
  638. }
  639. // Run MAIN routine
  640. // Init UI flags
  641. await Promise.race([chatgpt.isLoaded(), new Promise(resolve => setTimeout(resolve, 5000))]) // initial UI loaded
  642. await chatgpt.sidebar.isLoaded()
  643. const isFirefox = chatgpt.browser.isFirefox(),
  644. isGPT4oUI = document.documentElement.className.includes(' '),
  645. firstLink = chatgpt.getNewChatLink()
  646. // Add listener to auto-disable Infinity Mode
  647. if (document.hidden !== undefined) // ...if Page Visibility API supported
  648. document.onvisibilitychange = () => {
  649. if (config.infinityMode) {
  650. if (document.getElementById('infinity-toggle-label')) // ensure toggle state is accurate
  651. document.getElementById('infinity-toggle-label').click()
  652. else infinityMode.deactivate()
  653. refreshMenu()
  654. }}
  655. // Add/update TWEAKS style
  656. const tweaksStyleUpdated = 20240724 // datestamp of last edit for this file's `tweaksStyle`
  657. let tweaksStyle = document.getElementById('tweaks-style') // try to select existing style
  658. if (!tweaksStyle || parseInt(tweaksStyle.getAttribute('last-updated'), 10) < tweaksStyleUpdated) { // if missing or outdated
  659. if (!tweaksStyle) { // outright missing, create/id/attr/append it first
  660. tweaksStyle = document.createElement('style') ; tweaksStyle.id = 'tweaks-style'
  661. tweaksStyle.setAttribute('last-updated', tweaksStyleUpdated.toString())
  662. document.head.append(tweaksStyle)
  663. }
  664. tweaksStyle.innerText = (
  665. ( chatgpt.isDarkMode() ? '.chatgpt-modal > div { border: 1px solid white }' : '' )
  666. + '.chatgpt-modal button {'
  667. + 'font-size: 0.77rem ; text-transform: uppercase ;'
  668. + 'border-radius: 0 !important ; padding: 5px !important ; min-width: 102px }'
  669. + '.chatgpt-modal button:hover { transform: scale(1.055) }'
  670. + '.modal-buttons { margin-left: -13px !important }'
  671. + '* { scrollbar-width: thin }' // make FF scrollbar skinny to not crop toggle
  672. + '.sticky div:active, .sticky div:focus {' // post-GPT-4o UI sidebar button container
  673. + 'transform: none !important }' // disable distracting click zoom effect
  674. )
  675. }
  676. // Create NAV TOGGLE div, add styles
  677. const navToggleDiv = document.createElement('div')
  678. navToggleDiv.style.height = '37px'
  679. navToggleDiv.style.margin = '2px 0' // add v-margins
  680. navToggleDiv.style.userSelect = 'none' // prevent highlighting
  681. navToggleDiv.style.cursor = 'pointer' // add finger cursor
  682. updateToggleHTML() // create children
  683. if (firstLink) { // borrow/assign CLASSES from sidebar div
  684. const firstIcon = firstLink.querySelector('div:first-child'),
  685. firstLabel = firstLink.querySelector('div:nth-child(2)')
  686. navToggleDiv.classList.add(...firstLink.classList, ...firstLabel.classList)
  687. navToggleDiv.querySelector('img')?.classList.add(...firstIcon.classList)
  688. }
  689. insertToggle()
  690. // Add LISTENER to toggle switch/label/config/menu
  691. navToggleDiv.onclick = () => {
  692. const toggleInput = document.getElementById('infinity-toggle-input')
  693. toggleInput.checked = !toggleInput.checked
  694. config.infinityMode = toggleInput.checked
  695. updateToggleHTML() ; refreshMenu()
  696. infinityMode.toggle()
  697. }
  698. // Auto-start if enabled
  699. if (config.autoStart) {
  700. const navToggle = document.getElementById('infinity-toggle-input')
  701. if (navToggle) navToggle.parentNode.click()
  702. else { // activate via infinityMode
  703. infinityMode.activate() ; config.infinityMode = true ; refreshMenu()
  704. }}
  705. // Monitor <html> to maintain SIDEBAR TOGGLE VISIBILITY on node changes
  706. const nodeObserver = new MutationObserver(mutations => { mutations.forEach(mutation => {
  707. if (mutation.type == 'childList' && mutation.addedNodes.length) insertToggle() })})
  708. nodeObserver.observe(document.documentElement, { childList: true, subtree: true })
  709. })()