@kudoai/chatgpt.js 2.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/LICENSE +21 -0
  2. package/chatgpt.js +2060 -0
  3. package/dist/chatgpt-2.6.3.min.js +1 -0
  4. package/docs/.nojekyll +0 -0
  5. package/docs/CNAME +1 -0
  6. package/docs/README.md +324 -0
  7. package/docs/SECURITY.md +25 -0
  8. package/docs/USERGUIDE.md +1814 -0
  9. package/docs/_coverpage.md +16 -0
  10. package/docs/_utils/LICENSE.md +21 -0
  11. package/docs/_utils/minify.js +50 -0
  12. package/docs/assets/docsify/cursors/futuristic/pointer.cur +0 -0
  13. package/docs/assets/docsify/favicons/favicon16.png +0 -0
  14. package/docs/assets/docsify/favicons/favicon320.png +0 -0
  15. package/docs/assets/docsify/favicons/favicon48.png +0 -0
  16. package/docs/assets/docsify/favicons/favicon64.png +0 -0
  17. package/docs/assets/docsify/fonts/eurostile-extended-black/EurostileExtendedBlack.otf +0 -0
  18. package/docs/assets/docsify/fonts/eurostile-extended-black/EurostileExtendedBlack.ttf +0 -0
  19. package/docs/assets/docsify/fonts/eurostile-extended-black/EurostileExtendedBlack.woff +0 -0
  20. package/docs/assets/docsify/fonts/eurostile-extended-black/EurostileExtendedBlack.woff2 +0 -0
  21. package/docs/assets/docsify/fonts/ibm-plex-mono/OFL.txt +93 -0
  22. package/docs/assets/docsify/fonts/ibm-plex-mono/otf/IBMPlexMono-Bold.otf +0 -0
  23. package/docs/assets/docsify/fonts/ibm-plex-mono/otf/IBMPlexMono-BoldItalic.otf +0 -0
  24. package/docs/assets/docsify/fonts/ibm-plex-mono/otf/IBMPlexMono-ExtraLight.otf +0 -0
  25. package/docs/assets/docsify/fonts/ibm-plex-mono/otf/IBMPlexMono-ExtraLightItalic.otf +0 -0
  26. package/docs/assets/docsify/fonts/ibm-plex-mono/otf/IBMPlexMono-Italic.otf +0 -0
  27. package/docs/assets/docsify/fonts/ibm-plex-mono/otf/IBMPlexMono-Light.otf +0 -0
  28. package/docs/assets/docsify/fonts/ibm-plex-mono/otf/IBMPlexMono-LightItalic.otf +0 -0
  29. package/docs/assets/docsify/fonts/ibm-plex-mono/otf/IBMPlexMono-Medium.otf +0 -0
  30. package/docs/assets/docsify/fonts/ibm-plex-mono/otf/IBMPlexMono-MediumItalic.otf +0 -0
  31. package/docs/assets/docsify/fonts/ibm-plex-mono/otf/IBMPlexMono-Regular.otf +0 -0
  32. package/docs/assets/docsify/fonts/ibm-plex-mono/otf/IBMPlexMono-SemiBold.otf +0 -0
  33. package/docs/assets/docsify/fonts/ibm-plex-mono/otf/IBMPlexMono-SemiBoldItalic.otf +0 -0
  34. package/docs/assets/docsify/fonts/ibm-plex-mono/otf/IBMPlexMono-Thin.otf +0 -0
  35. package/docs/assets/docsify/fonts/ibm-plex-mono/otf/IBMPlexMono-ThinItalic.otf +0 -0
  36. package/docs/assets/docsify/fonts/ibm-plex-mono/ttf/IBMPlexMono-Bold.ttf +0 -0
  37. package/docs/assets/docsify/fonts/ibm-plex-mono/ttf/IBMPlexMono-BoldItalic.ttf +0 -0
  38. package/docs/assets/docsify/fonts/ibm-plex-mono/ttf/IBMPlexMono-ExtraLight.ttf +0 -0
  39. package/docs/assets/docsify/fonts/ibm-plex-mono/ttf/IBMPlexMono-ExtraLightItalic.ttf +0 -0
  40. package/docs/assets/docsify/fonts/ibm-plex-mono/ttf/IBMPlexMono-Italic.ttf +0 -0
  41. package/docs/assets/docsify/fonts/ibm-plex-mono/ttf/IBMPlexMono-Light.ttf +0 -0
  42. package/docs/assets/docsify/fonts/ibm-plex-mono/ttf/IBMPlexMono-LightItalic.ttf +0 -0
  43. package/docs/assets/docsify/fonts/ibm-plex-mono/ttf/IBMPlexMono-Medium.ttf +0 -0
  44. package/docs/assets/docsify/fonts/ibm-plex-mono/ttf/IBMPlexMono-MediumItalic.ttf +0 -0
  45. package/docs/assets/docsify/fonts/ibm-plex-mono/ttf/IBMPlexMono-Regular.ttf +0 -0
  46. package/docs/assets/docsify/fonts/ibm-plex-mono/ttf/IBMPlexMono-SemiBold.ttf +0 -0
  47. package/docs/assets/docsify/fonts/ibm-plex-mono/ttf/IBMPlexMono-SemiBoldItalic.ttf +0 -0
  48. package/docs/assets/docsify/fonts/ibm-plex-mono/ttf/IBMPlexMono-Thin.ttf +0 -0
  49. package/docs/assets/docsify/fonts/ibm-plex-mono/ttf/IBMPlexMono-ThinItalic.ttf +0 -0
  50. package/docs/assets/docsify/fonts/ibm-plex-mono/woff/IBMPlexMono-Bold.woff +0 -0
  51. package/docs/assets/docsify/fonts/ibm-plex-mono/woff/IBMPlexMono-BoldItalic.woff +0 -0
  52. package/docs/assets/docsify/fonts/ibm-plex-mono/woff/IBMPlexMono-ExtraLight.woff +0 -0
  53. package/docs/assets/docsify/fonts/ibm-plex-mono/woff/IBMPlexMono-ExtraLightItalic.woff +0 -0
  54. package/docs/assets/docsify/fonts/ibm-plex-mono/woff/IBMPlexMono-Italic.woff +0 -0
  55. package/docs/assets/docsify/fonts/ibm-plex-mono/woff/IBMPlexMono-Light.woff +0 -0
  56. package/docs/assets/docsify/fonts/ibm-plex-mono/woff/IBMPlexMono-LightItalic.woff +0 -0
  57. package/docs/assets/docsify/fonts/ibm-plex-mono/woff/IBMPlexMono-Medium.woff +0 -0
  58. package/docs/assets/docsify/fonts/ibm-plex-mono/woff/IBMPlexMono-MediumItalic.woff +0 -0
  59. package/docs/assets/docsify/fonts/ibm-plex-mono/woff/IBMPlexMono-Regular.woff +0 -0
  60. package/docs/assets/docsify/fonts/ibm-plex-mono/woff/IBMPlexMono-SemiBold.woff +0 -0
  61. package/docs/assets/docsify/fonts/ibm-plex-mono/woff/IBMPlexMono-SemiBoldItalic.woff +0 -0
  62. package/docs/assets/docsify/fonts/ibm-plex-mono/woff/IBMPlexMono-Thin.woff +0 -0
  63. package/docs/assets/docsify/fonts/ibm-plex-mono/woff/IBMPlexMono-ThinItalic.woff +0 -0
  64. package/docs/assets/docsify/fonts/ibm-plex-mono/woff2/IBMPlexMono-Bold.woff2 +0 -0
  65. package/docs/assets/docsify/fonts/ibm-plex-mono/woff2/IBMPlexMono-BoldItalic.woff2 +0 -0
  66. package/docs/assets/docsify/fonts/ibm-plex-mono/woff2/IBMPlexMono-ExtraLight.woff2 +0 -0
  67. package/docs/assets/docsify/fonts/ibm-plex-mono/woff2/IBMPlexMono-ExtraLightItalic.woff2 +0 -0
  68. package/docs/assets/docsify/fonts/ibm-plex-mono/woff2/IBMPlexMono-Italic.woff2 +0 -0
  69. package/docs/assets/docsify/fonts/ibm-plex-mono/woff2/IBMPlexMono-Light.woff2 +0 -0
  70. package/docs/assets/docsify/fonts/ibm-plex-mono/woff2/IBMPlexMono-LightItatlic.woff2 +0 -0
  71. package/docs/assets/docsify/fonts/ibm-plex-mono/woff2/IBMPlexMono-Medium.woff2 +0 -0
  72. package/docs/assets/docsify/fonts/ibm-plex-mono/woff2/IBMPlexMono-MediumItalic.woff2 +0 -0
  73. package/docs/assets/docsify/fonts/ibm-plex-mono/woff2/IBMPlexMono-Regular.woff2 +0 -0
  74. package/docs/assets/docsify/fonts/ibm-plex-mono/woff2/IBMPlexMono-SemiBold.woff2 +0 -0
  75. package/docs/assets/docsify/fonts/ibm-plex-mono/woff2/IBMPlexMono-SemiBoldItalic.woff2 +0 -0
  76. package/docs/assets/docsify/fonts/ibm-plex-mono/woff2/IBMPlexMono-Thin.woff2 +0 -0
  77. package/docs/assets/docsify/fonts/ibm-plex-mono/woff2/IBMPlexMono-ThinItalic.woff2 +0 -0
  78. package/docs/assets/docsify/fonts/major-mono-display/MajorMonoDisplay-Regular.otf +0 -0
  79. package/docs/assets/docsify/fonts/major-mono-display/MajorMonoDisplay-Regular.ttf +0 -0
  80. package/docs/assets/docsify/fonts/major-mono-display/MajorMonoDisplay-Regular.woff +0 -0
  81. package/docs/assets/docsify/fonts/major-mono-display/MajorMonoDisplay-Regular.woff2 +0 -0
  82. package/docs/assets/docsify/fonts/major-mono-display/OFL.txt +93 -0
  83. package/docs/assets/docsify/fonts/polysans-neutral/PolySansNeutral.eot +0 -0
  84. package/docs/assets/docsify/fonts/polysans-neutral/PolySansNeutral.ttf +0 -0
  85. package/docs/assets/docsify/fonts/polysans-neutral/PolySansNeutral.woff +0 -0
  86. package/docs/assets/docsify/fonts/polysans-neutral/PolySansNeutral.woff2 +0 -0
  87. package/docs/assets/docsify/html/footer.html +23 -0
  88. package/docs/assets/docsify/js/min/back-to-top-button.min.js +1 -0
  89. package/docs/assets/docsify/js/min/copy-code-button.min.js +1 -0
  90. package/docs/assets/docsify/js/min/onload-hacks.min.js +3 -0
  91. package/docs/assets/docsify/js/min/starry-background.min.js +1 -0
  92. package/docs/assets/docsify/js/src/back-to-top-button.js +64 -0
  93. package/docs/assets/docsify/js/src/copy-code-button.js +91 -0
  94. package/docs/assets/docsify/js/src/onload-hacks.js +613 -0
  95. package/docs/assets/docsify/js/src/starry-background.js +111 -0
  96. package/docs/assets/docsify/styles/css/style.min.css +1 -0
  97. package/docs/assets/docsify/styles/css/style.min.css.map +1 -0
  98. package/docs/assets/docsify/styles/scss/style.scss +510 -0
  99. package/docs/assets/separators/aqua.png +0 -0
  100. package/docs/de/LICENSE.md +29 -0
  101. package/docs/de/README.md +324 -0
  102. package/docs/de/SECURITY.md +25 -0
  103. package/docs/de/_coverpage.md +12 -0
  104. package/docs/es/LICENSE.md +29 -0
  105. package/docs/es/README.md +324 -0
  106. package/docs/es/SECURITY.md +25 -0
  107. package/docs/es/_coverpage.md +12 -0
  108. package/docs/fr/LICENSE.md +29 -0
  109. package/docs/fr/README.md +324 -0
  110. package/docs/fr/SECURITY.md +25 -0
  111. package/docs/fr/_coverpage.md +12 -0
  112. package/docs/hi/LICENSE.md +29 -0
  113. package/docs/hi/README.md +325 -0
  114. package/docs/hi/SECURITY.md +25 -0
  115. package/docs/hi/_coverpage.md +12 -0
  116. package/docs/index.html +91 -0
  117. package/docs/it/LICENSE.md +27 -0
  118. package/docs/it/README.md +324 -0
  119. package/docs/it/SECURITY.md +25 -0
  120. package/docs/it/_coverpage.md +12 -0
  121. package/docs/ja/LICENSE.md +29 -0
  122. package/docs/ja/README.md +324 -0
  123. package/docs/ja/SECURITY.md +25 -0
  124. package/docs/ja/_coverpage.md +12 -0
  125. package/docs/ko/LICENSE.md +32 -0
  126. package/docs/ko/README.md +329 -0
  127. package/docs/ko/SECURITY.md +25 -0
  128. package/docs/ko/_coverpage.md +12 -0
  129. package/docs/ne/LICENSE.md +35 -0
  130. package/docs/ne/README.md +325 -0
  131. package/docs/ne/SECURITY.md +25 -0
  132. package/docs/ne/_coverpage.md +12 -0
  133. package/docs/nl/LICENSE.md +29 -0
  134. package/docs/nl/README.md +324 -0
  135. package/docs/nl/SECURITY.md +25 -0
  136. package/docs/nl/_coverpage.md +12 -0
  137. package/docs/pt/LICENSE.md +29 -0
  138. package/docs/pt/README.md +324 -0
  139. package/docs/pt/SECURITY.md +25 -0
  140. package/docs/pt/_coverpage.md +12 -0
  141. package/docs/vi/LICENSE.md +29 -0
  142. package/docs/vi/README.md +324 -0
  143. package/docs/vi/SECURITY.md +25 -0
  144. package/docs/vi/_coverpage.md +12 -0
  145. package/docs/zh-cn/LICENSE.md +29 -0
  146. package/docs/zh-cn/README.md +324 -0
  147. package/docs/zh-cn/SECURITY.md +25 -0
  148. package/docs/zh-cn/_coverpage.md +12 -0
  149. package/docs/zh-tw/LICENSE.md +29 -0
  150. package/docs/zh-tw/README.md +323 -0
  151. package/docs/zh-tw/SECURITY.md +25 -0
  152. package/docs/zh-tw/_coverpage.md +12 -0
  153. package/package.json +54 -0
  154. package/starters/chrome/LICENSE +21 -0
  155. package/starters/chrome/docs/README.md +77 -0
  156. package/starters/chrome/docs/de/LICENSE.md +13 -0
  157. package/starters/chrome/docs/de/README.md +77 -0
  158. package/starters/chrome/docs/es/LICENSE.md +13 -0
  159. package/starters/chrome/docs/es/README.md +77 -0
  160. package/starters/chrome/docs/fr/LICENSE.md +13 -0
  161. package/starters/chrome/docs/fr/README.md +77 -0
  162. package/starters/chrome/docs/hi/LICENSE.md +13 -0
  163. package/starters/chrome/docs/hi/README.md +78 -0
  164. package/starters/chrome/docs/it/LICENSE.md +11 -0
  165. package/starters/chrome/docs/it/README.md +77 -0
  166. package/starters/chrome/docs/ja/LICENSE.md +13 -0
  167. package/starters/chrome/docs/ja/README.md +78 -0
  168. package/starters/chrome/docs/ko/LICENSE.md +16 -0
  169. package/starters/chrome/docs/ko/README.md +77 -0
  170. package/starters/chrome/docs/nl/LICENSE.md +13 -0
  171. package/starters/chrome/docs/nl/README.md +77 -0
  172. package/starters/chrome/docs/pt/LICENSE.md +13 -0
  173. package/starters/chrome/docs/pt/README.md +77 -0
  174. package/starters/chrome/docs/vi/LICENSE.md +13 -0
  175. package/starters/chrome/docs/vi/README.md +77 -0
  176. package/starters/chrome/docs/zh-cn/LICENSE.md +13 -0
  177. package/starters/chrome/docs/zh-cn/README.md +78 -0
  178. package/starters/chrome/docs/zh-tw/LICENSE.md +13 -0
  179. package/starters/chrome/docs/zh-tw/README.md +77 -0
  180. package/starters/chrome/extension/background.js +14 -0
  181. package/starters/chrome/extension/content.js +62 -0
  182. package/starters/chrome/extension/icons/icon128.png +0 -0
  183. package/starters/chrome/extension/icons/icon16.png +0 -0
  184. package/starters/chrome/extension/icons/icon32.png +0 -0
  185. package/starters/chrome/extension/icons/icon64.png +0 -0
  186. package/starters/chrome/extension/lib/chatgpt.js +2061 -0
  187. package/starters/chrome/extension/lib/settings-utils.js +24 -0
  188. package/starters/chrome/extension/manifest.json +24 -0
  189. package/starters/chrome/extension/popup/index.html +62 -0
  190. package/starters/chrome/extension/popup/popup.js +92 -0
  191. package/starters/chrome/extension/popup/style.css +55 -0
  192. package/starters/chrome/media/images/screenshots/chatgpt-extension-in-list.png +0 -0
  193. package/starters/chrome/media/images/screenshots/developer-mode-toggle.png +0 -0
  194. package/starters/chrome/media/images/screenshots/developer-mode-toggle.psd +0 -0
  195. package/starters/chrome/media/images/screenshots/extension-loaded.png +0 -0
  196. package/starters/chrome/media/images/screenshots/load-unpacked-button.png +0 -0
  197. package/starters/chrome/media/images/screenshots/reload-extension-button.png +0 -0
  198. package/starters/chrome/media/images/screenshots/reload-page-button.png +0 -0
  199. package/starters/chrome/media/images/screenshots/select-extension-folder.png +0 -0
  200. package/starters/docs/LICENSE.md +25 -0
  201. package/starters/docs/README.md +29 -0
  202. package/starters/docs/de/LICENSE.md +13 -0
  203. package/starters/docs/de/README.md +29 -0
  204. package/starters/docs/es/LICENSE.md +13 -0
  205. package/starters/docs/es/README.md +29 -0
  206. package/starters/docs/fr/LICENSE.md +13 -0
  207. package/starters/docs/fr/README.md +29 -0
  208. package/starters/docs/hi/LICENSE.md +13 -0
  209. package/starters/docs/hi/README.md +29 -0
  210. package/starters/docs/it/LICENSE.md +11 -0
  211. package/starters/docs/it/README.md +29 -0
  212. package/starters/docs/ja/LICENSE.md +13 -0
  213. package/starters/docs/ja/README.md +30 -0
  214. package/starters/docs/ko/LICENSE.md +16 -0
  215. package/starters/docs/ko/README.md +29 -0
  216. package/starters/docs/nl/LICENSE.md +13 -0
  217. package/starters/docs/nl/README.md +29 -0
  218. package/starters/docs/pt/LICENSE.md +13 -0
  219. package/starters/docs/pt/README.md +29 -0
  220. package/starters/docs/vi/LICENSE.md +13 -0
  221. package/starters/docs/vi/README.md +29 -0
  222. package/starters/docs/zh-cn/LICENSE.md +13 -0
  223. package/starters/docs/zh-cn/README.md +30 -0
  224. package/starters/docs/zh-tw/LICENSE.md +13 -0
  225. package/starters/docs/zh-tw/README.md +29 -0
  226. package/starters/greasemonkey/LICENSE +21 -0
  227. package/starters/greasemonkey/chatgpt.js-greasemonkey-starter.user.js +52 -0
  228. package/starters/greasemonkey/docs/README.md +7 -0
  229. package/starters/greasemonkey/media/images/icons/robot/icon48.png +0 -0
  230. package/starters/greasemonkey/media/images/icons/robot/icon64.png +0 -0
  231. package/starters/greasemonkey/media/images/screenshots/chatgpt-userscript-on.png +0 -0
  232. package/starters/media/images/icons/tampermonkey-icon28.png +0 -0
  233. package/starters/media/images/icons/violentmonkey-icon100.png +0 -0
