@kudoai/chatgpt.js 3.0.2 → 3.0.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.
package/README.md CHANGED
@@ -46,7 +46,7 @@
46
46
  [![](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.md)
47
47
  [![](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)
48
48
  ![](https://img.shields.io/badge/Clones-326/month-869da0?logo=github&logoColor=white&labelColor=464646&style=for-the-badge)
49
- [![](https://img.shields.io/github/size/KudoAI/chatgpt.js/dist/chatgpt.min.js?branch=v3.0.2&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge)](https://github.com/KudoAI/chatgpt.js/tree/v3.0.2/dist/chatgpt.min.js)
49
+ [![](https://img.shields.io/github/size/KudoAI/chatgpt.js/dist/chatgpt.min.js?branch=v3.0.3&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge)](https://github.com/KudoAI/chatgpt.js/tree/v3.0.3/dist/chatgpt.min.js)
50
50
  [![](https://img.shields.io/codefactor/grade/github/kudoai/chatgpt.js?label=Code+Quality&logo=codefactor&logoColor=white&labelColor=464646&color=1acc6c&style=for-the-badge)](https://www.codefactor.io/repository/github/kudoai/chatgpt.js)
51
51
  [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dkudoai_chatgpt.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold)](https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=kudoai_chatgpt.js)
52
52
  [![](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)
@@ -84,7 +84,7 @@
84
84
 
85
85
  ```js
86
86
  (async () => {
87
- await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.2/dist/chatgpt.min.js');
87
+ await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.3/dist/chatgpt.min.js');
88
88
  // Your code here...
89
89
  })();
90
90
  ```
@@ -93,7 +93,7 @@
93
93
 
94
94
  ```js
95
95
  var xhr = new XMLHttpRequest();
96
- xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.2/dist/chatgpt.min.js');
96
+ xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.3/dist/chatgpt.min.js');
97
97
  xhr.onload = function () {
98
98
  if (xhr.status === 200) {
99
99
  var chatgptJS = document.createElement('script');
@@ -115,7 +115,7 @@ function yourCode() {
115
115
 
116
116
  ```js
117
117
  ...
118
- // @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.2/dist/chatgpt.min.js
118
+ // @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.3/dist/chatgpt.min.js
119
119
  // ==/UserScript==
120
120
 
121
121
  // Your code here...
@@ -190,7 +190,7 @@ chatgpt.get('reply', 'last');
190
190
 
191
191
  Each call equally fetches the last response. If you think it works, it probably will... so just type it!
192
192
 
193
- If it didn't, check out the extended [userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.0.2/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!
193
+ If it didn't, check out the extended [userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.0.3/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!
194
194
 
195
195
  <img height=8px width="100%" src="https://media.chatgptjs.org/images/separators/gradient-aqua.png?78210a7">
196
196
 
@@ -327,7 +327,6 @@ This library exists thanks to code, translations, issues & ideas from the follow
327
327
  [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/50076933?first-contrib=2024.6.22-code.isidle-request&h=47&w=47&mask=circle&maxage=7d "@grayfallstown")](https://github.com/grayfallstown)
328
328
  [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/155944537?first-contrib=2024.8.27-sidebar-update-testing&h=47&w=47&mask=circle&maxage=7d "@svan-b")](https://github.com/svan-b)
329
329
  [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/74002352?first-contrib=2024.8.28-sidebar-update-testing&h=47&w=47&mask=circle&maxage=7d "@Jeff-Zzh")](https://github.com/Jeff-Zzh)
330
-
331
330
  [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/in/29110&h=47&w=47&mask=circle&maxage=7d "Dependabot")](https://github.com/dependabot)
332
331
  <a href="https://chatgpt.com"><picture><source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://images.weserv.nl/?url=https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@main/media/images/icons/platforms/chatgpt/black-on-white/icon189.png?h=46&w=46&mask=circle&maxage=7d"><img src="https://images.weserv.nl/?url=https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@main/media/images/icons/platforms/chatgpt/white-on-black/icon189.png?h=46&w=46&mask=circle&maxage=7d" title="ChatGPT"></picture></a>
333
332
  <a href="https://poe.com"><picture><source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://images.weserv.nl/?url=https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@main/media/images/icons/platforms/poe/w-purple-blue-stripes/black-on-white/icon175.png?h=46&w=46&mask=circle&maxage=7d"><img src="https://images.weserv.nl/?url=https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@main/media/images/icons/platforms/poe/w-purple-blue-stripes/white-on-black/icon175.png?h=46&w=46&mask=circle&maxage=7d" title="Poe"></picture></a>
@@ -361,7 +360,7 @@ This library exists thanks to code, translations, issues & ideas from the follow
361
360
  <div align="center">
362
361
 
363
362
  **[Releases](https://github.com/KudoAI/chatgpt.js/releases)** /
364
- [Userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.0.2/docs/USERGUIDE.md) /
363
+ [Userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.0.3/docs/USERGUIDE.md) /
365
364
  [Discuss](https://github.com/KudoAI/chatgpt.js/discussions) /
366
365
  <a href="#--------------------------------------------------------------------------------english---------简体中文---------繁體中文---------日本---------한국인---------हिंदी---------नेपाली---------deutsch---------español---------français---------italiano---------nederlands---------português---------việt----">Back to top ↑</a>
367
366
 
package/chatgpt.js CHANGED
@@ -282,7 +282,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
282
282
  return modalContainer.id; // if assignment used
283
283
  },
284
284
 
285
- askAndGetReply: async function(query) {
285
+ async askAndGetReply(query) {
286
286
  chatgpt.send(query); await chatgpt.isIdle();
287
287
  return chatgpt.getChatData('active', 'msg', 'chatgpt', 'latest');
288
288
  },
@@ -379,7 +379,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
379
379
  return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); }
380
380
  },
381
381
 
382
- clearChats: async function() { // back-end method
382
+ async clearChats() { // back-end method
383
383
  return new Promise((resolve, reject) => {
384
384
  chatgpt.getAccessToken().then(token => {
385
385
  const xhr = new XMLHttpRequest();
@@ -398,7 +398,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
398
398
  code: {
399
399
  // Tip: Use template literals for easier passing of code arguments. Ensure backticks and `$`s are escaped (using `\`)
400
400
 
401
- execute: async function(code) {
401
+ async execute(code) {
402
402
  if (!code) return console.error('Code argument not supplied. Pass some code!');
403
403
  if (typeof code !== 'string') return console.error('Code argument must be a string!');
404
404
  chatgpt.send('Display the output as if you were terminal:\n\n' + code);
@@ -412,7 +412,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
412
412
  return codeBlocks ? codeBlocks[codeBlocks.length - 1] : msg;
413
413
  },
414
414
 
415
- isIdle: async function() {
415
+ async isIdle() {
416
416
  await new Promise(resolve => { // when in conversation page
417
417
  (function checkConvoPage() {
418
418
  document.querySelector('div[data-message-author-role]') ? resolve(true)
@@ -440,7 +440,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
440
440
  ]);
441
441
  },
442
442
 
443
- minify: async function(code) {
443
+ async minify(code) {
444
444
  if (!code) return console.error('Code argument not supplied. Pass some code!');
445
445
  if (typeof code !== 'string') return console.error('Code argument must be a string!');
446
446
  chatgpt.send('Minify the following code:\n\n' + code);
@@ -449,7 +449,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
449
449
  return chatgpt.code.extract(await chatgpt.getChatData('active', 'msg', 'chatgpt', 'latest'));
450
450
  },
451
451
 
452
- obfuscate: async function(code) {
452
+ async obfuscate(code) {
453
453
  if (!code) return console.error('Code argument not supplied. Pass some code!');
454
454
  if (typeof code !== 'string') return console.error('Code argument must be a string!');
455
455
  chatgpt.send('Obfuscate the following code:\n\n' + code);
@@ -458,7 +458,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
458
458
  return chatgpt.code.extract(await chatgpt.getChatData('active', 'msg', 'chatgpt', 'latest'));
459
459
  },
460
460
 
461
- refactor: async function(code, objective) {
461
+ async refactor(code, objective) {
462
462
  if (!code) return console.error('Code (1st) argument not supplied. Pass some code!');
463
463
  for (let i = 0; i < arguments.length; i++) if (typeof arguments[i] !== 'string')
464
464
  return console.error(`Argument ${ i + 1 } must be a string.`);
@@ -468,7 +468,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
468
468
  return chatgpt.code.extract(await chatgpt.getChatData('active', 'msg', 'chatgpt', 'latest'));
469
469
  },
470
470
 
471
- review: async function(code) {
471
+ async review(code) {
472
472
  if (!code) return console.error('Code argument not supplied. Pass some code!');
473
473
  if (typeof code !== 'string') return console.error('Code argument must be a string!');
474
474
  chatgpt.send('Review the following code for me:\n\n' + code);
@@ -477,7 +477,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
477
477
  return chatgpt.getChatData('active', 'msg', 'chatgpt', 'latest');
478
478
  },
479
479
 
480
- unminify: async function(code) {
480
+ async unminify(code) {
481
481
  if (!code) return console.error('Code argument not supplied. Pass some code!');
482
482
  if (typeof code !== 'string') return console.error('Code argument must be a string!');
483
483
  chatgpt.send('Unminify the following code.:\n\n' + code);
@@ -486,7 +486,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
486
486
  return chatgpt.code.extract(await chatgpt.getChatData('active', 'msg', 'chatgpt', 'latest'));
487
487
  },
488
488
 
489
- write: async function(prompt, outputLang) {
489
+ async write(prompt, outputLang) {
490
490
  if (!prompt) return console.error('Prompt (1st) argument not supplied. Pass a prompt!');
491
491
  if (!outputLang) return console.error('outputLang (2nd) argument not supplied. Pass a language!');
492
492
  for (let i = 0; i < arguments.length; i++) if (typeof arguments[i] !== 'string')
@@ -500,7 +500,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
500
500
 
501
501
  continue() { chatgpt.response.continue(); },
502
502
 
503
- detectLanguage: async function(text) {
503
+ async detectLanguage(text) {
504
504
  if (!text) return console.error('Text argument not supplied. Pass some text!');
505
505
  if (typeof text !== 'string') return console.error('Text argument must be a string!');
506
506
  chatgpt.send('Detect the language of the following text:\n\n' + text
@@ -512,7 +512,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
512
512
 
513
513
  executeCode() { chatgpt.code.execute(); },
514
514
 
515
- exportChat: async function(chatToGet, format) {
515
+ async exportChat(chatToGet, format) {
516
516
  // chatToGet = 'active' (default) | 'latest' | index|title|id of chat to get
517
517
  // format = 'html' (default) | 'md' | 'pdf' | 'text'
518
518
 
@@ -1171,7 +1171,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
1171
1171
 
1172
1172
  minify() { chatgpt.code.minify(); },
1173
1173
 
1174
- notify: async function(msg, position, notifDuration, shadow) {
1174
+ async notify(msg, position, notifDuration, shadow) {
1175
1175
  notifDuration = notifDuration ? +notifDuration : 1.75; // sec duration to maintain notification visibility
1176
1176
  const fadeDuration = 0.35, // sec duration of fade-out
1177
1177
  vpYoffset = 23, vpXoffset = 27; // px offset from viewport border
@@ -1409,7 +1409,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
1409
1409
  return node; // if assignment used
1410
1410
  },
1411
1411
 
1412
- resend: async function() { chatgpt.send(await chatgpt.getChatData('latest', 'msg', 'user', 'latest')); },
1412
+ async resend() { chatgpt.send(await chatgpt.getChatData('latest', 'msg', 'user', 'latest')); },
1413
1413
 
1414
1414
  response: {
1415
1415
  continue() { try { chatgpt.getContinueBtn().click(); } catch (err) { console.error(err.message); }},
@@ -1481,17 +1481,16 @@ const chatgpt = { // eslint-disable-line no-redeclare
1481
1481
  send(msg, method='') {
1482
1482
  for (let i = 0; i < arguments.length; i++) if (typeof arguments[i] !== 'string')
1483
1483
  return console.error(`Argument ${ i + 1 } must be a string!`);
1484
- const textArea = document.querySelector('form textarea'),
1485
- sendBtn = chatgpt.getSendButton();
1484
+ const textArea = document.querySelector('form textarea');
1486
1485
  textArea.value = msg;
1487
1486
  textArea.dispatchEvent(new Event('input', { bubbles: true })); // enable send button
1488
-
1489
1487
  setTimeout(function delaySend() {
1488
+ const sendBtn = chatgpt.getSendButton();
1490
1489
  if (!sendBtn?.hasAttribute('disabled')) { // send msg
1491
1490
  method.toLowerCase() == 'click' || chatgpt.browser.isMobile() ? sendBtn.click()
1492
- : textArea.dispatchEvent(new KeyboardEvent('keydown', { keyCode: 13, bubbles: true }));
1493
- } else setTimeout(delaySend, 25);
1494
- }, 25);
1491
+ : textArea.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }));
1492
+ } else setTimeout(delaySend, 222);
1493
+ }, 222);
1495
1494
  },
1496
1495
 
1497
1496
  sendInNewChat(msg) {
@@ -1531,7 +1530,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
1531
1530
  }
1532
1531
  },
1533
1532
 
1534
- sentiment: async function(text, entity) {
1533
+ async sentiment(text, entity) {
1535
1534
  for (let i = 0; i < arguments.length; i++) if (typeof arguments[i] !== 'string')
1536
1535
  return console.error(`Argument ${ i + 1 } must be a string.`);
1537
1536
  chatgpt.send('What is the sentiment of the following text'
@@ -1755,7 +1754,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
1755
1754
  if (isToggleBtn(btn)) { btn.click(); return; }
1756
1755
  },
1757
1756
 
1758
- isLoaded: async function() {
1757
+ async isLoaded() {
1759
1758
  await chatgpt.isLoaded();
1760
1759
  return Promise.race([
1761
1760
  new Promise(resolve => {
@@ -1771,7 +1770,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
1771
1770
  startNewChat() { try { chatgpt.getNewChatBtn().click(); } catch (err) { console.error(err.message); }},
1772
1771
  stop() { chatgpt.response.stopGenerating(); },
1773
1772
 
1774
- suggest: async function(ideaType, details) {
1773
+ async suggest(ideaType, details) {
1775
1774
  if (!ideaType) return console.error('ideaType (1st argument) not supplied'
1776
1775
  + '(e.g. \'gifts\', \'names\', \'recipes\', etc.)');
1777
1776
  for (let i = 0; i < arguments.length; i++) if (typeof arguments[i] !== 'string')
@@ -1809,7 +1808,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
1809
1808
  } catch (err) { console.error( err); }
1810
1809
  },
1811
1810
 
1812
- summarize: async function(text) {
1811
+ async summarize(text) {
1813
1812
  if (!text) return console.error('Text (1st) argument not supplied. Pass some text!');
1814
1813
  if (typeof text !== 'string') return console.error('Text argument must be a string!');
1815
1814
  chatgpt.send('Summarize the following text:\n\n' + text);
@@ -1820,7 +1819,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
1820
1819
 
1821
1820
  toggleScheme() { chatgpt.settings.scheme.toggle(); },
1822
1821
 
1823
- translate: async function(text, outputLang) {
1822
+ async translate(text, outputLang) {
1824
1823
  if (!text) return console.error('Text (1st) argument not supplied. Pass some text!');
1825
1824
  if (!outputLang) return console.error('outputLang (2nd) argument not supplied. Pass a language!');
1826
1825
  for (let i = 0; i < arguments.length; i++) if (typeof arguments[i] !== 'string')
@@ -1,4 +1,4 @@
1
- localStorage.alertQueue=JSON.stringify([]),localStorage.notifyProps=JSON.stringify({queue:{topRight:[],bottomRight:[],bottomLeft:[],topLeft:[]}});const x={openAIaccessToken:{},endpoints:{assets:"https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@da5d03f07129ba9bbce1dc7f352457c29e1df587",openAI:{session:"https://chatgpt.com/api/auth/session",chats:"https://chatgpt.com/backend-api/conversations",chat:"https://chatgpt.com/backend-api/conversation",share_create:"https://chatgpt.com/backend-api/share/create",share:"https://chatgpt.com/backend-api/share",instructions:"https://chatgpt.com/backend-api/user_system_messages"}},actAs:function(a){return new Promise((o,r)=>{const s=new XMLHttpRequest;s.open("GET","https://raw.githubusercontent.com/KudoAI/chat-prompts/main/dist/personas.min.json",!0),s.send(),s.onload=()=>{if(200!==s.status)return r("🤖 chatgpt.js >> Request failed. Cannot retrieve prompts data.");var e=JSON.parse(s.responseText).personas;if(a){var t=e.find(e=>e.title.toLowerCase()==a.toLowerCase());if(!t)return r(`🤖 chatgpt.js >> Persona '${a}' was not found!`);x.send(t.prompt,"click"),console.info(`Loading ${a} persona...`),x.isIdle().then(()=>{console.info("Persona activated!")})}else{console.log("\n%c🤖 chatgpt.js personas\n","font-family: sans-serif ; font-size: xxx-large ; font-weight: bold");for(const n of e)console.log("%c"+n.title,"font-family: monospace ; font-size: larger ;")}return o()}})},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(e,t,n,o,r){const s=x.isDarkMode()?"dark":"light",a=x.browser.isMobile(),i=document.createElement("div"),c=(i.id=Math.floor(1e6*x.randomFloat())+Date.now(),i.classList.add("chatgpt-modal"),document.createElement("div")),l=document.createElement("h2"),u=document.createElement("p");var d=20231203;let g=document.querySelector("#chatgpt-modal-style");(!g||parseInt(g.getAttribute("last-updated"),10)<d)&&(g||((g=document.createElement("style")).id="chatgpt-modal-style",g.setAttribute("last-updated",d.toString()),document.head.append(g)),g.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: ${"dark"==s?"black":"white"} ;`+("dark"!=s?"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: ${"dark"==s?"#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 ;"+(a?"flex-direction: column-reverse":"")+"}.chatgpt-modal button {"+`margin-left: ${a?0:10}px ; padding: ${a?15:4}px 18px ; border-radius: 15px ;`+(a?"margin-top: 5px ; margin-bottom: 3px ;":"")+`border: 1px solid ${"dark"==s?"white":"black"}}`+".primary-modal-btn {"+`border: 1px solid ${"dark"==s?"white":"black"} ;`+`background: ${"dark"==s?"white":"black"} ;`+`color: ${"dark"==s?"black":"white"}}`+".chatgpt-modal button:hover { color: #3d5d71 ; border-color: #6d9cb9 ;background-color: "+("dark"==s?"#00cfff":"#9cdaff")+";box-shadow: 2px 1px "+("dark"==s?"54px #00cfff":"30px #9cdaff")+"}.modal-close-btn {cursor: pointer ; width: 29px ; height: 29px ; border-radius: 17px ;float: right ; position: relative ; right: -6px ; top: -5px }.modal-close-btn svg { margin: 10px }"+`.modal-close-btn:hover { background-color: #f2f2f2${"dark"==s?"00":""}}`+".chatgpt-modal .checkbox-group { display: flex ; margin-top: -18px }.chatgpt-modal .checkbox-group label {font-size: .7rem ; margin: -.04rem 0 0px .3rem ;"+`color: ${"dark"==s?"#e1e1e1":"#1e1e1e"}}`+'.chatgpt-modal input[type="checkbox"] { transform: scale(0.7) ;'+`border: 1px solid ${"dark"==s?"white":"black"}}`+'.chatgpt-modal input[type="checkbox"]:checked {'+`border: 1px solid ${"dark"==s?"white":"black"} ;`+'background-color: black ; position: inherit }.chatgpt-modal input[type="checkbox"]:focus { outline: none ; box-shadow: none }'),l.innerText=e||"",u.innerText=t||"",x.renderHTML(u);const p=document.createElement("div");p.classList.add("modal-buttons"),n&&(n=Array.isArray(n)?n:[n]).forEach(e=>{var t=document.createElement("button");t.textContent=e.name.replace(/[_-]\w/g,e=>e.slice(1).toUpperCase()).replace(/([A-Z])/g," $1").replace(/^\w/,e=>e.toUpperCase()),t.addEventListener("click",()=>{v(),e()}),p.insertBefore(t,p.firstChild)});d=document.createElement("button"),d.textContent=n?"Dismiss":"OK",p.insertBefore(d,p.firstChild),p.lastChild.classList.add("primary-modal-btn"),e=document.createElement("div");if(o){e.classList.add("checkbox-group");const w=o,b=document.createElement("input");b.type="checkbox",b.addEventListener("change",w);t=document.createElement("label");t.addEventListener("click",()=>{b.checked=!b.checked,w()}),t.textContent=w.name.charAt(0).toUpperCase()+w.name.slice(1).replace(/([A-Z])/g,(e,t)=>" "+t.toLowerCase()).replace(/\b(\w+)nt\b/gi,"$1n't").trim(),e.append(b),e.append(t)}n=document.createElement("div"),n.title="Close",n.classList.add("modal-close-btn"),o=document.createElementNS("http://www.w3.org/2000/svg","svg"),o.setAttribute("height","10px"),o.setAttribute("viewBox","0 0 14 14"),o.setAttribute("fill","none"),t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("fill-rule","evenodd"),t.setAttribute("clip-rule","evenodd"),t.setAttribute("fill",x.isDarkMode()?"white":"black"),t.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"),o.append(t),n.append(o),[n,l,u,p,e].forEach(e=>{c.append(e)}),c.style.width=`${r||458}px`,i.append(c),document.body.append(i);let f=JSON.parse(localStorage.alertQueue);f.push(i.id),localStorage.alertQueue=JSON.stringify(f),i.style.display="none",1===f.length&&(i.style.display="",setTimeout(()=>{i.style.backgroundColor=`rgba(67, 70, 72, ${"dark"==s?.62:.1})`,i.classList.add("animated")},100));const m=e=>{(e.target==e.currentTarget||e.target instanceof SVGPathElement)&&v()},h=e=>{if([" ","Spacebar","Enter","Return","Escape","Esc"].includes(e.key)||[32,13,27].includes(e.keyCode))for(const n of f){var t=document.getElementById(n);if(t&&"none"!==t.style.display)return void(e.key.includes("Esc")||27==e.keyCode?v():([" ","Spacebar","Enter","Return"].includes(e.key)||[32,13].includes(e.keyCode))&&(t=t.querySelector(".modal-buttons").lastChild)&&(t.click(),e.preventDefault()))}},y=[i,n,o,d],v=(y.forEach(e=>{e.addEventListener("click",m)}),document.addEventListener("keydown",h),()=>{i.style.backgroundColor="transparent",c.style.animation="alert-zoom-fade-out 0.075s ease-out",setTimeout(()=>{if(i.remove(),(f=JSON.parse(localStorage.alertQueue)).shift(),localStorage.alertQueue=JSON.stringify(f),y.forEach(e=>{e.removeEventListener("click",m)}),document.removeEventListener("keydown",h),0<f.length){const e=document.getElementById(f[0]);setTimeout(()=>{e.style.display="",setTimeout(()=>{e.classList.add("animated")},100)},500)}},50)});return i.id},askAndGetReply:async function(e){return x.send(e),await x.isIdle(),x.getChatData("active","msg","chatgpt","latest")},autoRefresh:{activate:function(e){if(this.isActive)console.log("↻ ChatGPT >> ["+x.autoRefresh.nowTimeStamp()+"] Auto refresh already active!");else{const n=this,o=(this.toggle.refreshFrame(),t=>{var e=Math.max(2,Math.floor(21*x.randomFloat()-10));n.isActive=setTimeout(()=>{var e=document.querySelector('script[src*="_ssgManifest.js"]');document.querySelector("#refresh-frame").src=e.src+"?"+Date.now(),console.log("↻ ChatGPT >> ["+n.nowTimeStamp()+"] ChatGPT session refreshed"),o(t)},1e3*(t+e))});o(e?parseInt(e,10):30),console.log("↻ ChatGPT >> ["+x.autoRefresh.nowTimeStamp()+"] Auto refresh activated"),navigator.userAgent.includes("Chrome")&&void 0!==document.hidden&&document.addEventListener("visibilitychange",this.toggle.beacons)}},deactivate:function(){this.isActive?(this.toggle.refreshFrame(),document.removeEventListener("visibilitychange",this.toggle.beacons),clearTimeout(this.isActive),this.isActive=null,console.log("↻ ChatGPT >> ["+x.autoRefresh.nowTimeStamp()+"] Auto refresh de-activated")):console.log("↻ ChatGPT >> ["+x.autoRefresh.nowTimeStamp()+"] Auto refresh already inactive!")},nowTimeStamp:function(){var e=new Date,t=e.getHours()%12||12;let n=e.getMinutes(),o=e.getSeconds();n<10&&(n="0"+n),o<10&&(o="0"+o);e=e.getHours()<12?"AM":"PM";return t+":"+n+":"+o+" "+e},toggle:{beacons:function(){x.autoRefresh.beaconID?(clearInterval(x.autoRefresh.beaconID),x.autoRefresh.beaconID=null,console.log("↻ ChatGPT >> ["+x.autoRefresh.nowTimeStamp()+"] Beacons de-activated")):(x.autoRefresh.beaconID=setInterval(()=>{navigator.sendBeacon("https://httpbin.org/post",new Uint8Array),console.log("↻ ChatGPT >> ["+x.autoRefresh.nowTimeStamp()+"] Beacon sent")},9e4),console.log("↻ ChatGPT >> ["+x.autoRefresh.nowTimeStamp()+"] Beacons activated"))},refreshFrame:function(){let e=document.querySelector("#refresh-frame");e?e.remove():(e=Object.assign(document.createElement("iframe"),{id:"refresh-frame",style:"display: none"}),document.head.prepend(e))}}},browser:{isLightMode:function(){return window.matchMedia?.("(prefers-color-scheme: light)")?.matches},isDarkMode:function(){return window.matchMedia?.("(prefers-color-scheme: dark)")?.matches},isChromium:function(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Chromium")},isChrome:function(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Chrome")},isEdge:function(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Edge")},isBrave:function(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Brave")},isFirefox:function(){return navigator.userAgent.includes("Firefox")},isFullScreen:function(){var e=navigator.userAgent;return e.includes("Chrome")?window.matchMedia("(display-mode: fullscreen)").matches:e.includes("Firefox")?window.fullScreen:/MSIE|rv:/.test(e)?document.msFullscreenElement:document.webkitIsFullScreen},isMobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}},clearChats:async function(){return new Promise((n,o)=>{x.getAccessToken().then(e=>{const t=new XMLHttpRequest;t.open("PATCH",x.endpoints.openAI.chats,!0),t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("Authorization","Bearer "+e),t.onload=()=>{if(200!==t.status)return o("🤖 chatgpt.js >> Request failed. Cannot clear chats.");console.info("Chats successfully cleared"),n()},t.send(JSON.stringify({is_visible:!1}))}).catch(e=>o(new Error(e.message)))})},code:{execute:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(x.send("Display the output as if you were terminal:\n\n"+e),console.info("Executing code..."),await x.isIdle(),x.code.extract(await x.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},extract:function(e){var t=e.match(/(?<=```.*\n)[\s\S]*?(?=```)/g);return t?t[t.length-1]:e},isIdle:async function(){await new Promise(t=>{!function e(){document.querySelector("div[data-message-author-role]")?t(!0):setTimeout(e,200)}()}),await new Promise(n=>{!function e(){var t=document.querySelectorAll("div[data-message-author-role]");"assistant"==t[t.length-1].dataset.messageAuthorRole?n(!0):setTimeout(e,200)}()});const n=await new Promise(n=>{!function e(){var t=document.querySelectorAll('div[data-message-author-role="assistant"]'),t=t[t.length-1];t.querySelector("pre")?n(t):setTimeout(e,200)}()});return Promise.race([new Promise(t=>{!function e(){n.querySelector("pre").nextElementSibling?t(!0):setTimeout(e,200)}()}),x.isIdle()])},minify:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(x.send("Minify the following code:\n\n"+e),console.info("Minifying code..."),await x.isIdle(),x.code.extract(await x.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},obfuscate:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(x.send("Obfuscate the following code:\n\n"+e),console.info("Obfuscating code..."),await x.isIdle(),x.code.extract(await x.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},refactor:async function(e,t){if(!e)return console.error("Code (1st) argument not supplied. Pass some code!");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return x.send("Refactor the following code for "+(t||"brevity")+":\n\n"+e),console.info("Refactoring code..."),await x.isIdle(),x.code.extract(await x.getChatData("active","msg","chatgpt","latest"))},review:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(x.send("Review the following code for me:\n\n"+e),console.info("Reviewing code..."),await x.isIdle(),x.getChatData("active","msg","chatgpt","latest")):console.error("Code argument not supplied. Pass some code!")},unminify:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(x.send("Unminify the following code.:\n\n"+e),console.info("Unminifying code..."),await x.isIdle(),x.code.extract(await x.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},write:async function(e,t){if(!e)return console.error("Prompt (1st) argument not supplied. Pass a prompt!");if(!t)return console.error("outputLang (2nd) argument not supplied. Pass a language!");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return x.send(e+"\n\nWrite this as code in "+t),console.info("Writing code..."),await x.isIdle(),x.code.extract(await x.getChatData("active","msg","chatgpt","latest"))}},continue:function(){x.response.continue()},detectLanguage:async function(e){return e?"string"!=typeof e?console.error("Text argument must be a string!"):(x.send("Detect the language of the following text:\n\n"+e+"\n\nOnly respond with the name of the language"),console.info("Reviewing text..."),await x.isIdle(),x.getChatData("active","msg","chatgpt","latest")):console.error("Text argument not supplied. Pass some text!")},executeCode:function(){x.code.execute()},exportChat:async function(e,t){e=e?Number.isInteger(e)||/^\d+$/.test(e)?parseInt(e,10):e:"active",t=t.toLowerCase()||"html",console.info("Generating transcript...");let o="",n;if(/te?xt/.test(t)){var r=new Date,s=r.getDate().toString().padStart(2,"0"),a=(r.getMonth()+1).toString().padStart(2,"0"),i=r.getFullYear(),c=r.getHours().toString().padStart(2,"0"),r=r.getMinutes().toString().padStart(2,"0");if(n=`ChatGPT_${s}-${a}-${i}_${c}-${r}.txt`,"active"==e&&/\/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(window.location.href)){s=document.querySelectorAll("main > div > div > div > div > div > div[class*=group]");if(0===s.length)return console.error("Chat is empty!");const l=[];let n=!0;s.forEach(e=>{var t=n?"USER":"CHATGPT",e=(n=!n,Array.from(e.childNodes).map(e=>e.innerText).join("\n\n").replace("Copy code",""));l.push(t+": "+e)}),o=l.join("\n\n")}else for(const u of await x.getChatData(e,"msg","both","all"))o=(o+=`USER: ${u.user}
1
+ localStorage.alertQueue=JSON.stringify([]),localStorage.notifyProps=JSON.stringify({queue:{topRight:[],bottomRight:[],bottomLeft:[],topLeft:[]}});const x={openAIaccessToken:{},endpoints:{assets:"https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@5f03341750fd154ae4f3f11d6ce79cc2f68f7068",openAI:{session:"https://chatgpt.com/api/auth/session",chats:"https://chatgpt.com/backend-api/conversations",chat:"https://chatgpt.com/backend-api/conversation",share_create:"https://chatgpt.com/backend-api/share/create",share:"https://chatgpt.com/backend-api/share",instructions:"https://chatgpt.com/backend-api/user_system_messages"}},actAs:function(a){return new Promise((o,r)=>{const s=new XMLHttpRequest;s.open("GET","https://raw.githubusercontent.com/KudoAI/chat-prompts/main/dist/personas.min.json",!0),s.send(),s.onload=()=>{if(200!==s.status)return r("🤖 chatgpt.js >> Request failed. Cannot retrieve prompts data.");var e=JSON.parse(s.responseText).personas;if(a){var t=e.find(e=>e.title.toLowerCase()==a.toLowerCase());if(!t)return r(`🤖 chatgpt.js >> Persona '${a}' was not found!`);x.send(t.prompt,"click"),console.info(`Loading ${a} persona...`),x.isIdle().then(()=>{console.info("Persona activated!")})}else{console.log("\n%c🤖 chatgpt.js personas\n","font-family: sans-serif ; font-size: xxx-large ; font-weight: bold");for(const n of e)console.log("%c"+n.title,"font-family: monospace ; font-size: larger ;")}return o()}})},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(e,t,n,o,r){const s=x.isDarkMode()?"dark":"light",a=x.browser.isMobile(),i=document.createElement("div"),c=(i.id=Math.floor(1e6*x.randomFloat())+Date.now(),i.classList.add("chatgpt-modal"),document.createElement("div")),l=document.createElement("h2"),u=document.createElement("p");var d=20231203;let g=document.querySelector("#chatgpt-modal-style");(!g||parseInt(g.getAttribute("last-updated"),10)<d)&&(g||((g=document.createElement("style")).id="chatgpt-modal-style",g.setAttribute("last-updated",d.toString()),document.head.append(g)),g.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: ${"dark"==s?"black":"white"} ;`+("dark"!=s?"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: ${"dark"==s?"#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 ;"+(a?"flex-direction: column-reverse":"")+"}.chatgpt-modal button {"+`margin-left: ${a?0:10}px ; padding: ${a?15:4}px 18px ; border-radius: 15px ;`+(a?"margin-top: 5px ; margin-bottom: 3px ;":"")+`border: 1px solid ${"dark"==s?"white":"black"}}`+".primary-modal-btn {"+`border: 1px solid ${"dark"==s?"white":"black"} ;`+`background: ${"dark"==s?"white":"black"} ;`+`color: ${"dark"==s?"black":"white"}}`+".chatgpt-modal button:hover { color: #3d5d71 ; border-color: #6d9cb9 ;background-color: "+("dark"==s?"#00cfff":"#9cdaff")+";box-shadow: 2px 1px "+("dark"==s?"54px #00cfff":"30px #9cdaff")+"}.modal-close-btn {cursor: pointer ; width: 29px ; height: 29px ; border-radius: 17px ;float: right ; position: relative ; right: -6px ; top: -5px }.modal-close-btn svg { margin: 10px }"+`.modal-close-btn:hover { background-color: #f2f2f2${"dark"==s?"00":""}}`+".chatgpt-modal .checkbox-group { display: flex ; margin-top: -18px }.chatgpt-modal .checkbox-group label {font-size: .7rem ; margin: -.04rem 0 0px .3rem ;"+`color: ${"dark"==s?"#e1e1e1":"#1e1e1e"}}`+'.chatgpt-modal input[type="checkbox"] { transform: scale(0.7) ;'+`border: 1px solid ${"dark"==s?"white":"black"}}`+'.chatgpt-modal input[type="checkbox"]:checked {'+`border: 1px solid ${"dark"==s?"white":"black"} ;`+'background-color: black ; position: inherit }.chatgpt-modal input[type="checkbox"]:focus { outline: none ; box-shadow: none }'),l.innerText=e||"",u.innerText=t||"",x.renderHTML(u);const p=document.createElement("div");p.classList.add("modal-buttons"),n&&(n=Array.isArray(n)?n:[n]).forEach(e=>{var t=document.createElement("button");t.textContent=e.name.replace(/[_-]\w/g,e=>e.slice(1).toUpperCase()).replace(/([A-Z])/g," $1").replace(/^\w/,e=>e.toUpperCase()),t.addEventListener("click",()=>{v(),e()}),p.insertBefore(t,p.firstChild)});d=document.createElement("button"),d.textContent=n?"Dismiss":"OK",p.insertBefore(d,p.firstChild),p.lastChild.classList.add("primary-modal-btn"),e=document.createElement("div");if(o){e.classList.add("checkbox-group");const w=o,b=document.createElement("input");b.type="checkbox",b.addEventListener("change",w);t=document.createElement("label");t.addEventListener("click",()=>{b.checked=!b.checked,w()}),t.textContent=w.name.charAt(0).toUpperCase()+w.name.slice(1).replace(/([A-Z])/g,(e,t)=>" "+t.toLowerCase()).replace(/\b(\w+)nt\b/gi,"$1n't").trim(),e.append(b),e.append(t)}n=document.createElement("div"),n.title="Close",n.classList.add("modal-close-btn"),o=document.createElementNS("http://www.w3.org/2000/svg","svg"),o.setAttribute("height","10px"),o.setAttribute("viewBox","0 0 14 14"),o.setAttribute("fill","none"),t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("fill-rule","evenodd"),t.setAttribute("clip-rule","evenodd"),t.setAttribute("fill",x.isDarkMode()?"white":"black"),t.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"),o.append(t),n.append(o),[n,l,u,p,e].forEach(e=>{c.append(e)}),c.style.width=`${r||458}px`,i.append(c),document.body.append(i);let f=JSON.parse(localStorage.alertQueue);f.push(i.id),localStorage.alertQueue=JSON.stringify(f),i.style.display="none",1===f.length&&(i.style.display="",setTimeout(()=>{i.style.backgroundColor=`rgba(67, 70, 72, ${"dark"==s?.62:.1})`,i.classList.add("animated")},100));const m=e=>{(e.target==e.currentTarget||e.target instanceof SVGPathElement)&&v()},h=e=>{if([" ","Spacebar","Enter","Return","Escape","Esc"].includes(e.key)||[32,13,27].includes(e.keyCode))for(const n of f){var t=document.getElementById(n);if(t&&"none"!==t.style.display)return void(e.key.includes("Esc")||27==e.keyCode?v():([" ","Spacebar","Enter","Return"].includes(e.key)||[32,13].includes(e.keyCode))&&(t=t.querySelector(".modal-buttons").lastChild)&&(t.click(),e.preventDefault()))}},y=[i,n,o,d],v=(y.forEach(e=>{e.addEventListener("click",m)}),document.addEventListener("keydown",h),()=>{i.style.backgroundColor="transparent",c.style.animation="alert-zoom-fade-out 0.075s ease-out",setTimeout(()=>{if(i.remove(),(f=JSON.parse(localStorage.alertQueue)).shift(),localStorage.alertQueue=JSON.stringify(f),y.forEach(e=>{e.removeEventListener("click",m)}),document.removeEventListener("keydown",h),0<f.length){const e=document.getElementById(f[0]);setTimeout(()=>{e.style.display="",setTimeout(()=>{e.classList.add("animated")},100)},500)}},50)});return i.id},askAndGetReply:async function(e){return x.send(e),await x.isIdle(),x.getChatData("active","msg","chatgpt","latest")},autoRefresh:{activate:function(e){if(this.isActive)console.log("↻ ChatGPT >> ["+x.autoRefresh.nowTimeStamp()+"] Auto refresh already active!");else{const n=this,o=(this.toggle.refreshFrame(),t=>{var e=Math.max(2,Math.floor(21*x.randomFloat()-10));n.isActive=setTimeout(()=>{var e=document.querySelector('script[src*="_ssgManifest.js"]');document.querySelector("#refresh-frame").src=e.src+"?"+Date.now(),console.log("↻ ChatGPT >> ["+n.nowTimeStamp()+"] ChatGPT session refreshed"),o(t)},1e3*(t+e))});o(e?parseInt(e,10):30),console.log("↻ ChatGPT >> ["+x.autoRefresh.nowTimeStamp()+"] Auto refresh activated"),navigator.userAgent.includes("Chrome")&&void 0!==document.hidden&&document.addEventListener("visibilitychange",this.toggle.beacons)}},deactivate:function(){this.isActive?(this.toggle.refreshFrame(),document.removeEventListener("visibilitychange",this.toggle.beacons),clearTimeout(this.isActive),this.isActive=null,console.log("↻ ChatGPT >> ["+x.autoRefresh.nowTimeStamp()+"] Auto refresh de-activated")):console.log("↻ ChatGPT >> ["+x.autoRefresh.nowTimeStamp()+"] Auto refresh already inactive!")},nowTimeStamp:function(){var e=new Date,t=e.getHours()%12||12;let n=e.getMinutes(),o=e.getSeconds();n<10&&(n="0"+n),o<10&&(o="0"+o);e=e.getHours()<12?"AM":"PM";return t+":"+n+":"+o+" "+e},toggle:{beacons:function(){x.autoRefresh.beaconID?(clearInterval(x.autoRefresh.beaconID),x.autoRefresh.beaconID=null,console.log("↻ ChatGPT >> ["+x.autoRefresh.nowTimeStamp()+"] Beacons de-activated")):(x.autoRefresh.beaconID=setInterval(()=>{navigator.sendBeacon("https://httpbin.org/post",new Uint8Array),console.log("↻ ChatGPT >> ["+x.autoRefresh.nowTimeStamp()+"] Beacon sent")},9e4),console.log("↻ ChatGPT >> ["+x.autoRefresh.nowTimeStamp()+"] Beacons activated"))},refreshFrame:function(){let e=document.querySelector("#refresh-frame");e?e.remove():(e=Object.assign(document.createElement("iframe"),{id:"refresh-frame",style:"display: none"}),document.head.prepend(e))}}},browser:{isLightMode:function(){return window.matchMedia?.("(prefers-color-scheme: light)")?.matches},isDarkMode:function(){return window.matchMedia?.("(prefers-color-scheme: dark)")?.matches},isChromium:function(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Chromium")},isChrome:function(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Chrome")},isEdge:function(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Edge")},isBrave:function(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Brave")},isFirefox:function(){return navigator.userAgent.includes("Firefox")},isFullScreen:function(){var e=navigator.userAgent;return e.includes("Chrome")?window.matchMedia("(display-mode: fullscreen)").matches:e.includes("Firefox")?window.fullScreen:/MSIE|rv:/.test(e)?document.msFullscreenElement:document.webkitIsFullScreen},isMobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}},clearChats:async function(){return new Promise((n,o)=>{x.getAccessToken().then(e=>{const t=new XMLHttpRequest;t.open("PATCH",x.endpoints.openAI.chats,!0),t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("Authorization","Bearer "+e),t.onload=()=>{if(200!==t.status)return o("🤖 chatgpt.js >> Request failed. Cannot clear chats.");console.info("Chats successfully cleared"),n()},t.send(JSON.stringify({is_visible:!1}))}).catch(e=>o(new Error(e.message)))})},code:{execute:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(x.send("Display the output as if you were terminal:\n\n"+e),console.info("Executing code..."),await x.isIdle(),x.code.extract(await x.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},extract:function(e){var t=e.match(/(?<=```.*\n)[\s\S]*?(?=```)/g);return t?t[t.length-1]:e},isIdle:async function(){await new Promise(t=>{!function e(){document.querySelector("div[data-message-author-role]")?t(!0):setTimeout(e,200)}()}),await new Promise(n=>{!function e(){var t=document.querySelectorAll("div[data-message-author-role]");"assistant"==t[t.length-1].dataset.messageAuthorRole?n(!0):setTimeout(e,200)}()});const n=await new Promise(n=>{!function e(){var t=document.querySelectorAll('div[data-message-author-role="assistant"]'),t=t[t.length-1];t.querySelector("pre")?n(t):setTimeout(e,200)}()});return Promise.race([new Promise(t=>{!function e(){n.querySelector("pre").nextElementSibling?t(!0):setTimeout(e,200)}()}),x.isIdle()])},minify:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(x.send("Minify the following code:\n\n"+e),console.info("Minifying code..."),await x.isIdle(),x.code.extract(await x.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},obfuscate:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(x.send("Obfuscate the following code:\n\n"+e),console.info("Obfuscating code..."),await x.isIdle(),x.code.extract(await x.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},refactor:async function(e,t){if(!e)return console.error("Code (1st) argument not supplied. Pass some code!");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return x.send("Refactor the following code for "+(t||"brevity")+":\n\n"+e),console.info("Refactoring code..."),await x.isIdle(),x.code.extract(await x.getChatData("active","msg","chatgpt","latest"))},review:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(x.send("Review the following code for me:\n\n"+e),console.info("Reviewing code..."),await x.isIdle(),x.getChatData("active","msg","chatgpt","latest")):console.error("Code argument not supplied. Pass some code!")},unminify:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(x.send("Unminify the following code.:\n\n"+e),console.info("Unminifying code..."),await x.isIdle(),x.code.extract(await x.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},write:async function(e,t){if(!e)return console.error("Prompt (1st) argument not supplied. Pass a prompt!");if(!t)return console.error("outputLang (2nd) argument not supplied. Pass a language!");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return x.send(e+"\n\nWrite this as code in "+t),console.info("Writing code..."),await x.isIdle(),x.code.extract(await x.getChatData("active","msg","chatgpt","latest"))}},continue:function(){x.response.continue()},detectLanguage:async function(e){return e?"string"!=typeof e?console.error("Text argument must be a string!"):(x.send("Detect the language of the following text:\n\n"+e+"\n\nOnly respond with the name of the language"),console.info("Reviewing text..."),await x.isIdle(),x.getChatData("active","msg","chatgpt","latest")):console.error("Text argument not supplied. Pass some text!")},executeCode:function(){x.code.execute()},exportChat:async function(e,t){e=e?Number.isInteger(e)||/^\d+$/.test(e)?parseInt(e,10):e:"active",t=t.toLowerCase()||"html",console.info("Generating transcript...");let o="",n;if(/te?xt/.test(t)){var r=new Date,s=r.getDate().toString().padStart(2,"0"),a=(r.getMonth()+1).toString().padStart(2,"0"),i=r.getFullYear(),c=r.getHours().toString().padStart(2,"0"),r=r.getMinutes().toString().padStart(2,"0");if(n=`ChatGPT_${s}-${a}-${i}_${c}-${r}.txt`,"active"==e&&/\/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(window.location.href)){s=document.querySelectorAll("main > div > div > div > div > div > div[class*=group]");if(0===s.length)return console.error("Chat is empty!");const l=[];let n=!0;s.forEach(e=>{var t=n?"USER":"CHATGPT",e=(n=!n,Array.from(e.childNodes).map(e=>e.innerText).join("\n\n").replace("Copy code",""));l.push(t+": "+e)}),o=l.join("\n\n")}else for(const u of await x.getChatData(e,"msg","both","all"))o=(o+=`USER: ${u.user}
2
2
 
3
3
  `)+`CHATGPT: ${u.chatgpt}
4
4
 
package/docs/README.md CHANGED
@@ -46,7 +46,7 @@
46
46
  [![](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.md)
47
47
  [![](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)
48
48
  ![](https://img.shields.io/badge/Clones-326/month-869da0?logo=github&logoColor=white&labelColor=464646&style=for-the-badge)
49
- [![](https://img.shields.io/github/size/KudoAI/chatgpt.js/dist/chatgpt.min.js?branch=v3.0.2&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge)](https://github.com/KudoAI/chatgpt.js/tree/v3.0.2/dist/chatgpt.min.js)
49
+ [![](https://img.shields.io/github/size/KudoAI/chatgpt.js/dist/chatgpt.min.js?branch=v3.0.3&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge)](https://github.com/KudoAI/chatgpt.js/tree/v3.0.3/dist/chatgpt.min.js)
50
50
  [![](https://img.shields.io/codefactor/grade/github/kudoai/chatgpt.js?label=Code+Quality&logo=codefactor&logoColor=white&labelColor=464646&color=1acc6c&style=for-the-badge)](https://www.codefactor.io/repository/github/kudoai/chatgpt.js)
51
51
  [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dkudoai_chatgpt.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold)](https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=kudoai_chatgpt.js)
52
52
  [![](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)
@@ -84,7 +84,7 @@
84
84
 
85
85
  ```js
86
86
  (async () => {
87
- await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.2/dist/chatgpt.min.js');
87
+ await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.3/dist/chatgpt.min.js');
88
88
  // Your code here...
89
89
  })();
90
90
  ```
@@ -93,7 +93,7 @@
93
93
 
94
94
  ```js
95
95
  var xhr = new XMLHttpRequest();
96
- xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.2/dist/chatgpt.min.js');
96
+ xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.3/dist/chatgpt.min.js');
97
97
  xhr.onload = function () {
98
98
  if (xhr.status === 200) {
99
99
  var chatgptJS = document.createElement('script');
@@ -115,7 +115,7 @@ function yourCode() {
115
115
 
116
116
  ```js
117
117
  ...
118
- // @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.2/dist/chatgpt.min.js
118
+ // @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.3/dist/chatgpt.min.js
119
119
  // ==/UserScript==
120
120
 
121
121
  // Your code here...
@@ -190,7 +190,7 @@ chatgpt.get('reply', 'last');
190
190
 
191
191
  Each call equally fetches the last response. If you think it works, it probably will... so just type it!
192
192
 
193
- If it didn't, check out the extended [userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.0.2/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!
193
+ If it didn't, check out the extended [userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.0.3/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!
194
194
 
195
195
  <img height=8px width="100%" src="https://media.chatgptjs.org/images/separators/gradient-aqua.png?78210a7">
196
196
 
@@ -327,7 +327,6 @@ This library exists thanks to code, translations, issues & ideas from the follow
327
327
  [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/50076933?first-contrib=2024.6.22-code.isidle-request&h=47&w=47&mask=circle&maxage=7d "@grayfallstown")](https://github.com/grayfallstown)
328
328
  [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/155944537?first-contrib=2024.8.27-sidebar-update-testing&h=47&w=47&mask=circle&maxage=7d "@svan-b")](https://github.com/svan-b)
329
329
  [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/u/74002352?first-contrib=2024.8.28-sidebar-update-testing&h=47&w=47&mask=circle&maxage=7d "@Jeff-Zzh")](https://github.com/Jeff-Zzh)
330
-
331
330
  [![](https://images.weserv.nl/?url=https://avatars.githubusercontent.com/in/29110&h=47&w=47&mask=circle&maxage=7d "Dependabot")](https://github.com/dependabot)
332
331
  <a href="https://chatgpt.com"><picture><source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://images.weserv.nl/?url=https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@main/media/images/icons/platforms/chatgpt/black-on-white/icon189.png?h=46&w=46&mask=circle&maxage=7d"><img src="https://images.weserv.nl/?url=https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@main/media/images/icons/platforms/chatgpt/white-on-black/icon189.png?h=46&w=46&mask=circle&maxage=7d" title="ChatGPT"></picture></a>
333
332
  <a href="https://poe.com"><picture><source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://images.weserv.nl/?url=https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@main/media/images/icons/platforms/poe/w-purple-blue-stripes/black-on-white/icon175.png?h=46&w=46&mask=circle&maxage=7d"><img src="https://images.weserv.nl/?url=https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@main/media/images/icons/platforms/poe/w-purple-blue-stripes/white-on-black/icon175.png?h=46&w=46&mask=circle&maxage=7d" title="Poe"></picture></a>
@@ -361,7 +360,7 @@ This library exists thanks to code, translations, issues & ideas from the follow
361
360
  <div align="center">
362
361
 
363
362
  **[Releases](https://github.com/KudoAI/chatgpt.js/releases)** /
364
- [Userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.0.2/docs/USERGUIDE.md) /
363
+ [Userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.0.3/docs/USERGUIDE.md) /
365
364
  [Discuss](https://github.com/KudoAI/chatgpt.js/discussions) /
366
365
  <a href="#--------------------------------------------------------------------------------english---------简体中文---------繁體中文---------日本---------한국인---------हिंदी---------नेपाली---------deutsch---------español---------français---------italiano---------nederlands---------português---------việt----">Back to top ↑</a>
367
366
 
package/docs/USERGUIDE.md CHANGED
@@ -150,7 +150,7 @@
150
150
 
151
151
  ```js
152
152
  (async () => {
153
- await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.2/dist/chatgpt.min.js');
153
+ await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.3/dist/chatgpt.min.js');
154
154
  // Your code here...
155
155
  })();
156
156
  ```
@@ -159,7 +159,7 @@
159
159
 
160
160
  ```js
161
161
  var xhr = new XMLHttpRequest();
162
- xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.2/dist/chatgpt.min.js');
162
+ xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.3/dist/chatgpt.min.js');
163
163
  xhr.onload = function () {
164
164
  if (xhr.status === 200) {
165
165
  var chatgptJS = document.createElement('script');
@@ -181,7 +181,7 @@ function yourCode() {
181
181
 
182
182
  ```js
183
183
  ...
184
- // @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.2/dist/chatgpt.min.js
184
+ // @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.3/dist/chatgpt.min.js
185
185
  // ==/UserScript==
186
186
 
187
187
  // Your code here...
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kudoai/chatgpt.js",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "Client-side JavaScript library for ChatGPT",
5
5
  "author": {
6
6
  "name": "KudoAI & contributors",
@@ -282,7 +282,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
282
282
  return modalContainer.id; // if assignment used
283
283
  },
284
284
 
285
- askAndGetReply: async function(query) {
285
+ async askAndGetReply(query) {
286
286
  chatgpt.send(query); await chatgpt.isIdle();
287
287
  return chatgpt.getChatData('active', 'msg', 'chatgpt', 'latest');
288
288
  },
@@ -379,7 +379,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
379
379
  return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); }
380
380
  },
381
381
 
382
- clearChats: async function() { // back-end method
382
+ async clearChats() { // back-end method
383
383
  return new Promise((resolve, reject) => {
384
384
  chatgpt.getAccessToken().then(token => {
385
385
  const xhr = new XMLHttpRequest();
@@ -398,7 +398,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
398
398
  code: {
399
399
  // Tip: Use template literals for easier passing of code arguments. Ensure backticks and `$`s are escaped (using `\`)
400
400
 
401
- execute: async function(code) {
401
+ async execute(code) {
402
402
  if (!code) return console.error('Code argument not supplied. Pass some code!');
403
403
  if (typeof code !== 'string') return console.error('Code argument must be a string!');
404
404
  chatgpt.send('Display the output as if you were terminal:\n\n' + code);
@@ -412,7 +412,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
412
412
  return codeBlocks ? codeBlocks[codeBlocks.length - 1] : msg;
413
413
  },
414
414
 
415
- isIdle: async function() {
415
+ async isIdle() {
416
416
  await new Promise(resolve => { // when in conversation page
417
417
  (function checkConvoPage() {
418
418
  document.querySelector('div[data-message-author-role]') ? resolve(true)
@@ -440,7 +440,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
440
440
  ]);
441
441
  },
442
442
 
443
- minify: async function(code) {
443
+ async minify(code) {
444
444
  if (!code) return console.error('Code argument not supplied. Pass some code!');
445
445
  if (typeof code !== 'string') return console.error('Code argument must be a string!');
446
446
  chatgpt.send('Minify the following code:\n\n' + code);
@@ -449,7 +449,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
449
449
  return chatgpt.code.extract(await chatgpt.getChatData('active', 'msg', 'chatgpt', 'latest'));
450
450
  },
451
451
 
452
- obfuscate: async function(code) {
452
+ async obfuscate(code) {
453
453
  if (!code) return console.error('Code argument not supplied. Pass some code!');
454
454
  if (typeof code !== 'string') return console.error('Code argument must be a string!');
455
455
  chatgpt.send('Obfuscate the following code:\n\n' + code);
@@ -458,7 +458,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
458
458
  return chatgpt.code.extract(await chatgpt.getChatData('active', 'msg', 'chatgpt', 'latest'));
459
459
  },
460
460
 
461
- refactor: async function(code, objective) {
461
+ async refactor(code, objective) {
462
462
  if (!code) return console.error('Code (1st) argument not supplied. Pass some code!');
463
463
  for (let i = 0; i < arguments.length; i++) if (typeof arguments[i] !== 'string')
464
464
  return console.error(`Argument ${ i + 1 } must be a string.`);
@@ -468,7 +468,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
468
468
  return chatgpt.code.extract(await chatgpt.getChatData('active', 'msg', 'chatgpt', 'latest'));
469
469
  },
470
470
 
471
- review: async function(code) {
471
+ async review(code) {
472
472
  if (!code) return console.error('Code argument not supplied. Pass some code!');
473
473
  if (typeof code !== 'string') return console.error('Code argument must be a string!');
474
474
  chatgpt.send('Review the following code for me:\n\n' + code);
@@ -477,7 +477,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
477
477
  return chatgpt.getChatData('active', 'msg', 'chatgpt', 'latest');
478
478
  },
479
479
 
480
- unminify: async function(code) {
480
+ async unminify(code) {
481
481
  if (!code) return console.error('Code argument not supplied. Pass some code!');
482
482
  if (typeof code !== 'string') return console.error('Code argument must be a string!');
483
483
  chatgpt.send('Unminify the following code.:\n\n' + code);
@@ -486,7 +486,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
486
486
  return chatgpt.code.extract(await chatgpt.getChatData('active', 'msg', 'chatgpt', 'latest'));
487
487
  },
488
488
 
489
- write: async function(prompt, outputLang) {
489
+ async write(prompt, outputLang) {
490
490
  if (!prompt) return console.error('Prompt (1st) argument not supplied. Pass a prompt!');
491
491
  if (!outputLang) return console.error('outputLang (2nd) argument not supplied. Pass a language!');
492
492
  for (let i = 0; i < arguments.length; i++) if (typeof arguments[i] !== 'string')
@@ -500,7 +500,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
500
500
 
501
501
  continue() { chatgpt.response.continue(); },
502
502
 
503
- detectLanguage: async function(text) {
503
+ async detectLanguage(text) {
504
504
  if (!text) return console.error('Text argument not supplied. Pass some text!');
505
505
  if (typeof text !== 'string') return console.error('Text argument must be a string!');
506
506
  chatgpt.send('Detect the language of the following text:\n\n' + text
@@ -512,7 +512,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
512
512
 
513
513
  executeCode() { chatgpt.code.execute(); },
514
514
 
515
- exportChat: async function(chatToGet, format) {
515
+ async exportChat(chatToGet, format) {
516
516
  // chatToGet = 'active' (default) | 'latest' | index|title|id of chat to get
517
517
  // format = 'html' (default) | 'md' | 'pdf' | 'text'
518
518
 
@@ -1171,7 +1171,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
1171
1171
 
1172
1172
  minify() { chatgpt.code.minify(); },
1173
1173
 
1174
- notify: async function(msg, position, notifDuration, shadow) {
1174
+ async notify(msg, position, notifDuration, shadow) {
1175
1175
  notifDuration = notifDuration ? +notifDuration : 1.75; // sec duration to maintain notification visibility
1176
1176
  const fadeDuration = 0.35, // sec duration of fade-out
1177
1177
  vpYoffset = 23, vpXoffset = 27; // px offset from viewport border
@@ -1409,7 +1409,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
1409
1409
  return node; // if assignment used
1410
1410
  },
1411
1411
 
1412
- resend: async function() { chatgpt.send(await chatgpt.getChatData('latest', 'msg', 'user', 'latest')); },
1412
+ async resend() { chatgpt.send(await chatgpt.getChatData('latest', 'msg', 'user', 'latest')); },
1413
1413
 
1414
1414
  response: {
1415
1415
  continue() { try { chatgpt.getContinueBtn().click(); } catch (err) { console.error(err.message); }},
@@ -1481,17 +1481,16 @@ const chatgpt = { // eslint-disable-line no-redeclare
1481
1481
  send(msg, method='') {
1482
1482
  for (let i = 0; i < arguments.length; i++) if (typeof arguments[i] !== 'string')
1483
1483
  return console.error(`Argument ${ i + 1 } must be a string!`);
1484
- const textArea = document.querySelector('form textarea'),
1485
- sendBtn = chatgpt.getSendButton();
1484
+ const textArea = document.querySelector('form textarea');
1486
1485
  textArea.value = msg;
1487
1486
  textArea.dispatchEvent(new Event('input', { bubbles: true })); // enable send button
1488
-
1489
1487
  setTimeout(function delaySend() {
1488
+ const sendBtn = chatgpt.getSendButton();
1490
1489
  if (!sendBtn?.hasAttribute('disabled')) { // send msg
1491
1490
  method.toLowerCase() == 'click' || chatgpt.browser.isMobile() ? sendBtn.click()
1492
- : textArea.dispatchEvent(new KeyboardEvent('keydown', { keyCode: 13, bubbles: true }));
1493
- } else setTimeout(delaySend, 25);
1494
- }, 25);
1491
+ : textArea.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }));
1492
+ } else setTimeout(delaySend, 222);
1493
+ }, 222);
1495
1494
  },
1496
1495
 
1497
1496
  sendInNewChat(msg) {
@@ -1531,7 +1530,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
1531
1530
  }
1532
1531
  },
1533
1532
 
1534
- sentiment: async function(text, entity) {
1533
+ async sentiment(text, entity) {
1535
1534
  for (let i = 0; i < arguments.length; i++) if (typeof arguments[i] !== 'string')
1536
1535
  return console.error(`Argument ${ i + 1 } must be a string.`);
1537
1536
  chatgpt.send('What is the sentiment of the following text'
@@ -1755,7 +1754,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
1755
1754
  if (isToggleBtn(btn)) { btn.click(); return; }
1756
1755
  },
1757
1756
 
1758
- isLoaded: async function() {
1757
+ async isLoaded() {
1759
1758
  await chatgpt.isLoaded();
1760
1759
  return Promise.race([
1761
1760
  new Promise(resolve => {
@@ -1771,7 +1770,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
1771
1770
  startNewChat() { try { chatgpt.getNewChatBtn().click(); } catch (err) { console.error(err.message); }},
1772
1771
  stop() { chatgpt.response.stopGenerating(); },
1773
1772
 
1774
- suggest: async function(ideaType, details) {
1773
+ async suggest(ideaType, details) {
1775
1774
  if (!ideaType) return console.error('ideaType (1st argument) not supplied'
1776
1775
  + '(e.g. \'gifts\', \'names\', \'recipes\', etc.)');
1777
1776
  for (let i = 0; i < arguments.length; i++) if (typeof arguments[i] !== 'string')
@@ -1809,7 +1808,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
1809
1808
  } catch (err) { console.error( err); }
1810
1809
  },
1811
1810
 
1812
- summarize: async function(text) {
1811
+ async summarize(text) {
1813
1812
  if (!text) return console.error('Text (1st) argument not supplied. Pass some text!');
1814
1813
  if (typeof text !== 'string') return console.error('Text argument must be a string!');
1815
1814
  chatgpt.send('Summarize the following text:\n\n' + text);
@@ -1820,7 +1819,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
1820
1819
 
1821
1820
  toggleScheme() { chatgpt.settings.scheme.toggle(); },
1822
1821
 
1823
- translate: async function(text, outputLang) {
1822
+ async translate(text, outputLang) {
1824
1823
  if (!text) return console.error('Text (1st) argument not supplied. Pass some text!');
1825
1824
  if (!outputLang) return console.error('outputLang (2nd) argument not supplied. Pass a language!');
1826
1825
  for (let i = 0; i < arguments.length; i++) if (typeof arguments[i] !== 'string')
@@ -3,13 +3,13 @@
3
3
  // @description A Greasemonkey template to start using chatgpt.js like a boss
4
4
  // @author chatgpt.js
5
5
  // @namespace https://chatgpt.js.org
6
- // @version 2024.8.28
6
+ // @version 2024.8.28.1
7
7
  // @license MIT
8
8
  // @match *://chatgpt.com/*
9
9
  // @match *://chat.openai.com/*
10
- // @icon https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@3.0.2/starters/greasemonkey/media/images/icons/robot/icon48.png
11
- // @icon64 https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@3.0.2/starters/greasemonkey/media/images/icons/robot/icon64.png
12
- // @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.2/dist/chatgpt.min.js
10
+ // @icon https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@3.0.3/starters/greasemonkey/media/images/icons/robot/icon48.png
11
+ // @icon64 https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@3.0.3/starters/greasemonkey/media/images/icons/robot/icon64.png
12
+ // @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.3/dist/chatgpt.min.js
13
13
  // @grant GM_getValue
14
14
  // @grant GM_setValue
15
15
  // @noframes