@@ -0,0 +1 @@
1
+ const functionAliases=[["actAs","actas","act","become","persona","premadePrompt","preMadePrompt","prePrompt","preprompt","roleplay","rolePlay","rp"],["activateAutoRefresh","activateAutoRefresher","activateRefresher","activateSessionRefresher","autoRefresh","autoRefresher","autoRefreshSession","refresher","sessionRefresher"],["deactivateAutoRefresh","deactivateAutoRefresher","deactivateRefresher","deactivateSessionRefresher"],["detectLanguage","getLanguage"],["executeCode","codeExecute"],["exportChat","chatExport","export"],["getLastPrompt","getLastQuery","getMyLastMsg","getMyLastQuery"],["getTextarea","getTextArea","getChatbox","getChatBox"],["isFullScreen","isFullscreen"],["logOut","logout","logOff","logoff","signOut","signout","signOff","signoff"],["minify","codeMinify","minifyCode"],["new","newChat","startNewChat"],["obfuscate","codeObfuscate","obfuscateCode"],["printAllFunctions","showAllFunctions"],["refactor","codeRefactor","refactorCode"],["refreshReply","regenerate","regenerateReply"],["refreshSession","sessionRefresh"],["renderHTML","renderHtml","renderLinks","renderTags"],["reviewCode","codeReview"],["send","sendChat","sendMsg"],["sendInNewChat","sendNewChat"],["sentiment","analyzeSentiment","sentimentAnalysis"],["stop","stopGenerating"],["suggest","suggestion","recommend"],["toggleAutoRefresh","toggleAutoRefresher","toggleRefresher","toggleSessionRefresher"],["toggleScheme","toggleMode"],["translate","translation","translator"],["unminify","unminifyCode","codeUnminify"],["writeCode","codeWrite"]];const synonyms=[["account","acct"],["activate","turnOn"],["analyze","check","evaluate","review"],["ask","send","submit"],["chat","conversation","convo"],["data","details"],["deactivate","deActivate","turnOff"],["execute","interpret","interpreter","run"],["generating","generation"],["minify","uglify"],["refactor","rewrite"],["regenerate","regen"],["render","parse"],["reply","response"],["sentiment","attitude","emotion","feeling","opinion","perception"],["speak","say","speech","talk","tts"],["summarize","tldr"],["unminify","beautify","prettify","prettyPrint"]];const endpoints={assets:"https://raw.githubusercontent.com/KudoAI/chatgpt.js/main",openAI:{session:"https://chat.openai.com/api/auth/session",chats:"https://chat.openai.com/backend-api/conversations",chat:"https://chat.openai.com/backend-api/conversation",share_create:"https://chat.openai.com/backend-api/share/create",share:"https://chat.openai.com/backend-api/share",instructions:"https://chat.openai.com/backend-api/user_system_messages"}};localStorage.alertQueue=JSON.stringify([]);localStorage.notifyProps=JSON.stringify({queue:{topRight:[],bottomRight:[],bottomLeft:[],topLeft:[]},lastNthAudio:0});const isChromeUserScript=navigator.userAgent.includes("Chrome")&&typeof unsafeWindow!="undefined",isFFuserScript=navigator.userAgent.includes("Firefox")&&typeof unsafeWindow!="undefined",isFFtmScript=isFFuserScript&&GM_info.scriptHandler=="Tampermonkey";let cjsMessages;if(!isChromeUserScript&&!(isFFuserScript&&!isFFtmScript)){(async()=>{const cjsMsgsLoaded=new Promise(resolve=>{const userLanguage=navigator.languages[0]||navigator.language||navigator.browserLanguage||navigator.systemLanguage||navigator.userLanguage||"",msgHostDir=endpoints.assets+"/data/_locales/",msgLocaleDir=(userLanguage?userLanguage.replace("-","_"):"en")+"/";let msgHref=msgHostDir+msgLocaleDir+"messages.json",msgXHRtries=0;(function loadMsgs(){const xhr=new XMLHttpRequest;xhr.open("GET",msgHref);xhr.send();xhr.onload=()=>{try{const messages=new Proxy(JSON.parse(xhr.responseText),{get(target,prop){if(typeof target[prop]=="object"&&target[prop]!==null&&"message"in target[prop]){return target[prop].message}}});resolve(messages)}catch(err){msgXHRtries++;if(msgXHRtries===3)resolve({});msgHref=userLanguage.includes("-")&&msgXHRtries===1?msgHref.replace(/(.*)_.*(\/.*)/,"$1$2"):msgHostDir+"en/messages.json";loadMsgs()}};xhr.onerror=()=>{resolve({})}})()});cjsMessages=await cjsMsgsLoaded})()}const chatgpt={openAIaccessToken:{},actAs:function(persona){const promptsUrl="https://raw.githubusercontent.com/KudoAI/chat-prompts/main/dist/personas.min.json";return new Promise((resolve,reject)=>{const xhr=new XMLHttpRequest;xhr.open("GET",promptsUrl,true);xhr.send();xhr.onload=()=>{if(xhr.status!==200)return reject("🤖 chatgpt.js >> Request failed. Cannot retrieve prompts data.");const data=JSON.parse(xhr.responseText).personas;if(!persona){console.log("\n%c🤖 chatgpt.js personas\n","font-family: sans-serif ; font-size: xxx-large ; font-weight: bold");for(const prompt of data)console.log(`%c${prompt.title}`,"font-family: monospace ; font-size: larger ;");return resolve()}const selectedPrompt=data.find(obj=>obj.title.toLowerCase()==persona.toLowerCase());if(!selectedPrompt)return reject(`🤖 chatgpt.js >> Persona '${persona}' was not found!`);chatgpt.send(selectedPrompt.prompt,"click");console.info(`Loading ${persona} persona...`);chatgpt.isIdle().then(()=>{console.info("Persona activated!")});return resolve()}})},activateDarkMode:function(){document.documentElement.classList.replace("light","dark");document.documentElement.style.colorScheme="dark";localStorage.setItem("theme","dark")},activateLightMode:function(){document.documentElement.classList.replace("dark","light");document.documentElement.style.colorScheme="light";localStorage.setItem("theme","light")},alert:function(title,msg,btns,checkbox,width){const scheme=chatgpt.isDarkMode()?"dark":"light",isMobile=chatgpt.browser.isMobile();const modalContainer=document.createElement("div");modalContainer.id=Math.floor(chatgpt.randomFloat()*1e6)+Date.now();modalContainer.classList.add("chatgpt-modal");const modal=document.createElement("div"),modalTitle=document.createElement("h2"),modalMessage=document.createElement("p");const thisUpdated=20231203;let modalStyle=document.querySelector("#chatgpt-modal-style");if(!modalStyle||parseInt(modalStyle.getAttribute("last-updated"),10)<thisUpdated){if(!modalStyle){modalStyle=document.createElement("style");modalStyle.id="chatgpt-modal-style";modalStyle.setAttribute("last-updated",thisUpdated.toString());document.head.append(modalStyle)}modalStyle.innerText=".chatgpt-modal {"+"position: fixed ; top: 0 ; left: 0 ; width: 100% ; height: 100% ;"+"background-color: rgba(67, 70, 72, 0) ;"+"transition: background-color 0.05s ease ;"+"display: flex ; justify-content: center ; align-items: center ; z-index: 9999 }"+".chatgpt-modal > div {"+"opacity: 0 ; transform: translateX(-2px) translateY(5px) ; max-width: 75vw ; word-wrap: break-word ;"+"transition: opacity 0.1s cubic-bezier(.165,.84,.44,1), transform 0.2s cubic-bezier(.165,.84,.44,1) ;"+`background-color: ${scheme=="dark"?"black":"white"} ;`+(scheme!="dark"?"border: 1px solid rgba(0, 0, 0, 0.3) ;":"")+"padding: 20px ; margin: 12px 23px ; border-radius: 15px ; box-shadow: 0 30px 60px rgba(0, 0, 0, .12) ;"+" -webkit-user-select: none ; -moz-user-select: none ; -ms-user-select: none ; user-select: none ; }"+".chatgpt-modal h2 { margin-bottom: 9px }"+`.chatgpt-modal a { color: ${scheme=="dark"?"#00cfff":"#1e9ebb"}}`+".chatgpt-modal.animated > div { opacity: 1 ; transform: translateX(0) translateY(0) }"+"@keyframes alert-zoom-fade-out { 0% { opacity: 1 ; transform: scale(1) }"+"50% { opacity: 0.25 ; transform: scale(1.05) }"+"100% { opacity: 0 ; transform: scale(1.35) }}"+".modal-buttons { display: flex ; justify-content: flex-end ; margin: 20px -5px -3px 0 ;"+(isMobile?"flex-direction: column-reverse":"")+"}"+".chatgpt-modal button {"+`margin-left: ${isMobile?0:10}px ; padding: ${isMobile?15:4}px 18px ; border-radius: 15px ;`+(isMobile?"margin-top: 5px ; margin-bottom: 3px ;":"")+`border: 1px solid ${scheme=="dark"?"white":"black"}}`+".primary-modal-btn {"+`border: 1px solid ${scheme=="dark"?"white":"black"} ;`+`background: ${scheme=="dark"?"white":"black"} ;`+`color: ${scheme=="dark"?"black":"white"}}`+".chatgpt-modal button:hover { color: #3d5d71 ; border-color: #6d9cb9 ;"+"background-color: "+(scheme=="dark"?"#00cfff":"#9cdaff")+";"+"box-shadow: 2px 1px "+(scheme=="dark"?"54px #00cfff":"30px #9cdaff")+"}"+".modal-close-btn {"+"cursor: pointer ; width: 20px ; height: 20px ; float: right ; position: relative ; right: -2px }"+".modal-close-btn svg { margin: 5px 5px }"+`.modal-close-btn:hover { background-color: #f2f2f2${scheme=="dark"?"00":""}}`+".chatgpt-modal .checkbox-group { display: flex ; margin-top: -18px }"+".chatgpt-modal .checkbox-group label {"+"font-size: .7rem ; margin: -.04rem 0 0px .3rem ;"+`color: ${scheme=="dark"?"#e1e1e1":"#1e1e1e"}}`+'.chatgpt-modal input[type="checkbox"] { transform: scale(0.7) ;'+`border: 1px solid ${scheme=="dark"?"white":"black"}}`+'.chatgpt-modal input[type="checkbox"]:checked {'+`border: 1px solid ${scheme=="dark"?"white":"black"} ;`+"background-color: black ; position: inherit }"+'.chatgpt-modal input[type="checkbox"]:focus { outline: none ; box-shadow: none }'}modalTitle.innerText=title||"";modalMessage.innerText=msg||"";this.renderHTML(modalMessage);const modalButtons=document.createElement("div");modalButtons.classList.add("modal-buttons");if(btns){if(!Array.isArray(btns))btns=[btns];btns.forEach(buttonFn=>{const button=document.createElement("button");button.textContent=buttonFn.name.replace(/[_-]\w/g,match=>match.slice(1).toUpperCase()).replace(/([A-Z])/g," $1").replace(/^\w/,firstChar=>firstChar.toUpperCase());button.addEventListener("click",()=>{dismissAlert();buttonFn()});modalButtons.insertBefore(button,modalButtons.firstChild)})}const dismissBtn=document.createElement("button");dismissBtn.textContent=btns?"Dismiss":"OK";modalButtons.insertBefore(dismissBtn,modalButtons.firstChild);modalButtons.lastChild.classList.add("primary-modal-btn");const checkboxDiv=document.createElement("div");if(checkbox){checkboxDiv.classList.add("checkbox-group");const checkboxFn=checkbox,checkboxInput=document.createElement("input");checkboxInput.type="checkbox";checkboxInput.addEventListener("change",checkboxFn);const checkboxLabel=document.createElement("label");checkboxLabel.addEventListener("click",()=>{checkboxInput.checked=!checkboxInput.checked;checkboxFn()});checkboxLabel.textContent=checkboxFn.name.charAt(0).toUpperCase()+checkboxFn.name.slice(1).replace(/([A-Z])/g,(match,letter)=>" "+letter.toLowerCase()).replace(/\b(\w+)nt\b/gi,"$1n't").trim();checkboxDiv.append(checkboxInput);checkboxDiv.append(checkboxLabel)}const closeBtn=document.createElement("div");closeBtn.title=cjsMessages?.tooltip_close||"Close";closeBtn.classList.add("modal-close-btn");const closeSVG=document.createElementNS("http://www.w3.org/2000/svg","svg");closeSVG.setAttribute("height","10px");closeSVG.setAttribute("viewBox","0 0 14 14");closeSVG.setAttribute("fill","none");const closeSVGpath=document.createElementNS("http://www.w3.org/2000/svg","path");closeSVGpath.setAttribute("fill-rule","evenodd");closeSVGpath.setAttribute("clip-rule","evenodd");closeSVGpath.setAttribute("fill",chatgpt.isDarkMode()?"white":"black");closeSVGpath.setAttribute("d","M13.7071 1.70711C14.0976 1.31658 14.0976 0.683417 13.7071 0.292893C13.3166 -0.0976312 12.6834 -0.0976312 12.2929 0.292893L7 5.58579L1.70711 0.292893C1.31658 -0.0976312 0.683417 -0.0976312 0.292893 0.292893C-0.0976312 0.683417 -0.0976312 1.31658 0.292893 1.70711L5.58579 7L0.292893 12.2929C-0.0976312 12.6834 -0.0976312 13.3166 0.292893 13.7071C0.683417 14.0976 1.31658 14.0976 1.70711 13.7071L7 8.41421L12.2929 13.7071C12.6834 14.0976 13.3166 14.0976 13.7071 13.7071C14.0976 13.3166 14.0976 12.6834 13.7071 12.2929L8.41421 7L13.7071 1.70711Z");closeSVG.append(closeSVGpath);closeBtn.append(closeSVG);const modalElems=[closeBtn,modalTitle,modalMessage,modalButtons,checkboxDiv];modalElems.forEach(elem=>{modal.append(elem)});modal.style.width=`${width||458}px`;modalContainer.append(modal);document.body.append(modalContainer);let alertQueue=JSON.parse(localStorage.alertQueue);alertQueue.push(modalContainer.id);localStorage.alertQueue=JSON.stringify(alertQueue);modalContainer.style.display="none";if(alertQueue.length===1){modalContainer.style.display="";setTimeout(()=>{modalContainer.style.backgroundColor=`rgba(67, 70, 72, ${scheme==="dark"?.62:0})`;modalContainer.classList.add("animated")},100)}const clickHandler=event=>{if(event.target==event.currentTarget||event.target instanceof SVGPathElement)dismissAlert()};const keyHandler=event=>{const dismissKeys=[13,27];if(dismissKeys.includes(event.keyCode)){for(const alertId of alertQueue){const alert=document.getElementById(alertId);if(alert&&alert.style.display!=="none"){if(event.keyCode===27)dismissAlert();else if(event.keyCode===13){const mainButton=alert.querySelector(".modal-buttons").lastChild;if(mainButton){mainButton.click();event.preventDefault()}}return}}}};const dismissElems=[modalContainer,closeBtn,closeSVG,dismissBtn];dismissElems.forEach(elem=>{elem.addEventListener("click",clickHandler)});document.addEventListener("keydown",keyHandler);const dismissAlert=()=>{modalContainer.style.backgroundColor="transparent";modal.style.animation="alert-zoom-fade-out 0.075s ease-out";setTimeout(()=>{modalContainer.remove();alertQueue=JSON.parse(localStorage.alertQueue);alertQueue.shift();localStorage.alertQueue=JSON.stringify(alertQueue);dismissElems.forEach(elem=>{elem.removeEventListener("click",clickHandler)});document.removeEventListener("keydown",keyHandler);if(alertQueue.length>0){const nextAlert=document.getElementById(alertQueue[0]);setTimeout(()=>{nextAlert.style.display="";setTimeout(()=>{nextAlert.classList.add("animated")},100)},500)}},50)};return modalContainer.id},askAndGetReply:async function(query){chatgpt.send(query);await chatgpt.isIdle();return chatgpt.getChatData("active","msg","chatgpt","latest")},autoRefresh:{activate:function(interval){if(this.isActive){console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already active!");return}const autoRefresh=this;this.toggle.refreshFrame();const scheduleRefreshes=interval=>{const randomDelay=Math.max(2,Math.floor(chatgpt.randomFloat()*21-10));autoRefresh.isActive=setTimeout(()=>{const manifestScript=document.querySelector('script[src*="_ssgManifest.js"]');document.querySelector("#refresh-frame").src=manifestScript.src+"?"+Date.now();console.log("↻ ChatGPT >> ["+autoRefresh.nowTimeStamp()+"] ChatGPT session refreshed");scheduleRefreshes(interval)},(interval+randomDelay)*1e3)};scheduleRefreshes(interval?parseInt(interval,10):30);console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh activated");if(navigator.userAgent.includes("Chrome")&&typeof document.hidden!=="undefined"){document.addEventListener("visibilitychange",this.toggle.beacons)}},deactivate:function(){if(this.isActive){this.toggle.refreshFrame();document.removeEventListener("visibilitychange",this.toggle.beacons);clearTimeout(this.isActive);this.isActive=null;console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh de-activated")}else{console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already inactive!")}},nowTimeStamp:function(){const now=new Date;const hours=now.getHours()%12||12;let minutes=now.getMinutes(),seconds=now.getSeconds();if(minutes<10)minutes="0"+minutes;if(seconds<10)seconds="0"+seconds;const meridiem=now.getHours()<12?"AM":"PM";return hours+":"+minutes+":"+seconds+" "+meridiem},toggle:{beacons:function(){if(chatgpt.autoRefresh.beaconID){clearInterval(chatgpt.autoRefresh.beaconID);chatgpt.autoRefresh.beaconID=null;console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacons de-activated")}else{chatgpt.autoRefresh.beaconID=setInterval(()=>{navigator.sendBeacon("https://httpbin.org/post",new Uint8Array);console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacon sent")},9e4);console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacons activated")}},refreshFrame:function(){let refreshFrame=document.querySelector("#refresh-frame");if(refreshFrame)refreshFrame.remove();else{refreshFrame=Object.assign(document.createElement("iframe"),{id:"refresh-frame",style:"display: none"});document.head.prepend(refreshFrame)}}}},browser:{isLightMode:function(){return window.matchMedia?.("(prefers-color-scheme: light)")?.matches},isDarkMode:function(){return window.matchMedia?.("(prefers-color-scheme: dark)")?.matches},isChromium:function(){return navigator.userAgent.includes("Chrome")},isFirefox:function(){return navigator.userAgent.includes("Firefox")},isFullScreen:function(){const userAgentStr=navigator.userAgent;return userAgentStr.includes("Chrome")?window.matchMedia("(display-mode: fullscreen)").matches:userAgentStr.includes("Firefox")?window.fullScreen:/MSIE|rv:/.test(userAgentStr)?document.msFullscreenElement:document.webkitIsFullScreen},isMobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}},clearChats:async function(method){const validMethods=["api","dom"];method=(method||"dom").trim().toLowerCase();if(method&&!validMethods.includes(method))return console.log(`Method argument must be one of: [${validMethods}]`);if(method=="dom"){try{await chatgpt.getChatData()}catch{return}chatgpt.menu.open();setTimeout(()=>{const menuItems=document.querySelectorAll('a[role="menuitem"]')||[];for(const menuItem of menuItems)if(/settings/i.test(menuItem.text)){menuItem.click();break}setTimeout(()=>{const settingsBtns=document.querySelectorAll("[id*=radix] button");for(const settingsBtn of settingsBtns)if(/^clear/i.test(settingsBtn.textContent)){settingsBtn.click();break}setTimeout(()=>{document.querySelector("[id*=radix] button").click();setTimeout(()=>{exitMenu();try{document.querySelector("#prompt-textarea").focus()}catch(err){}},10)},10)},333)},10);const exitMenu=()=>{document.querySelector("div[id*=radix] button").click()}}else{return new Promise((resolve,reject)=>{chatgpt.getAccessToken().then(token=>{const xhr=new XMLHttpRequest;xhr.open("PATCH",endpoints.openAI.chats,true);xhr.setRequestHeader("Content-Type","application/json");xhr.setRequestHeader("Authorization","Bearer "+token);xhr.onload=()=>{if(xhr.status!==200)return reject("🤖 chatgpt.js >> Request failed. Cannot clear chats.");console.info("Chats successfully cleared");resolve()};xhr.send(JSON.stringify({is_visible:false}))}).catch(reject)})}},code:{execute:async function(code){if(!code)return console.error("Code argument not supplied. Pass some code!");if(typeof code!=="string")return console.error("Code argument must be a string!");chatgpt.send("Display the output as if you were terminal:\n\n"+code);console.info("Executing code...");await chatgpt.isIdle();return chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))},extract:function(msg){const codeBlocks=msg.match(/(?<=```.*\n)[\s\S]*?(?=```)/g);return codeBlocks?codeBlocks[codeBlocks.length-1]:msg},minify:async function(code){if(!code)return console.error("Code argument not supplied. Pass some code!");if(typeof code!=="string")return console.error("Code argument must be a string!");chatgpt.send("Minify the following code:\n\n"+code);console.info("Minifying code...");await chatgpt.isIdle();return chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))},obfuscate:async function(code){if(!code)return console.error("Code argument not supplied. Pass some code!");if(typeof code!=="string")return console.error("Code argument must be a string!");chatgpt.send("Obfuscate the following code:\n\n"+code);console.info("Obfuscating code...");await chatgpt.isIdle();return chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))},refactor:async function(code,objective){if(!code)return console.error("Code (1st) argument not supplied. Pass some code!");for(let i=0;i<arguments.length;i++)if(typeof arguments[i]!=="string")return console.error(`Argument ${i+1} must be a string.`);chatgpt.send("Refactor the following code for "+(objective||"brevity")+":\n\n"+code);console.info("Refactoring code...");await chatgpt.isIdle();return chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))},review:async function(code){if(!code)return console.error("Code argument not supplied. Pass some code!");if(typeof code!=="string")return console.error("Code argument must be a string!");chatgpt.send("Review the following code for me:\n\n"+code);console.info("Reviewing code...");await chatgpt.isIdle();return chatgpt.getChatData("active","msg","chatgpt","latest")},unminify:async function(code){if(!code)return console.error("Code argument not supplied. Pass some code!");if(typeof code!=="string")return console.error("Code argument must be a string!");chatgpt.send("Unminify the following code.:\n\n"+code);console.info("Unminifying code...");await chatgpt.isIdle();return chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))},write:async function(prompt,outputLang){if(!prompt)return console.error("Prompt (1st) argument not supplied. Pass a prompt!");if(!outputLang)return console.error("outputLang (2nd) argument not supplied. Pass a language!");for(let i=0;i<arguments.length;i++)if(typeof arguments[i]!=="string")return console.error(`Argument ${i+1} must be a string.`);chatgpt.send(prompt+"\n\nWrite this as code in "+outputLang);console.info("Writing code...");await chatgpt.isIdle();return chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))}},detectLanguage:async function(text){if(!text)return console.error("Text argument not supplied. Pass some text!");if(typeof text!=="string")return console.error("Text argument must be a string!");chatgpt.send("Detect the language of the following text:\n\n"+text+"\n\nOnly respond with the name of the language");console.info("Reviewing text...");await chatgpt.isIdle();return chatgpt.getChatData("active","msg","chatgpt","latest")},executeCode:function(){chatgpt.code.execute()},exportChat:async function(chatToGet,format){chatToGet=!chatToGet?"active":Number.isInteger(chatToGet)||/^\d+$/.test(chatToGet)?parseInt(chatToGet,10):chatToGet;format=format.toLowerCase()||"html";console.info("Generating transcript...");let transcript="",filename;if(/te?xt/.test(format)){const now=new Date,day=now.getDate().toString().padStart(2,"0"),month=(now.getMonth()+1).toString().padStart(2,"0"),year=now.getFullYear(),hour=now.getHours().toString().padStart(2,"0"),minute=now.getMinutes().toString().padStart(2,"0");filename=`ChatGPT_${day}-${month}-${year}_${hour}-${minute}.txt`;if(chatToGet=="active"&&/\/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(window.location.href)){const chatDivs=document.querySelectorAll("main > div > div > div > div > div > div[class*=group]");if(chatDivs.length===0)return console.error("Chat is empty!");const msgs=[];let isUserMsg=true;chatDivs.forEach(div=>{const sender=isUserMsg?"USER":"CHATGPT";isUserMsg=!isUserMsg;let msg=Array.from(div.childNodes).map(node=>node.innerText).join("\n\n").replace("Copy code","");msgs.push(sender+": "+msg)});transcript=msgs.join("\n\n")}else{for(const entry of await chatgpt.getChatData(chatToGet,"msg","both","all")){transcript+=`USER: ${entry.user}\n\n`;transcript+=`CHATGPT: ${entry.chatgpt}\n\n`}}}else{const response=await fetch(await chatgpt.shareChat(chatToGet)),htmlContent=await response.text();const parser=new DOMParser,parsedHtml=parser.parseFromString(htmlContent,"text/html");filename=parsedHtml.querySelector("title").textContent+".html";const cssLinks=parsedHtml.querySelectorAll('link[rel="stylesheet"]');cssLinks.forEach(link=>{const href=link.getAttribute("href");if(href?.startsWith("/"))link.setAttribute("href","https://chat.openai.com"+href)});transcript=(new XMLSerializer).serializeToString(parsedHtml)}console.info(`Exporting transcript as ${format.toUpperCase()}...`);if(format=="pdf"){transcript=transcript.replace(/<svg.*?<\/svg>/g,match=>{const dataURL="data:image/svg+xml,"+encodeURIComponent(match);return`<img src="${dataURL}">`});const transcriptPopup=window.open("","","toolbar=0, location=0, menubar=0, height=600, width=800");transcriptPopup.document.write(transcript);setTimeout(()=>{transcriptPopup.print({toPDF:true})},100)}else{if(format=="md"){const mdMatch=/<!?.*(<h1(.|\n)*?href=".*?continue.*?".*?\/a>.*?)<[^/]/.exec(transcript)[1];transcript=mdMatch||transcript;filename=filename.replace(".html",".md")}const blob=new Blob([transcript],{type:"text/"+(format=="html"?"html":format=="md"?"markdown":"plain")});const link=document.createElement("a"),blobURL=URL.createObjectURL(blob);link.href=blobURL;link.download=filename;document.body.append(link);link.click();document.body.removeChild(link);URL.revokeObjectURL(blobURL)}},extractCode:function(){chatgpt.code.extract()},generateRandomIP:function(){const ip=Array.from({length:4},()=>Math.floor(chatgpt.randomFloat()*256)).join(".");console.info("IP generated: "+ip);return ip},get:function(targetType,targetName=""){if(typeof targetType!=="string"||typeof targetName!=="string"){throw new TypeError("Invalid arguments. Both arguments must be strings.")}if(!targetTypes.includes(targetType.toLowerCase())){throw new Error("Invalid targetType: "+targetType+". Valid values are: "+JSON.stringify(targetTypes))}const targetNames=[],reTargetName=new RegExp("^get(.*)"+targetType+"$","i");for(const prop in chatgpt){if(typeof chatgpt[prop]=="function"&&reTargetName.test(prop)){targetNames.push(prop.replace(reTargetName,"$1").toLowerCase())}}if(!targetNames.includes(targetName.toLowerCase())){throw new Error("Invalid targetName: "+targetName+". "+(targetNames.length>0?"Valid values are: "+JSON.stringify(targetNames):"targetType "+targetType.toLowerCase()+" does not require additional options."))}const targetFuncNameLower=("get"+targetName+targetType).toLowerCase();const targetFuncName=Object.keys(this).find(name=>{return name.toLowerCase()==targetFuncNameLower});return this[targetFuncName]()},getAccessToken:function(){return new Promise((resolve,reject)=>{if(Object.keys(chatgpt.openAIaccessToken).length>0&&Date.parse(chatgpt.openAIaccessToken.expireDate)-Date.parse(new Date)>=0)return resolve(chatgpt.openAIaccessToken.token);const xhr=new XMLHttpRequest;xhr.open("GET",endpoints.openAI.session,true);xhr.setRequestHeader("Content-Type","application/json");xhr.onload=()=>{if(xhr.status!==200)return reject("🤖 chatgpt.js >> Request failed. Cannot retrieve access token.");console.info("Token expiration: "+new Date(JSON.parse(xhr.responseText).expires).toLocaleString().replace(","," at"));chatgpt.openAIaccessToken={token:JSON.parse(xhr.responseText).accessToken,expireDate:JSON.parse(xhr.responseText).expires};return resolve(chatgpt.openAIaccessToken.token)};xhr.send()})},getAccountDetails:function(...details){const validDetails=["email","id","image","name","picture"];details=!arguments[0]?validDetails:Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);for(const detail of details){if(!validDetails.includes(detail)){return console.error("Invalid detail arg '"+detail+"' supplied. Valid details are:\n"+" ["+validDetails+"]")}}return new Promise((resolve,reject)=>{const xhr=new XMLHttpRequest;xhr.open("GET",endpoints.openAI.session,true);xhr.setRequestHeader("Content-Type","application/json");xhr.onload=()=>{if(xhr.status===200){const data=JSON.parse(xhr.responseText).user,detailsToReturn={};for(const detail of details)detailsToReturn[detail]=data[detail];return resolve(detailsToReturn)}else return reject("🤖 chatgpt.js >> Request failed. Cannot retrieve account details.")};xhr.send()})},getChatBox:function(){return document.getElementById("prompt-textarea")},getChatData:function(chatToGet=1,detailsToGet="all",sender="all",msgToGet="all"){const validDetails=["all","id","title","create_time","update_time","msg"];const validSenders=["all","both","user","chatgpt"];chatToGet=!chatToGet?"active":Number.isInteger(chatToGet)||/^\d+$/.test(chatToGet)?parseInt(chatToGet,10)===0?0:parseInt(chatToGet,10)-1:chatToGet;detailsToGet=["all",""].includes(detailsToGet)?validDetails.filter(detail=>/^(?!all$|msg$).*/.test(detail)):Array.isArray(detailsToGet)?detailsToGet:[detailsToGet];sender=!sender?"all":validSenders.includes(sender)?sender:"invalid";msgToGet=Number.isInteger(msgToGet)||/^\d+$/.test(msgToGet)?parseInt(msgToGet,10)===0?0:parseInt(msgToGet,10)-1:["all","latest"].includes(msgToGet.toLowerCase())?msgToGet.toLowerCase():!msgToGet?"all":"invalid";for(const detail of detailsToGet){if(!validDetails.includes(detail)){return console.error("Invalid detail arg '"+detail+"' passed. Valid details are:\n"+" ["+validDetails+"]")}}if(sender=="invalid"){return console.error("Invalid sender arg passed. Valid senders are:\n"+" ["+validSenders+"]")}if(msgToGet=="invalid"){return console.error("Invalid msgToGet arg passed. Valid msg's to get are:\n"+" [ 'all' | 'latest' | index of msg to get ]")}const getChatDetails=(token,detailsToGet)=>{const re_chatID=/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/;return new Promise((resolve,reject)=>{const xhr=new XMLHttpRequest;xhr.open("GET",endpoints.openAI.chats,true);xhr.setRequestHeader("Content-Type","application/json");xhr.setRequestHeader("Authorization","Bearer "+token);xhr.onload=()=>{if(xhr.status!==200)return reject("🤖 chatgpt.js >> Request failed. Cannot retrieve chat details.");const data=JSON.parse(xhr.responseText).items;if(data.length<=0)return reject("🤖 chatgpt.js >> Chat list is empty.");const detailsToReturn={};if(Number.isInteger(chatToGet)||chatToGet=="latest"||chatToGet=="active"&&!new RegExp("/"+re_chatID.source+"$").test(window.location.href)){chatToGet=Number.isInteger(chatToGet)?chatToGet:0;if(chatToGet>data.length){return reject("🤖 chatgpt.js >> Chat with index "+(chatToGet+1)+" is out of bounds. Only "+data.length+" chats exist!")}for(const detail of detailsToGet)detailsToReturn[detail]=data[chatToGet][detail];return resolve(detailsToReturn)}const chatIdentifier=chatToGet=="active"||new RegExp("^"+re_chatID.source+"$").test(chatToGet)?"id":"title";if(chatToGet=="active")chatToGet=re_chatID.exec(window.location.href)[0];let idx,chatFound;for(idx=0;idx<data.length;idx++){if(data[idx][chatIdentifier]==chatToGet){chatFound=true;break}}if(!chatFound)return reject("🤖 chatgpt.js >> No chat with "+chatIdentifier+" = "+chatToGet+" found.");for(const detail of detailsToGet)detailsToReturn[detail]=data[idx][detail];return resolve(detailsToReturn)};xhr.send()})};const getChatMsgs=token=>{return new Promise((resolve,reject)=>{const xhr=new XMLHttpRequest;getChatDetails(token,["id"]).then(chat=>{xhr.open("GET",`${endpoints.openAI.chat}/${chat.id}`,true);xhr.setRequestHeader("Content-Type","application/json");xhr.setRequestHeader("Authorization","Bearer "+token);xhr.onload=()=>{if(xhr.status!==200)return reject("🤖 chatgpt.js >> Request failed. Cannot retrieve chat messages.");const data=JSON.parse(xhr.responseText).mapping;const userMessages=[],chatGPTMessages=[],msgsToReturn=[];for(const key in data)if("message"in data[key]&&data[key].message.author.role=="user")userMessages.push({id:data[key].id,msg:data[key].message});userMessages.sort((a,b)=>a.msg.create_time-b.msg.create_time);if(parseInt(msgToGet,10)+1>userMessages.length)return reject("🤖 chatgpt.js >> Message/response with index "+(msgToGet+1)+" is out of bounds. Only "+userMessages.length+" messages/responses exist!");for(const userMessage of userMessages){let sub=[];for(const key in data){if("message"in data[key]&&data[key].message.author.role=="assistant"&&data[key].parent==userMessage.id){sub.push(data[key].message)}}sub.sort((a,b)=>a.create_time-b.create_time);sub=sub.map(x=>x.content.parts[0]);sub=sub.length===1?sub[0]:sub;chatGPTMessages.push(sub)}if(sender=="user")for(const userMessage in userMessages)msgsToReturn.push(userMessages[userMessage].msg.content.parts[0]);else if(sender=="chatgpt")for(const chatGPTMessage of chatGPTMessages)msgsToReturn.push(msgToGet=="latest"?chatGPTMessages[chatGPTMessages.length-1]:chatGPTMessage);else{let i=0;for(const message in userMessages){msgsToReturn.push({user:userMessages[message].msg.content.parts[0],chatgpt:msgToGet=="latest"?chatGPTMessages[i][chatGPTMessages[i].length-1]:chatGPTMessages[i]});i++}}return resolve(msgToGet=="all"?msgsToReturn:msgToGet=="latest"?msgsToReturn[msgsToReturn.length-1]:msgsToReturn[msgToGet])};xhr.send()})})};return new Promise(resolve=>{chatgpt.getAccessToken().then(token=>{if(!detailsToGet.includes("msg"))getChatDetails(token,detailsToGet).then(data=>{return resolve(data)});else getChatMsgs(token).then(messages=>{return resolve(messages)})})})},getChatInput:function(){return chatgpt.getChatBox().value},getContinueGeneratingButton:function(){for(const formButton of document.querySelectorAll("form button")){if(formButton.textContent.toLowerCase().includes("continue")){return formButton}}},getLastPrompt:function(){return chatgpt.getChatData("active","msg","user","latest")},getLastResponse:function(){return chatgpt.getChatData("active","msg","chatgpt","latest")},getNewChatLink:function(){for(const navLink of document.querySelectorAll('nav[aria-label="Chat history"] a')){if(/(new|clear) chat/i.test(navLink.text)){return navLink}}},getRegenerateButton:function(){for(const mainSVG of document.querySelectorAll("main svg")){if(mainSVG.querySelector('path[d*="M4.5 2.5C5.05228"]'))return mainSVG.parentNode.parentNode}},getResponse:function(){if(window.location.href.startsWith("https://chat.openai.com/c/"))return chatgpt.getResponseFromDOM.apply(null,arguments);else return chatgpt.getResponseFromAPI.apply(null,arguments)},getResponseFromAPI:function(chatToGet,responseToGet){return chatgpt.response.getFromAPI(chatToGet,responseToGet)},getResponseFromDOM:function(pos){return chatgpt.response.getFromDOM(pos)},getSendButton:function(){return document.querySelector('form button[class*="bottom"]')},getStopGeneratingButton:function(){for(const formButton of document.querySelectorAll("form button")){if(formButton.textContent.toLowerCase().includes("stop")){return formButton}}},getUserLanguage:function(){return navigator.languages[0]||navigator.language||navigator.browserLanguage||navigator.systemLanguage||navigator.userLanguage||""},history:{isLoaded:function(){return new Promise(resolve=>{const checkChatHistory=()=>{if(document.querySelector('nav[aria-label="Chat history"]'))resolve();else setTimeout(checkChatHistory,100)};checkChatHistory()})},activate:function(){this.isOff()?this.toggle():console.info("Chat history is already enabled!")},deactivate:function(){this.isOn()?this.toggle():console.info("Chat history is already disabled!")},isOn:function(){const navDivs=document.querySelectorAll('nav[aria-label="Chat history"] div'),offDiv=[...navDivs].find(div=>div.textContent.includes("Chat History is off"))||{};return offDiv.classList.toString().includes("invisible")},isOff:function(){return!this.isOn()},toggle:function(){for(const navBtn of document.querySelectorAll('nav[aria-label="Chat history"] button')){if(/chat history/i.test(navBtn.textContent)){navBtn.click();return}}}},instructions:{add:function(instruction,target){if(!instruction)return console.error("Please provide an instruction");if(typeof instruction!=="string")return console.error("Instruction must be a string");const validTargets=["user","chatgpt"];if(!target)return console.error("Please provide a valid target!");if(typeof target!=="string")return console.error("Target must be a string");target=target.toLowerCase();if(!validTargets.includes(target))return console.error(`Invalid target ${target}. Valid targets are [${validTargets}]`);instruction=`\n\n${instruction}`;return new Promise(resolve=>{chatgpt.getAccessToken().then(async token=>{const instructionsData=await this.fetchData();if(target=="user")instructionsData.about_user_message+=instruction;else if(target=="chatgpt")instructionsData.about_model_message+=instruction;await this.sendRequest("POST",token,instructionsData);return resolve()})})},clear:function(target){const validTargets=["user","chatgpt"];if(!target)return console.error("Please provide a valid target!");if(typeof target!=="string")return console.error("Target must be a string");target=target.toLowerCase();if(!validTargets.includes(target))return console.error(`Invalid target ${target}. Valid targets are [${validTargets}]`);return new Promise(resolve=>{chatgpt.getAccessToken().then(async token=>{const instructionsData=await this.fetchData();if(target=="user")instructionsData.about_user_message="";else if(target=="chatgpt")instructionsData.about_model_message="";await this.sendRequest("POST",token,instructionsData);return resolve()})})},fetchData:function(){return new Promise(resolve=>{chatgpt.getAccessToken().then(async token=>{return resolve(await this.sendRequest("GET",token))})})},sendRequest:function(method,token,body){for(let i=0;i<arguments.length-1;i++)if(typeof arguments[i]!=="string")return console.error(`Argument ${i+1} must be a string`);const validMethods=["POST","GET"];method=(method||"").trim().toUpperCase();if(!method||!validMethods.includes(method))return console.error(`Valid methods are ${validMethods}`);if(!token)return console.error("Please provide a valid access token!");if(body&&typeof body!=="object")return console.error(`Invalid body data type. Got ${typeof body}, expected object`);return new Promise((resolve,reject)=>{const xhr=new XMLHttpRequest;xhr.open(method,endpoints.openAI.instructions,true);xhr.setRequestHeader("Accept-Language","en-US");xhr.setRequestHeader("Authorization","Bearer "+token);if(method=="POST")xhr.setRequestHeader("Content-Type","application/json");xhr.onload=()=>{const responseData=JSON.parse(xhr.responseText);if(xhr.status===422)return reject("🤖 chatgpt.js >> Character limit exceeded. Custom instructions can have a maximum length of 1500 characters.");else if(xhr.status===403&&responseData.detail.reason=="content_policy")return reject("🤖 chatgpt.js >> "+responseData.detail.description);else if(xhr.status!==200)return reject("🤖 chatgpt.js >> Request failed. Cannot contact custom instructions endpoint.");console.info(`Custom instructions successfully contacted with method ${method}`);return resolve(responseData||{})};xhr.send(JSON.stringify(body)||"")})},turnOff:function(){return new Promise(resolve=>{chatgpt.getAccessToken().then(async token=>{const instructionsData=await this.fetchData();instructionsData.enabled=false;await this.sendRequest("POST",token,instructionsData);return resolve()})})},turnOn:function(){return new Promise(resolve=>{chatgpt.getAccessToken().then(async token=>{const instructionsData=await this.fetchData();instructionsData.enabled=true;await this.sendRequest("POST",token,instructionsData);return resolve()})})},toggle:function(){return new Promise(resolve=>{this.fetchData().then(async instructionsData=>{await(instructionsData.enabled?this.turnOff():this.turnOn());return resolve()})})}},isChromium:function(){return chatgpt.browser.isChromium()},isDarkMode:function(){return document.documentElement.classList.toString().includes("dark")},isFirefox:function(){return chatgpt.browser.isFirefox()},isFullScreen:function(){return chatgpt.browser.isFullScreen()},isIdle:function(){return new Promise(resolve=>{const intervalId=setInterval(()=>{if(chatgpt.getRegenerateButton()){clearInterval(intervalId);resolve()}},100)})},isLoaded:function(){return new Promise(resolve=>{const intervalId=setInterval(()=>{if(document.querySelector('nav button[id*="menu"]')){clearInterval(intervalId);setTimeout(()=>{resolve()},500)}},100)})},isLightMode:function(){return document.documentElement.classList.toString().includes("light")},isMobileDevice:function(){return chatgpt.browser.isMobile()},logout:function(){window.location.href="https://chat.openai.com/auth/logout"},menu:{elements:[],addedEvent:false,append:function(element,attrs={}){const validElements=["button","dropdown"];if(!element||typeof element!=="string")return console.error("🤖 chatgpt.js >> Please supply a valid string element name!");element=element.toLowerCase();if(!validElements.includes(element))return console.error(`🤖 chatgpt.js >> Invalid element! Valid elements are [${validElements}]`);const newElement=document.createElement(element=="dropdown"?"select":element=="button"?"a":element);newElement.id=Math.floor(chatgpt.randomFloat()*1e6)+Date.now();if(element=="button"){newElement.textContent=attrs?.label&&typeof attrs.label=="string"?attrs.label:"chatgpt.js button";const icon=document.createElement("img");icon.src=attrs?.icon&&typeof attrs.icon=="string"?attrs.icon:endpoints.assets+"/starters/chrome/extension/icons/icon128.png";icon.width=18;newElement.insertBefore(icon,newElement.firstChild);newElement.onclick=attrs?.onclick&&typeof attrs.onclick=="function"?attrs.onclick:function(){}}else if(element=="dropdown"){if(!attrs?.items||!Array.isArray(attrs.items)||!attrs.items.length)attrs.items=[{text:"🤖 chatgpt.js option",value:"chatgpt.js option value"}];if(!attrs.items.every(el=>typeof el=="object"))return console.error("'items' must be an array of objects!");newElement.style="background-color: #000; width: 100%; border: none;";attrs.items.forEach(item=>{const optionElement=document.createElement("option");optionElement.textContent=item?.text;optionElement.value=item?.value;newElement.add(optionElement)})}const addElementsToMenu=()=>{const optionButtons=document.querySelectorAll('a[role="menuitem"]');let cssClasses;for(let navLink of optionButtons)if(navLink.textContent=="Settings"){cssClasses=navLink.classList;break}const headlessNav=optionButtons[0].parentNode;chatgpt.menu.elements.forEach(element=>{element.setAttribute("class",cssClasses);if(!headlessNav.contains(element))try{headlessNav.insertBefore(element,headlessNav.firstChild)}catch(err){console.error(err)}})};this.elements.push(newElement);const menuBtn=document.querySelector('nav button[id*="headless"]');if(!this.addedEvent){menuBtn.addEventListener("click",()=>{setTimeout(addElementsToMenu,25)});this.addedEvent=true}return newElement.id},close:function(){const menuBtn=document.querySelector('nav [id*="menu-button"][aria-expanded="true"]');if(menuBtn)try{menuBtn.click()}catch(err){console.error("Error while closing the menu");throw new Error(err)}else{console.error("Menu already hidden!");throw new Error}},open:function(){const menuBtn=document.querySelector('nav [id*="menu-button"][aria-expanded="false"]');if(menuBtn)try{menuBtn.click()}catch(err){console.error("Error while closing the menu");throw new Error(err)}else{console.error("Menu already hidden!");throw new Error}}},minify:function(){chatgpt.code.minify()},notify:async function(msg,position,notifDuration,shadow){notifDuration=notifDuration?+notifDuration:1.75;const fadeDuration=.3,vpYoffset=23,vpXoffset=27;const notificationDiv=document.createElement("div");notificationDiv.id=Math.floor(chatgpt.randomFloat()*1e6)+Date.now();notificationDiv.classList.add("chatgpt-notif");notificationDiv.innerText=msg;document.body.append(notificationDiv);const closeBtn=document.createElement("div");closeBtn.title=cjsMessages?.tooltip_dismiss||"Dismiss";closeBtn.classList.add("notif-close-btn");const closeSVG=document.createElementNS("http://www.w3.org/2000/svg","svg");closeSVG.setAttribute("height","8px");closeSVG.setAttribute("viewBox","0 0 14 14");closeSVG.setAttribute("fill","none");closeSVG.style.height=closeSVG.style.width="8px";const closeSVGpath=document.createElementNS("http://www.w3.org/2000/svg","path");closeSVGpath.setAttribute("fill-rule","evenodd");closeSVGpath.setAttribute("clip-rule","evenodd");closeSVGpath.setAttribute("fill","white");closeSVGpath.setAttribute("d","M13.7071 1.70711C14.0976 1.31658 14.0976 0.683417 13.7071 0.292893C13.3166 -0.0976312 12.6834 -0.0976312 12.2929 0.292893L7 5.58579L1.70711 0.292893C1.31658 -0.0976312 0.683417 -0.0976312 0.292893 0.292893C-0.0976312 0.683417 -0.0976312 1.31658 0.292893 1.70711L5.58579 7L0.292893 12.2929C-0.0976312 12.6834 -0.0976312 13.3166 0.292893 13.7071C0.683417 14.0976 1.31658 14.0976 1.70711 13.7071L7 8.41421L12.2929 13.7071C12.6834 14.0976 13.3166 14.0976 13.7071 13.7071C14.0976 13.3166 14.0976 12.6834 13.7071 12.2929L8.41421 7L13.7071 1.70711Z");closeSVG.append(closeSVGpath);closeBtn.append(closeSVG);notificationDiv.append(closeBtn);notificationDiv.isTop=!position||!/low|bottom/i.test(position);notificationDiv.isRight=!position||!/left/i.test(position);notificationDiv.quadrant=(notificationDiv.isTop?"top":"bottom")+(notificationDiv.isRight?"Right":"Left");const thisUpdated=20231110;let notifStyle=document.querySelector("#chatgpt-notif-style");if(!notifStyle||parseInt(notifStyle.getAttribute("last-updated"),10)<thisUpdated){if(!notifStyle){notifStyle=document.createElement("style");notifStyle.id="chatgpt-notif-style";notifStyle.setAttribute("last-updated",thisUpdated.toString());document.head.append(notifStyle)}notifStyle.innerText=".chatgpt-notif {"+"background-color: black ; padding: 10px 13px 10px 18px ; border-radius: 11px ; border: 1px solid #f5f5f7 ;"+"opacity: 0 ; position: fixed ; z-index: 9999 ; font-size: 1.8rem ; color: white ;"+"-webkit-user-select: none ; -moz-user-select: none ; -ms-user-select: none ; user-select: none ;"+`transform: translateX(${!notificationDiv.isRight?"-":""}35px) ;`+(shadow?"box-shadow: -8px 13px 25px 0 "+(/\b(shadow|on)\b/gi.test(shadow)?"gray":shadow):"")+"}"+".notif-close-btn { cursor: pointer ; float: right ; position: relative ; right: -4px ; margin-left: -3px ;"+"display: grid }"+"@keyframes notif-zoom-fade-out { 0% { opacity: 1 ; transform: scale(1) }"+"15% { opacity: 0.35 ; transform: rotateX(-27deg) scale(1.05) }"+"45% { opacity: 0.05 ; transform: rotateX(-81deg) }"+"100% { opacity: 0 ; transform: rotateX(-180deg) scale(1.15) }}"}let notifyProps=JSON.parse(localStorage.notifyProps);notifyProps.queue[notificationDiv.quadrant].push(notificationDiv.id);localStorage.notifyProps=JSON.stringify(notifyProps);notificationDiv.style.top=notificationDiv.isTop?vpYoffset.toString()+"px":"";notificationDiv.style.bottom=!notificationDiv.isTop?vpYoffset.toString()+"px":"";notificationDiv.style.right=notificationDiv.isRight?vpXoffset.toString()+"px":"";notificationDiv.style.left=!notificationDiv.isRight?vpXoffset.toString()+"px":"";const thisQuadrantQueue=notifyProps.queue[notificationDiv.quadrant];if(thisQuadrantQueue.length>1){try{for(const divId of thisQuadrantQueue.slice(0,-1)){const oldDiv=document.getElementById(divId),offsetProp=oldDiv.style.top?"top":"bottom",vOffset=+/\d+/.exec(oldDiv.style[offsetProp])[0]+5+oldDiv.getBoundingClientRect().height;oldDiv.style[offsetProp]=`${vOffset}px`}}catch(err){}}setTimeout(()=>{notificationDiv.style.opacity=chatgpt.isDarkMode()?.8:.67;notificationDiv.style.transform="translateX(0)";notificationDiv.style.transition="transform 0.15s ease, opacity 0.15s ease"},10);const hideDelay=fadeDuration>notifDuration?0:notifDuration-fadeDuration;let dismissAudio,dismissAudioTID;if(isFFtmScript){let nthAudio;do{nthAudio=Math.floor(Math.random()*3)+1}while(nthAudio===notifyProps.lastNthAudio);notifyProps.lastNthAudio=nthAudio;localStorage.notifyProps=JSON.stringify(notifyProps);dismissAudio=new Audio;dismissAudio.src=endpoints.assets+"/media/audio/notifications/bubble-pop/"+`${nthAudio}-${notificationDiv.isRight?"right":"left"}.mp3`;dismissAudioTID=setTimeout(()=>dismissAudio.play().catch(()=>{}),hideDelay*1e3)}const dismissNotif=()=>{notificationDiv.style.animation=`notif-zoom-fade-out ${fadeDuration}s ease-out`;if(isFFtmScript)dismissAudio?.play().catch(()=>{});clearTimeout(dismissFuncTID);clearTimeout(dismissAudioTID)};const dismissFuncTID=setTimeout(dismissNotif,hideDelay*1e3);closeSVG.addEventListener("click",dismissNotif,{once:true});notificationDiv.addEventListener("animationend",()=>{notificationDiv.remove();notifyProps=JSON.parse(localStorage.notifyProps);notifyProps.queue[notificationDiv.quadrant].shift();localStorage.notifyProps=JSON.stringify(notifyProps)},{once:true})},obfuscate:function(){chatgpt.code.obfuscate()},printAllFunctions:function(){const colors={cmdPrompt:["#ff00ff","#00ff00"],objName:["#0611e9","#f9ee16"],methodName:["#005aff","#ffa500"],entryType:["#467e06","#b981f9"],srcMethod:["#ff0000","#00ffff"]};Object.keys(colors).forEach(element=>{colors[element][1]=colors[element][1]||"#"+(Number(`0x1${colors[element][0].replace(/^#/,"")}`)^16777215).toString(16).substring(1).toUpperCase()});const functionNames=[];for(const prop in this){if(typeof this[prop]=="function"){const chatgptIsParent=!Object.keys(this).find(obj=>Object.keys(this[obj]).includes(this[prop].name)),functionParent=chatgptIsParent?"chatgpt":"other";functionNames.push([functionParent,prop])}else if(typeof this[prop]=="object"){for(const nestedProp in this[prop]){if(typeof this[prop][nestedProp]=="function"){functionNames.push([prop,nestedProp])}}}}functionNames.sort((a,b)=>{return a[0].localeCompare(b[0])||a[1].localeCompare(b[1])});const isDarkMode=window.matchMedia("(prefers-color-scheme: dark)").matches,baseFontStyles="font-family: monospace ; font-size: larger ; ";console.log("\n%c🤖 chatgpt.js methods\n","font-family: sans-serif ; font-size: xxx-large ; font-weight: bold");for(const functionName of functionNames){const isChatGptObjParent=/chatgpt|other/.test(functionName[0]),rootFunction=functionName[0]=="chatgpt"?this[functionName[1]].name:functionName[0]!=="other"?functionName[0]+"."+functionName[1]:Object.keys(this).find(obj=>Object.keys(this[obj]).includes(this[functionName[1]].name))+"."+this[functionName[1]].name,isAsync=this[functionName[1]]?.constructor.name=="AsyncFunction";console.log("%c>> %c"+(isChatGptObjParent?"":`${functionName[0]}.%c`)+functionName[1]+" - https://chatgptjs.org/userguide/"+/(?:.*\.)?(.*)/.exec(rootFunction)[1].toLowerCase()+(isAsync?"-async":"")+"\n%c[%c"+(functionName[0]=="chatgpt"&&functionName[1]==this[functionName[1]].name||!isChatGptObjParent?"Function":"Alias of")+"%c: %c"+rootFunction+"%c]",baseFontStyles+"font-weight: bold ; color:"+colors.cmdPrompt[+isDarkMode],baseFontStyles+"font-weight: bold ;"+"color:"+colors[isChatGptObjParent?"methodName":"objName"][+isDarkMode],baseFontStyles+"font-weight: "+(isChatGptObjParent?"initial":"bold")+";"+"color:"+(isChatGptObjParent?"initial":colors.methodName[+isDarkMode]),baseFontStyles+"font-weight: "+(isChatGptObjParent?"bold":"initial")+";"+"color:"+(isChatGptObjParent?colors.entryType[+isDarkMode]:"initial"),baseFontStyles+"font-weight: "+(isChatGptObjParent?"initial":"bold")+";"+"color:"+(isChatGptObjParent?"initial":colors.entryType[+isDarkMode]),baseFontStyles+(isChatGptObjParent?"font-style: italic":"font-weight: initial")+";"+"color:"+(isChatGptObjParent?colors.srcMethod[+isDarkMode]:"initial"),baseFontStyles+(isChatGptObjParent?"font-weight: initial":"font-style: italic")+";"+"color:"+(isChatGptObjParent?"initial":colors.srcMethod[+isDarkMode]),isChatGptObjParent?"":baseFontStyles+"color: initial ; font-weight: initial")}},randomFloat:function(){const crypto=window.crypto||window.msCrypto;return crypto.getRandomValues(new Uint32Array(1))[0]/4294967295},refactor:function(){chatgpt.code.refactor()},regenerate:function(){for(const formButton of document.querySelectorAll("form button")){if(formButton.textContent.toLowerCase().includes("regenerate")){formButton.click();return}}},renderHTML:function(node){const reTags=/<([a-z\d]+)\b([^>]*)>([\s\S]*?)<\/\1>/g,reAttributes=/(\S+)=['"]?((?:.(?!['"]?\s+(?:\S+)=|[>']))+.)['"]?/g,nodeContent=node.childNodes;if(!this.renderHTML.preWrapSet){node.style.whiteSpace="pre-wrap";this.renderHTML.preWrapSet=true;setTimeout(()=>{this.renderHTML.preWrapSet=false},100)}for(const childNode of nodeContent){if(childNode.nodeType==Node.TEXT_NODE){const text=childNode.nodeValue,elems=Array.from(text.matchAll(reTags));if(elems.length>0){const elem=elems[0],[tagContent,tagName,tagAttributes,tagText]=elem.slice(0,4),tagNode=document.createElement(tagName);tagNode.textContent=tagText;const attributes=Array.from(tagAttributes.matchAll(reAttributes));attributes.forEach(attribute=>{const name=attribute[1],value=attribute[2].replace(/['"]/g,"");tagNode.setAttribute(name,value)});const renderedNode=this.renderHTML(tagNode);const beforeTextNode=document.createTextNode(text.substring(0,elem.index)),afterTextNode=document.createTextNode(text.substring(elem.index+tagContent.length));node.replaceChild(beforeTextNode,childNode);node.insertBefore(renderedNode,beforeTextNode.nextSibling);node.insertBefore(afterTextNode,renderedNode.nextSibling)}}else if(childNode.nodeType==Node.ELEMENT_NODE)this.renderHTML(childNode)}return node},resend:async function(){chatgpt.send(await chatgpt.getChatData("latest","msg","user","latest"))},response:{get:function(){if(window.location.href.startsWith("https://chat.openai.com/c/"))return this.getFromDOM.apply(null,arguments);else return this.getFromAPI.apply(null,arguments)},getFromAPI:function(chatToGet,responseToGet){chatToGet=chatToGet||"latest";responseToGet=responseToGet||"latest";return chatgpt.getChatData(chatToGet,"msg","chatgpt",responseToGet)},getFromDOM:function(pos){const responseDivs=document.querySelectorAll('div[data-testid*="conversation-turn"]:nth-child(odd)'),strPos=pos.toString().toLowerCase();let response="";if(responseDivs.length){if(/last|final/.test(strPos))response=responseDivs[responseDivs.length-1].textContent;else{const nthOfResponse=Number.isInteger(pos)?pos:/^\d+/.test(strPos)?/^\d+/.exec(strPos)[0]:(/^(?:1|one|fir)(?:st)?$/.test(strPos)?1:/^(?:2|tw(?:o|en|el(?:ve|f))|seco)(?:nd|t[yi])?(?:e?th)?$/.test(strPos)?2:/^(?:3|th(?:ree|ir?))(?:rd|teen|t[yi])?(?:e?th)?$/.test(strPos)?3:/^(?:4|fou?r)(?:teen|t[yi])?(?:e?th)?$/.test(strPos)?4:/^(?:5|fi(?:ve|f))(?:teen|t[yi])?(?:e?th)?$/.test(strPos)?5:/^(?:6|six)(?:teen|t[yi])?(?:e?th)?$/.test(strPos)?6:/^(?:7|seven)(?:teen|t[yi])?(?:e?th)?$/.test(strPos)?7:/^(?:8|eight?)(?:teen|t[yi])?(?:e?th)?$/.test(strPos)?8:/^(?:9|nine?)(?:teen|t[yi])?(?:e?th)?$/.test(strPos)?9:/^(?:10|ten)(?:th)?$/.test(strPos)?10:1)*(/(ty|ieth)$/.test(strPos)?10:1)+(/teen(th)?$/.test(strPos)?10:0);response=responseDivs[nthOfResponse-1].textContent}response=response.replace(/^ChatGPTChatGPT/,"")}return response},getLast:function(){return chatgpt.getChatData("active","msg","chatgpt","latest")},regenerate:function(){for(const formButton of document.querySelectorAll("form button")){if(formButton.textContent.toLowerCase().includes("regenerate")){formButton.click();return}}},stopGenerating:function(){for(const formButton of document.querySelectorAll("form button")){if(formButton.textContent.toLowerCase().includes("stop")){formButton.click();return}}}},reviewCode:function(){chatgpt.code.review()},scrollToBottom:function(){try{document.querySelector('button[class*="cursor"][class*="bottom"]').click()}catch(err){console.error("",err)}},send:function(msg,method=""){for(let i=0;i<arguments.length;i++)if(typeof arguments[i]!=="string")return console.error(`Argument ${i+1} must be a string!`);const textArea=document.querySelector("form textarea"),sendButton=document.querySelector('form button[class*="bottom"]');textArea.value=msg;textArea.dispatchEvent(new Event("input",{bubbles:true}));const delaySend=setInterval(()=>{if(!sendButton?.hasAttribute("disabled")){method.toLowerCase()=="click"||chatgpt.browser.isMobile()?sendButton.click():textArea.dispatchEvent(new KeyboardEvent("keydown",{keyCode:13,bubbles:true}));clearInterval(delaySend)}},25)},sendInNewChat:function(msg){if(typeof msg!=="string")return console.error("Message must be a string!");for(const navLink of document.querySelectorAll('nav[aria-label="Chat history"] a')){if(/(new|clear) chat/i.test(navLink.text)){navLink.click();break}}setTimeout(()=>{chatgpt.send(msg)},500)},settings:{scheme:{isDark:function(){return document.documentElement.classList.contains("dark")},isLight:function(){return document.documentElement.classList.contains("light")},set:function(value){const validValues=["dark","light","system"];if(!value)return console.error("Please specify a scheme value!");if(!validValues.includes(value))return console.error(`Invalid scheme value. Valid values are [${validValues}]`);let schemeToSet=value;if(value=="system")schemeToSet=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";localStorage.setItem("theme",value);console.info(`Scheme set to ${value.toUpperCase()}.`);if(!document.documentElement.classList.contains(schemeToSet))this.toggle()},toggle:function(){const[schemeToRemove,schemeToAdd]=this.isDark()?["dark","light"]:["light","dark"];document.documentElement.classList.replace(schemeToRemove,schemeToAdd);document.documentElement.style.colorScheme=schemeToAdd;localStorage.setItem("theme",schemeToAdd)}}},sentiment:async function(text,entity){for(let i=0;i<arguments.length;i++)if(typeof arguments[i]!=="string")return console.error(`Argument ${i+1} must be a string.`);chatgpt.send("What is the sentiment of the following text"+(entity?` towards the entity ${entity},`:"")+" from strongly negative to strongly positive?\n\n"+text);console.info("Analyzing sentiment...");await chatgpt.isIdle();return chatgpt.getChatData("active","msg","chatgpt","latest")},setScheme:function(value){chatgpt.settings.scheme.set(value)},shareChat:function(chatToGet,method="clipboard"){const validMethods=["alert","notify","notification","clipboard","copy"];if(!validMethods.includes(method))return console.error("Invalid method '"+method+"' passed. Valid methods are ["+validMethods+"].");const getChatNode=token=>{return new Promise((resolve,reject)=>{const xhr=new XMLHttpRequest;chatgpt.getChatData(chatToGet).then(chat=>{xhr.open("GET",`${endpoints.openAI.chat}/${chat.id}`,true);xhr.setRequestHeader("Content-Type","application/json");xhr.setRequestHeader("Authorization","Bearer "+token);xhr.onload=()=>{if(xhr.status!==200)return reject("🤖 chatgpt.js >> Request failed. Cannot retrieve chat node.");return resolve(JSON.parse(xhr.responseText).current_node)};xhr.send()})})};const makeChatToShare=(token,node)=>{return new Promise((resolve,reject)=>{const xhr=new XMLHttpRequest;chatgpt.getChatData(chatToGet).then(chat=>{xhr.open("POST",endpoints.openAI.share_create,true);xhr.setRequestHeader("Content-Type","application/json");xhr.setRequestHeader("Authorization","Bearer "+token);xhr.onload=()=>{if(xhr.status!==200)return reject("🤖 chatgpt.js >> Request failed. Cannot initialize share chat.");return resolve(JSON.parse(xhr.responseText))};xhr.send(JSON.stringify({current_node_id:node,conversation_id:chat.id,is_anonymous:true}))})})};const confirmShareChat=(token,data)=>{return new Promise((resolve,reject)=>{const xhr=new XMLHttpRequest;xhr.open("PATCH",`${endpoints.openAI.share}/${data.share_id}`,true);xhr.setRequestHeader("Content-Type","application/json");xhr.setRequestHeader("Authorization","Bearer "+token);xhr.onload=()=>{if(xhr.status!==200)return reject("🤖 chatgpt.js >> Request failed. Cannot share chat.");console.info(`Chat shared at '${data.share_url}'`);return resolve()};xhr.send(JSON.stringify({share_id:data.share_id,highlighted_message_id:data.highlighted_message_id,title:data.title,is_public:true,is_visible:data.is_visible,is_anonymous:data.is_anonymous}))})};return new Promise(resolve=>{chatgpt.getAccessToken().then(token=>{getChatNode(token).then(node=>{makeChatToShare(token,node).then(data=>{confirmShareChat(token,data).then(()=>{if(["copy","clipboard"].includes(method))navigator.clipboard.writeText(data.share_url);else chatgpt.alert("🚀 Share link created!",'"'+data.title+'" is available at: <a target="blank" rel="noopener" href="'+data.share_url+'" >'+data.share_url+"</a>",[function openLink(){window.open(data.share_url,"_blank","noopener")},function copyLink(){navigator.clipboard.writeText(data.share_url)}]);resolve(data.share_url)})})})})})},sidebar:{elements:[],observer:{},activateObserver:function(){const chatHistoryNav=document.querySelector('nav[aria-label="Chat history"]'),firstButton=chatHistoryNav.querySelector("a");if(chatgpt.history.isOff())try{firstButton.parentNode.nextElementSibling.style.display="none"}catch(err){}if(this.observer instanceof MutationObserver)try{this.observer.disconnect()}catch(e){}if(!this.elements.length)return console.error("🤖 chatgpt.js >> No elements to append!");let cssClasses;for(let navLink of document.querySelectorAll('nav[aria-label="Chat history"] a')){if(/.*chat/.exec(navLink.text)[0]){cssClasses=navLink.classList;navLink.parentNode.style.margin="2px 0";break}}this.elements.forEach(element=>{element.setAttribute("class",cssClasses);element.style.maxHeight=element.style.minHeight="44px";element.style.margin="2px 0"});const navBar=document.querySelector('nav[aria-label="Chat history"]');this.observer=new MutationObserver(mutations=>{mutations.forEach(mutation=>{if(mutation.type=="childList"&&mutation.addedNodes.length||mutation.type=="attributes"&&mutation.attributeName=="data-chatgptjs")this.elements.forEach(element=>{if(!navBar.contains(element))try{navBar.insertBefore(element,navBar.querySelector("a").parentNode)}catch(err){console.error(err)}})})});this.observer.observe(document.documentElement,{childList:true,subtree:true,attributes:true})},append:function(element,attrs={}){const validElements=["button","dropdown"];if(!element||typeof element!=="string")return console.error("🤖 chatgpt.js >> Please supply a valid string element name!");element=element.toLowerCase();if(!validElements.includes(element))return console.error(`🤖 chatgpt.js >> Invalid element! Valid elements are [${validElements}]`);const newElement=document.createElement(element=="dropdown"?"select":element);newElement.id=Math.floor(chatgpt.randomFloat()*1e6)+Date.now();if(element=="button"){newElement.textContent=attrs?.label&&typeof attrs.label=="string"?attrs.label:"chatgpt.js button";const icon=document.createElement("img");icon.src=attrs?.icon&&typeof attrs.icon=="string"?attrs.icon:endpoints.assets+"/starters/chrome/extension/icons/icon128.png";icon.width=18;newElement.insertBefore(icon,newElement.firstChild);newElement.onclick=attrs?.onclick&&typeof attrs.onclick=="function"?attrs.onclick:function(){}}else if(element=="dropdown"){if(!attrs?.items||!Array.isArray(attrs.items)||!attrs.items.length)attrs.items=[{text:"🤖 chatgpt.js option",value:"chatgpt.js option value"}];if(!attrs.items.every(el=>typeof el=="object"))return console.error("'items' must be an array of objects!");attrs.items.forEach(item=>{const optionElement=document.createElement("option");optionElement.textContent=item?.text;optionElement.value=item?.value;newElement.add(optionElement)})}if(element=="dropdown")newElement.style.backgroundColor="var(--gray-900, rgb(32, 33, 35))";this.elements.push(newElement);this.activateObserver();document.body.setAttribute("data-chatgptjs","observer-trigger");return newElement.id},hide:function(){this.isOn()?this.toggle():console.info("Sidebar already hidden!")},show:function(){this.isOff()?this.toggle():console.info("Sidebar already shown!")},isOff:function(){return!this.isOn()},isOn:function(){return chatgpt.browser.isMobile()?document.documentElement.style.overflow=="hidden":document.querySelector("#__next > div > div").style.visibility!="hidden"},toggle:function(){const isMobileDevice=chatgpt.browser.isMobile(),navBtnSelector=isMobileDevice?"#__next button":"main button",isToggleBtn=isMobileDevice?()=>true:btn=>Array.from(btn.querySelectorAll("*")).some(child=>child.style.transform.includes("translateY"));for(const btn of document.querySelectorAll(navBtnSelector))if(isToggleBtn(btn)){btn.click();return}}},startNewChat:function(){for(const navLink of document.querySelectorAll('nav[aria-label="Chat history"] a')){if(/(new|clear) chat/i.test(navLink.text)){navLink.click();return}}},stop:function(){for(const formButton of document.querySelectorAll("form button")){if(formButton.textContent.toLowerCase().includes("stop")){formButton.click();return}}},suggest:async function(ideaType,details){if(!ideaType)return console.error("ideaType (1st argument) not supplied"+"(e.g. 'gifts', 'names', 'recipes', etc.)");for(let i=0;i<arguments.length;i++)if(typeof arguments[i]!=="string")return console.error(`Argument ${i+1} must be a string.`);chatgpt.send("Suggest some names. "+(details||""));console.info(`Creating ${ideaType}...`);await chatgpt.isIdle();return chatgpt.getChatData("active","msg","chatgpt","latest")},speak:function(msg,options={}){const{voice=2,pitch=2,speed=1.1}=options;if(typeof msg!=="string")return console.error("Message must be a string!");for(let key in options){const value=options[key];if(typeof value!=="number"&&!/^\d+$/.test(value))return console.error(`Invalid ${key} index '${value}'. Must be a number!`)}try{const voices=speechSynthesis.getVoices(),utterance=new SpeechSynthesisUtterance;utterance.text=msg;utterance.voice=voices[voice];utterance.pitch=pitch;utterance.rate=speed;speechSynthesis.speak(utterance)}catch(err){console.error(err)}},summarize:async function(text){if(!text)return console.error("Text (1st) argument not supplied. Pass some text!");if(typeof text!=="string")return console.error("Text argument must be a string!");chatgpt.send("Summarize the following text:\n\n"+text);console.info("Summarizing text...");await chatgpt.isIdle();return chatgpt.getChatData("active","msg","chatgpt","latest")},toggleScheme:function(){chatgpt.settings.scheme.toggle()},translate:async function(text,outputLang){if(!text)return console.error("Text (1st) argument not supplied. Pass some text!");if(!outputLang)return console.error("outputLang (2nd) argument not supplied. Pass a language!");for(let i=0;i<arguments.length;i++)if(typeof arguments[i]!=="string")return console.error(`Argument ${i+1} must be a string!`);chatgpt.send("Translate the following text to "+outputLang+". Only reply with the translation.\n\n"+text);console.info("Translating text...");await chatgpt.isIdle();return chatgpt.getChatData("active","msg","chatgpt","latest")},unminify:function(){chatgpt.code.unminify()},uuidv4:function(){let d=(new Date).getTime();const uuid="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,c=>{const r=(d+window.crypto.getRandomValues(new Uint32Array(1))[0]/(Math.pow(2,32)-1)*16)%16|0;d=Math.floor(d/16);return(c=="x"?r:r&3|8).toString(16)});return uuid},writeCode:function(){chatgpt.code.write()}};chatgpt.scheme={...chatgpt.settings.scheme};const buttonActions=["click","get"],targetTypes=["button","link","div","response"];for(const buttonAction of buttonActions){chatgpt[buttonAction+"Button"]=function handleButton(buttonIdentifier){const button=/^[.#]/.test(buttonIdentifier)?document.querySelector(buttonIdentifier):/send/i.test(buttonIdentifier)?document.querySelector('form button[class*="bottom"]'):/scroll/i.test(buttonIdentifier)?document.querySelector('button[class*="cursor"]'):function(){for(const button of document.querySelectorAll("button")){if(button.textContent.toLowerCase().includes(buttonIdentifier.toLowerCase())){return button}}for(const navLink of document.querySelectorAll("nav a")){if(navLink.textContent.toLowerCase().includes(buttonIdentifier.toLowerCase())){return navLink}}}();if(buttonAction=="click"){button.click()}else{return button}}}const camelCaser=words=>{return words.map((word,index)=>index===0||word=="s"?word:word.charAt(0).toUpperCase()+word.slice(1)).join("")};for(const prop in chatgpt){for(const subAliases of functionAliases){if(subAliases.includes(prop)){if(subAliases.some(element=>element.includes("."))){const nestedFunction=subAliases.find(element=>element.includes(".")).split(".")[1];for(const nestAlias of subAliases){if(/^(\w+)/.exec(nestAlias)[1]!==prop){chatgpt[nestAlias]=chatgpt[prop][nestedFunction]}}}else{for(const dirAlias of subAliases){if(dirAlias!==prop){chatgpt[dirAlias]=chatgpt[prop]}}}}}do{var newFunctionsCreated=false;for(const funcName in chatgpt){if(typeof chatgpt[funcName]=="function"){const funcWords=funcName.split(/(?=[A-Zs])/);for(const funcWord of funcWords){const synonymValues=[].concat(...synonyms.filter(arr=>arr.includes(funcWord.toLowerCase())).map(arr=>arr.filter(synonym=>synonym!==funcWord.toLowerCase())));for(const synonym of synonymValues){const newFuncName=camelCaser(funcWords.map(word=>word==funcWord?synonym:word));if(!chatgpt[newFuncName]){chatgpt[newFuncName]=chatgpt[funcName];newFunctionsCreated=true}}}}}}while(newFunctionsCreated)}const consolePrefix="🤖 chatgpt.js >> ",ogError=console.error,ogInfo=console.info;console.error=(...args)=>{if(!args[0].startsWith(consolePrefix))ogError(consolePrefix+args[0],...args.slice(1));else ogError(...args)};console.info=msg=>{if(!msg.startsWith(consolePrefix))ogInfo(consolePrefix+msg);else ogInfo(msg)};try{window.chatgpt=chatgpt}catch(err){}try{module.exports=chatgpt}catch(err){}
package/docs/.nojekyll ADDED
File without changes
package/docs/CNAME ADDED
@@ -0,0 +1 @@
1
+ chatgpt.js.org
package/docs/README.md ADDED
@@ -0,0 +1,324 @@
1
+ <div id="repo-cover" align="center">
2
+
3
+ <div align="center">
4
+ <h6>
5
+ <a href="https://github.com/kudoai/chatgpt.js/tree/main/docs">
6
+ <picture>
7
+ <source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/KudoAI/chatgpt.js/main/media/images/icons/earth-americas-white-padded-icon17x15.svg">
8
+ <img src="https://raw.githubusercontent.com/KudoAI/chatgpt.js/main/media/images/icons/earth-americas-padded-icon17x15.svg">
9
+ </picture>
10
+ </a>
11
+ English |
12
+ <a href="zh-cn#readme">简体中文</a> |
13
+ <a href="zh-tw#readme">繁體中文</a> |
14
+ <a href="ja#readme">日本</a> |
15
+ <a href="ko#readme">한국인</a> |
16
+ <a href="hi#readme">हिंदी</a> |
17
+ <a href="np#readme">नेपाली</a> |
18
+ <a href="de#readme">Deutsch</a> |
19
+ <a href="es#readme">Español</a> |
20
+ <a href="fr#readme">Français</a> |
21
+ <a href="it#readme">Italiano</a> |
22
+ <a href="nl#readme">Nederlands</a> |
23
+ <a href="pt#readme">Português</a> |
24
+ <a href="vi#readme">Việt</a>
25
+ </h6>
26
+ </div>
27
+
28
+ <br>
29
+
30
+ <picture>
31
+ <source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/kudoai/chatgpt.js/main/media/images/logos/chatgpt.js/with-reflection/darkmode.png">
32
+ <img width=800 src="https://raw.githubusercontent.com/kudoai/chatgpt.js/main/media/images/logos/chatgpt.js/with-reflection/lightmode.png">
33
+ </picture>
34
+
35
+ ### 🤖 A powerful client-side JavaScript library for ChatGPT
36
+
37
+ </div>
38
+
39
+ <br>
40
+
41
+ <div id="shields" align="center">
42
+
43
+ [![](https://img.shields.io/github/stars/KudoAI/chatgpt.js?label=Stars&color=gold&logo=github&logoColor=white&labelColor=464646&style=for-the-badge)](https://github.com/KudoAI/chatgpt.js/stargazers)
44
+ [![](https://img.shields.io/badge/License-MIT-green.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge)](https://github.com/KudoAI/chatgpt.js/blob/main/LICENSE)
45
+ [![](https://img.shields.io/github/commit-activity/m/kudoai/chatgpt.js?label=Commits&logo=github&logoColor=white&labelColor=464646&style=for-the-badge)](https://github.com/kudoai/chatgpt.js/commits/main)
46
+ ![](https://img.shields.io/github/size/kudoai/chatgpt.js/dist/chatgpt-2.6.3.min.js?label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge)
47
+ [![](https://img.shields.io/codacy/grade/696917c8e5a949c49edb89ed2f43d5ba?label=Code+Quality&logo=codacy&logoColor=white&labelColor=464646&color=1acc6c&style=for-the-badge)](https://app.codacy.com/gh/KudoAI/chatgpt.js/commits?utm_source=chatgpt%2Ejs&utm_content=github_shield)
48
+ [![](https://img.shields.io/badge/Mentioned_in-Awesome-cca8c4?logo=awesomelists&logoColor=white&labelColor=464646&style=for-the-badge)](https://github.com/sindresorhus/awesome-chatgpt#javascript)
49
+ [![](https://img.shields.io/badge/Featured_on-Product_Hunt-ff6154?logo=producthunt&logoColor=white&labelColor=464646&style=for-the-badge)](https://www.producthunt.com/posts/chatgpt-js)
50
+ ![](https://img.shields.io/jsdelivr/gh/hm/kudoai/chatgpt.js?label=jsDelivr+Hits&logo=jsdelivr&logoColor=white&labelColor=464646&color=9146ff&style=for-the-badge)
51
+
52
+ </div>
53
+
54
+ <img height=8px width="100%" src="https://raw.githubusercontent.com/kudoai/chatgpt.js/main/docs/assets/separators/aqua.png">
55
+
56
+ <div id="intro">
57
+
58
+ ## 💡 About
59
+
60
+ </div>
61
+
62
+ <span style="color: white">chatgpt.js</span> is a <span style="color: white">powerful</span> JavaScript library that allows for <span style="color: white">super easy</span> interaction w/ the ChatGPT DOM.
63
+
64
+ - Feature-rich
65
+ - Object-oriented
66
+ - Easy-to-use
67
+ - Lightweight (yet optimally performant)
68
+
69
+ <img height=8px width="100%" src="https://raw.githubusercontent.com/kudoai/chatgpt.js/main/docs/assets/separators/aqua.png">
70
+
71
+ <div id="importing">
72
+
73
+ ## ⚡ Importing the library
74
+
75
+ </div>
76
+
77
+ ### ES6:
78
+
79
+ ```js
80
+ (async () => {
81
+ await import('https://code.chatgptjs.org/chatgpt-latest.min.js');
82
+ // Your code here...
83
+ })();
84
+ ```
85
+
86
+ ### ES5:
87
+
88
+ ```js
89
+ var xhr = new XMLHttpRequest();
90
+ xhr.open('GET', 'https://code.chatgptjs.org/chatgpt-latest.min.js');
91
+ xhr.onload = function () {
92
+ if (xhr.status === 200) {
93
+ var chatgptJS = document.createElement('script');
94
+ chatgptJS.textContent = xhr.responseText;
95
+ document.head.append(chatgptJS);
96
+ yourCode(); // runs your code
97
+ }
98
+ };
99
+ xhr.send();
100
+
101
+ function yourCode() {
102
+ // Your code here...
103
+ }
104
+ ```
105
+
106
+ ### <img style="margin: 0 2px -0.065rem 0" height=17 src="https://raw.githubusercontent.com/kudoai/chatgpt.js/main/starters/media/images/icons/tampermonkey-icon28.png"></picture><img style="margin: 0 2px -0.035rem 1px" height=17.5 src="https://raw.githubusercontent.com/kudoai/chatgpt.js/main/starters/media/images/icons/violentmonkey-icon100.png"> Greasemonkey:
107
+
108
+ > **Note** _To use a starter template: [kudoai/chatgpt.js-greasemonkey-starter](https://github.com/kudoai/chatgpt.js-greasemonkey-starter)_
109
+
110
+ Userscript repositories like Greasy Fork maintain a whitelist of pre-approved CDNs (such as commit-specific references from `cdn.jsdelivr.net`) so the import URL is substantially lengthier to preserve publishability to these sites:
111
+
112
+ ```js
113
+ ...
114
+ // @require https://cdn.jsdelivr.net/gh/kudoai/chatgpt.js@3ff1d910a62b989e02da86c8c4dd3ce14232216e/dist/chatgpt-2.6.3.min.js
115
+ // ==/UserScript==
116
+
117
+ // Your code here...
118
+ ```
119
+
120
+ If you don't plan on publishing to these repos, the simpler `https://code.chatgptjs.org/chatgpt-latest.min.js` can be used instead to import the latest minified release.
121
+
122
+ ### <img style="margin: 0 2px -1px 0" height=16 src="https://www.google.com/chrome/static/images/favicons/apple-icon-60x60.png"> Chrome:
123
+
124
+ > **Note** _To use a starter template: [kudoai/chatgpt.js-chrome-starter](https://github.com/kudoai/chatgpt.js-chrome-starter)_
125
+
126
+ Since Google does not allow remote code, importing chatgpt.js locally is required:
127
+
128
+ 1. Save https://raw.githubusercontent.com/kudoai/chatgpt.js/main/chatgpt.js to a subdirectory (`lib` in this example)
129
+
130
+ 2. Add ES6 export statement to end of `lib/chatgpt.js`
131
+ ```js
132
+ ...
133
+ export { chatgpt }
134
+ ```
135
+
136
+ 3. In project's (V3) `manifest.json`, add `lib/chatgpt.js` as a web accessible resource
137
+ ```json
138
+ "web_accessible_resources": [{
139
+ "matches": ["<all_urls>"],
140
+ "resources": ["lib/chatgpt.js"]
141
+ }],
142
+ ```
143
+
144
+ 4. In scripts that need `chatgpt.js` (foreground/background alike), import it like so:
145
+ ```js
146
+ (async () => {
147
+ const { chatgpt } = await import(chrome.runtime.getURL('lib/chatgpt.js'));
148
+ // Your code here...
149
+ })();
150
+ ```
151
+
152
+ <img height=8px width="100%" src="https://raw.githubusercontent.com/kudoai/chatgpt.js/main/docs/assets/separators/aqua.png">
153
+
154
+ <div id="usage">
155
+
156
+ ## 💻 Usage
157
+
158
+ </div>
159
+
160
+ **chatgpt.js** was written w/ ultra flexibility in mind.
161
+
162
+ For example:
163
+
164
+ ```js
165
+ chatgpt.getLastResponse();
166
+ chatgpt.getLastReply();
167
+ chatgpt.response.getLast();
168
+ chatgpt.get('reply', 'last');
169
+ ```
170
+
171
+ Each call equally fetches the last response. If you think it works, it probably will... so just type it!
172
+
173
+ If it didn't, check out the extended [userguide](https://github.com/kudoai/chatgpt.js/blob/main/docs/USERGUIDE.md), or simply submit an [issue](https://github.com/kudoai/chatgpt.js/issues) or [PR](https://github.com/kudoai/chatgpt.js/pulls) and it will be integrated, ezpz!
174
+
175
+ <img height=8px width="100%" src="https://raw.githubusercontent.com/kudoai/chatgpt.js/main/docs/assets/separators/aqua.png">
176
+
177
+ <div id="showcase">
178
+
179
+ ## 🤖 Made with chatgpt.js
180
+
181
+ </div>
182
+
183
+ https://github.com/KudoAI/chatgpt.js/assets/10906554/f53c740f-d5e0-49b6-ae02-3b3140b0f8a4
184
+
185
+ #
186
+
187
+ ### <picture><source media="(prefers-color-scheme: dark)" srcset="https://i.imgur.com/RduASbD.png"><img width=16 src="https://raw.githubusercontent.com/adamlui/chatgpt-addons/main/media/icons/openai-favicon64.png"></picture> [Autoclear ChatGPT History](https://autoclearchatgpt.com) <a href="https://github.com/awesome-scripts/awesome-userscripts#chatgpt" target="_blank" rel="noopener"><img src="https://awesome.re/mentioned-badge.svg" style="margin:0 0 -2px 5px"></a>
188
+
189
+ > Auto-clear your ChatGPT query history for maximum privacy.
190
+ <br>[Install](https://github.com/adamlui/autoclear-chatgpt-history#-installation) /
191
+ [Readme](https://github.com/adamlui/autoclear-chatgpt-history#readme) /
192
+ [Discuss](https://autoclearchatgpt.com/discuss)
193
+
194
+ ### <img width=16 src="https://i.imgur.com/1yjmK3W.png"> [Automatic ChatGPT DAN](https://github.com/madkarmaa/automatic-chatgpt-dan)
195
+
196
+ > Automatically send DAN prompts to ChatGPT.
197
+ <br>[Install](https://github.com/madkarmaa/automatic-chatgpt-dan#%EF%B8%8F-installation) /
198
+ [Readme](https://github.com/madkarmaa/automatic-chatgpt-dan#readme) /
199
+ [Discuss](https://github.com/madkarmaa/automatic-chatgpt-dan/issues)
200
+
201
+ ### <img src="https://media.bravegpt.com/images/icons/bravegpt/icon48.png" width=18> [BraveGPT](https://bravegpt.com) <a href="https://www.producthunt.com/posts/bravegpt?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-bravegpt" target="_blank" rel="noopener"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=385630&theme=light" style="width: 112px; height: 24px; margin:0 0 -4px 5px;" width="112" height="24" /></a>
202
+
203
+ > Display ChatGPT answers in Brave Search sidebar (powered by GPT-4!)
204
+ <br>[Install](https://github.bravegpt.com/#-installation) /
205
+ [Readme](https://github.bravegpt.com/#readme) /
206
+ [Discuss](https://github.bravegpt.com/discussions)
207
+
208
+ ### <picture><source media="(prefers-color-scheme: dark)" srcset="https://i.imgur.com/RduASbD.png"><img width=16 src="https://raw.githubusercontent.com/adamlui/chatgpt-userscripts/main/media/icons/openai-favicon64.png"></picture> [ChatGPT Auto-Continue ⏩](https://chatgptautocontinue.com) <a href="https://github.com/awesome-scripts/awesome-userscripts#chatgpt" target="_blank" rel="noopener"><img src="https://awesome.re/mentioned-badge.svg" style="margin:0 0 -3px 3px"></a>
209
+
210
+ > Automatically continue generating multiple ChatGPT responses.
211
+ <br>[Install](https://github.com/adamlui/chatgpt-auto-continue#-installation) /
212
+ [Readme](https://github.com/adamlui/chatgpt-auto-continue#readme) /
213
+ [Discuss](https://chatgptautocontinue.com/discuss)
214
+
215
+ ### <picture><source media="(prefers-color-scheme: dark)" srcset="https://i.imgur.com/RduASbD.png"><img width=16 src="https://raw.githubusercontent.com/adamlui/chatgpt-addons/main/media/icons/openai-favicon64.png"></picture> [ChatGPT Auto Refresh ↻](https://chatgptautorefresh.com) <a href="https://github.com/awesome-scripts/awesome-userscripts#chatgpt" target="_blank" rel="noopener"><img src="https://awesome.re/mentioned-badge.svg" style="margin:0 0 -2px 5px"></a>
216
+
217
+ > Keeps ChatGPT sessions fresh to eliminate network errors + Cloudflare checks.
218
+ <br>[Install](https://github.com/adamlui/chatgpt-auto-refresh#-installation) /
219
+ [Readme](https://github.com/adamlui/chatgpt-auto-refresh#readme) /
220
+ [Discuss](https://chatgptautorefresh.com/discuss)
221
+
222
+ ### <img src="https://media.ddgpt.com/images/icons/duckduckgpt/icon48.png" width=17> [DuckDuckGPT](https://duckduckgpt.com) <a href="https://www.producthunt.com/posts/duckduckgpt?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-duckduckgpt" target="_blank" rel="noopener"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=379261&theme=light" style="width: 112px; height: 24px; margin:0 0 -4px 5px;" width="112" height="24" /></a>
223
+
224
+ > Display ChatGPT answers in DuckDuckGo sidebar (powered by GPT-4!)
225
+ <br>[Install](https://github.duckduckgpt.com/#-installation) /
226
+ [Readme](https://github.duckduckgpt.com/#readme) /
227
+ [Discuss](https://github.duckduckgpt.com/discussions)
228
+
229
+ ### <picture><source media="(prefers-color-scheme: dark)" srcset="https://media.googlegpt.io/images/icons/googlegpt/white/icon32.png"><img width=17 src="https://media.googlegpt.io/images/icons/googlegpt/black/icon32.png"></picture> [GoogleGPT](https://googlegpt.kudoai.com)
230
+
231
+ > Display ChatGPT answers in Google Search sidebar (powered by GPT-4!)
232
+ <br>[Install](https://greasyfork.org/scripts/478597-googlegpt) /
233
+ [Readme](https://github.com/KudoAI/googlegpt#readme) /
234
+ [Discuss](https://github.com/KudoAI/googlegpt/discussions)
235
+
236
+ <p><br>
237
+
238
+ <a href="https://chatgptinfinity.com" target="_blank" rel="noopener">
239
+ <img width=555 src="https://raw.githubusercontent.com/adamlui/chatgpt-infinity/main/chrome/media/images/tiles/marquee-promo-tile-1400x560.png">
240
+ </a>
241
+
242
+ <p><br>
243
+
244
+ <a href="https://chatgptwidescreen.com" target="_blank" rel="noopener">
245
+ <img width=555 src="https://raw.githubusercontent.com/adamlui/chatgpt-widescreen/main/chrome/media/images/tiles/marquee-promo-tile-1400x560.png">
246
+ </a>
247
+
248
+ <p><br>
249
+
250
+ <p id="showcase-cta">
251
+ If you've made something w/ chatgpt.js you want to share, email <a href="mailto:showcase@chatgptjs.org">showcase@chatgptjs.org</a> or just open a <a href="https://github.com/kudoai/chatgpt.js/pulls" target="_blank" rel="noopener">pull request</a>!
252
+ </p>
253
+
254
+ <img height=8px width="100%" src="https://raw.githubusercontent.com/kudoai/chatgpt.js/main/docs/assets/separators/aqua.png">
255
+
256
+ <div id="contributors">
257
+
258
+ ## 🧠 Contributors
259
+
260
+ </div>
261
+
262
+ This library exists thanks to code, translations, issues & ideas from the following contributors:
263
+
264
+ <div align="center"><br>
265
+
266
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/10906554?first-contrib=2023.03.15&h=51&w=51&mask=circle&maxage=7d '@adamlui')](https://github.com/adamlui)
267
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/71683364?first-contrib=2023.03.16-get-functions&h=51&w=51&mask=circle&maxage=7d '@mefengl')](https://github.com/mefengl)
268
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/131989355?first-contrib=2023.04.30-doc-translations&h=51&w=51&mask=circle&maxage=7d '@Zin6969')](https://github.com/Zin6969)
269
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/30551844?first-contrib=2023.05.02-getlastresponse-bug-report&h=51&w=51&mask=circle&maxage=7d '@madruga8')](https://github.com/madruga8)
270
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/54934866?first-contrib=2023.05.01-clearchats-discard-fix&h=51&w=51&mask=circle&maxage=7d '@XiaoYingYo')](https://github.com/XiaoYingYo)
271
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/129722778?first-contrib=2023.05.24-css-readability&h=51&w=51&mask=circle&maxage=7d '@AliAlSarre')](https://github.com/AliAlSarre)
272
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/100418457?first-contrib=2023.06.02-send-function-bug-report&h=51&w=51&mask=circle&maxage=7d '@madkarmaa')](https://github.com/madkarmaa)
273
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/1170326?first-contrib=2023.06.10-html-parser-idea&h=51&w=51&mask=circle&maxage=7d '@wamoyo')](https://github.com/wamoyo)
274
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/33952?first-contrib=2023.06.10-html-parser-idea&h=51&w=51&mask=circle&maxage=7d '@meiraleal')](https://github.com/meiraleal)
275
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/22633385?first-contrib=2023.07.11-fix-ja-doc-md&h=51&w=51&mask=circle&maxage=7d '@eltociear')](https://github.com/eltociear)
276
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/72805486?first-contrib=2023.07.14-enhance-ko-docs&h=51&w=51&mask=circle&maxage=7d '@Rojojun')](https://github.com/Rojojun)
277
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/62183023?first-contrib=2023.07.24-fix-hi-doc&h=51&w=51&mask=circle&maxage=7d '@iamnishantgaharwar')](https://github.com/iamnishantgaharwar)
278
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/629429?first-contrib=2023.07.31-homepage-starry-bg&h=51&w=51&mask=circle&maxage=7d '@hakimel')](https://github.com/hakimel)
279
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/73983677?first-contrib=2023.08.23-fix-readme-typos&h=51&w=51&mask=circle&maxage=7d '@omahs')](https://github.com/omahs)
280
+ [![](https://images.weserv.nl/?url=https://i.imgur.com/DQVC7vj.jpg?first-contrib=2023.09.19-add-dmarc-policy&h=51&w=51&mask=circle&maxage=7d 'Najam Ul Arfeen')](https://www.linkedin.com/in/najam-ul-arfeen-khan/)
281
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/110587589?first-contrib=2023.10.13-translate-docs-to-nepali&h=51&w=51&mask=circle&maxage=7d '@iambijayd')](https://github.com/iambijayd)
282
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/4698976?first-contrib=2023.10.29-remove-outdated-mv2-preface-from-docs&h=51&w=51&mask=circle&maxage=7d '@abhinavm24')](https://github.com/abhinavm24)
283
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/77867745?first-contrib=2023.11.4-getchatdetails-bug-report&h=51&w=51&mask=circle&maxage=7d '@deyvisml')](https://github.com/deyvisml)
284
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/150537240?first-contrib=2023.11.15-regenerate-btn-changed-bug-email&h=51&w=51&mask=circle&maxage=7d '@philly88r')](https://github.com/philly88r)
285
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/9730392?first-contrib=2023.12.18-get-response-from-dom-request&h=51&w=51&mask=circle&maxage=7d '@thomasgauthier')](https://github.com/thomasgauthier)
286
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/42911524?first-contrib=2024.1.17-add-custom-gpt-support&h=51&w=51&mask=circle&maxage=7d '@pranav-bhatt')](https://github.com/pranav-bhatt)
287
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/in/29110&h=51&w=51&mask=circle&maxage=7d 'Dependabot')](https://github.com/dependabot)
288
+ [![](https://images.weserv.nl/?url=https://i.imgur.com/tNyIPmG.jpg?h=51&w=51&mask=circle&maxage=7d 'ChatGPT')](https://chat.openai.com)
289
+ [![](https://images.weserv.nl/?url=https://raw.githubusercontent.com/kudoai/chatgpt.js/main/media/images/icons/poe-icon128.svg?first-contrib=2023.07.27-getandshowreply-method&h=51&w=51&mask=circle&maxage=7d 'Poe')](https://poe.com)
290
+ [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/31427850?h=51&w=51&mask=circle&maxage=7d "@ImgBotApp")](https://github.com/ImgBotApp)
291
+
292
+ </div><br>
293
+
294
+ <img height=8px width="100%" src="https://raw.githubusercontent.com/kudoai/chatgpt.js/main/docs/assets/separators/aqua.png">
295
+
296
+ <div id="partners">
297
+
298
+ ## 🤝 Partners
299
+
300
+ </div>
301
+
302
+ **chatgpt.js** is funded in part by:
303
+
304
+ <div id="partners-collage" align="center">
305
+
306
+ <picture>
307
+ <source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/kudoai/chatgpt.js/main/media/images/logos/partners/collage/white.png">
308
+ <img width=888 src="https://raw.githubusercontent.com/kudoai/chatgpt.js/main/media/images/logos/partners/collage/black.png">
309
+ </picture>
310
+
311
+ </div>
312
+
313
+ <br>
314
+
315
+ <img height=8px width="100%" src="https://raw.githubusercontent.com/kudoai/chatgpt.js/main/docs/assets/separators/aqua.png">
316
+
317
+ <div align="center">
318
+
319
+ **[Releases](https://github.com/kudoai/chatgpt.js/tree/main/dist)** /
320
+ [Userguide](https://github.com/kudoai/chatgpt.js/blob/main/docs/USERGUIDE.md) /
321
+ [Discuss](https://github.com/kudoai/chatgpt.js/discussions) /
322
+ <a href="#">Back to top ↑</a>
323
+
324
+ </div>
@@ -0,0 +1,25 @@
1
+ <div align="center">
2
+ <h6>
3
+ <a href="./"><img height=15 style="margin: 0 3px -2px" src="https://raw.githubusercontent.com/kudoai/chatgpt.js/6fa1659feadaf70853996dc7d7f6e1ab5a1e6301/media/images/icons/earth-americas.svg"></a>
4
+ English |
5
+ <a href="zh-cn/SECURITY.md">简体中文</a> |
6
+ <a href="zh-tw/SECURITY.md">繁體中文</a> |
7
+ <a href="ja/SECURITY.md">日本</a> |
8
+ <a href="ko/SECURITY.md">한국인</a> |
9
+ <a href="hi/SECURITY.md">हिंदी</a> |
10
+ <a href="np/SECURITY.md">नेपाली</a> |
11
+ <a href="de/SECURITY.md">Deutsch</a> |
12
+ <a href="es/SECURITY.md">Español</a> |
13
+ <a href="fr/SECURITY.md">Français</a> |
14
+ <a href="it/SECURITY.md">Italiano</a> |
15
+ <a href="nl/SECURITY.md">Nederlands</a> |
16
+ <a href="pt/SECURITY.md">Português</a> |
17
+ <a href="vi/SECURITY.md">Việt</a>
18
+ </h6>
19
+ </div>
20
+
21
+ # Security Policy
22
+
23
+ If you find a vulnerability, please open a [draft security advisory](https://github.com/kudoai/chatgpt.js/security/advisories/new).
24
+
25
+ Pull requests are also welcome, but for safety reasons, send an email to security@chatgptjs.org and wait for a response before making it public.