@kudoai/chatgpt.js 2.9.3 → 3.0.1

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/docs/USERGUIDE.md CHANGED
@@ -23,11 +23,8 @@
23
23
  - [generateRandomIP](#generaterandomip)
24
24
  - [get](#get)
25
25
  - [getUserLanguage](#getuserlanguage)
26
- - [isChromium](#ischromium)
27
- - [isFirefox](#isfirefox)
28
26
  - [isFullScreen](#isfullscreen)
29
27
  - [isLoaded `async`](#isloaded-async)
30
- - [isMobileDevice](#ismobiledevice)
31
28
  - [printAllFunctions](#printallfunctions)
32
29
  - [randomFloat](#randomfloat)
33
30
  - [renderHTML](#renderhtml)
@@ -71,6 +68,7 @@
71
68
  - [startNewChat](#startnewchat)
72
69
  - [stop](#stop)
73
70
  - [DOM related](#dom-related)
71
+ - [focusChatbar](#focuschatbar)
74
72
  - [getChatBox](#getchatbox)
75
73
  - [getContinueGeneratingButton](#getcontinuegeneratingbutton)
76
74
  - [getFooterDiv](#getfooterdiv)
@@ -93,14 +91,18 @@
93
91
  - [browser `api`](#browser-api)
94
92
  - [isLightMode](#islightmode-1)
95
93
  - [isDarkMode](#isdarkmode-1)
96
- - [isChromium](#ischromium-1)
97
- - [isFirefox](#isfirefox-1)
94
+ - [isChromium](#ischromium)
95
+ - [isChrome](#ischrome)
96
+ - [isEdge](#isedge)
97
+ - [isBrave](#isbrave)
98
+ - [isFirefox](#isfirefox)
98
99
  - [isFullScreen](#isfullscreen-1)
99
100
  - [isMobile](#ismobile)
100
101
  - [code `api`](#code-api)
101
102
  - [minify `async`](#minify-async)
102
103
  - [execute `async`](#execute-async)
103
104
  - [extract](#extract)
105
+ - [isIdle `async`](#isidle-async-1)
104
106
  - [obfuscate `async`](#obfuscate-async)
105
107
  - [refactor `async`](#refactor-async)
106
108
  - [review `async`](#review-async)
@@ -148,7 +150,7 @@
148
150
 
149
151
  ```js
150
152
  (async () => {
151
- await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.9.3/dist/chatgpt.min.js');
153
+ await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.1/dist/chatgpt.min.js');
152
154
  // Your code here...
153
155
  })();
154
156
  ```
@@ -157,7 +159,7 @@
157
159
 
158
160
  ```js
159
161
  var xhr = new XMLHttpRequest();
160
- xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.9.3/dist/chatgpt.min.js');
162
+ xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.1/dist/chatgpt.min.js');
161
163
  xhr.onload = function () {
162
164
  if (xhr.status === 200) {
163
165
  var chatgptJS = document.createElement('script');
@@ -179,7 +181,7 @@ function yourCode() {
179
181
 
180
182
  ```js
181
183
  ...
182
- // @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.9.3/dist/chatgpt.min.js
184
+ // @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.1/dist/chatgpt.min.js
183
185
  // ==/UserScript==
184
186
 
185
187
  // Your code here...
@@ -288,30 +290,6 @@ const userLanguage = chatgpt.getUserLanguage();
288
290
  console.log(userLanguage); // Example output: 'en-US'
289
291
  ```
290
292
 
291
- ### isChromium
292
-
293
- Returns a boolean value. `true` if the browser is Chromium and `false` otherwise.
294
-
295
- Example code:
296
-
297
- ```js
298
- if (chatgpt.isChromium()) {
299
- // Do something
300
- }
301
- ```
302
-
303
- ### isFirefox
304
-
305
- Returns a boolean value. `true` if the browser is Firefox and `false` otherwise.
306
-
307
- Example code:
308
-
309
- ```js
310
- if (chatgpt.isFirefox()) {
311
- // Do something
312
- }
313
- ```
314
-
315
293
  ### isFullScreen
316
294
 
317
295
  Returns a boolean value. `true` if the website is fullscreen and `false` otherwise.
@@ -337,18 +315,6 @@ Example code:
337
315
  })();
338
316
  ```
339
317
 
340
- ### isMobileDevice
341
-
342
- Returns a boolean value. `true` if the user device is mobile and `false` otherwise.
343
-
344
- Example code:
345
-
346
- ```js
347
- if (chatgpt.isMobileDevice()) {
348
- // Do something
349
- }
350
- ```
351
-
352
318
  ### printAllFunctions
353
319
 
354
320
  Prints all the library functions to the console.
@@ -668,11 +634,13 @@ Example code:
668
634
 
669
635
  ### clearChats `async`
670
636
 
671
- **Parameters**:
637
+ Clears chat history.
672
638
 
673
- `method` (optional): The string `'api'` or `'dom'` representing the method to use.
639
+ Example code:
674
640
 
675
- > **Note** _The API method does not update DOM chat list (until session refresh)_
641
+ ```js
642
+ chatgpt.clearChats().then(() => console.log('Chat history cleared!'));
643
+ ```
676
644
 
677
645
  ### exportChat `async`
678
646
 
@@ -933,15 +901,14 @@ console.log(fifthResp); // Example output: 'Hello from ChatGPT!'
933
901
 
934
902
  ### isIdle `async`
935
903
 
936
- Returns a boolean value. `true` if ChatGPT has finished generating a response, `false` otherwise.
904
+ Resolves a promise when ChatGPT has finished generating a response.
937
905
 
938
906
  Example code:
939
907
 
940
908
  ```js
941
909
  (async () => {
942
- if (await chatgpt.isIdle()) {
943
- // Do something
944
- }
910
+ await chatgpt.code.isIdle();
911
+ console.log('ChatGPT is idle');
945
912
  })();
946
913
  ```
947
914
 
@@ -1070,6 +1037,16 @@ chatgpt.stop();
1070
1037
 
1071
1038
  ## DOM related
1072
1039
 
1040
+ ### focusChatbar
1041
+
1042
+ Focuses the chatbar.
1043
+
1044
+ Example code:
1045
+
1046
+ ```js
1047
+ chatgpt.focusChatbar();
1048
+ ```
1049
+
1073
1050
  ### getChatBox
1074
1051
 
1075
1052
  Returns the chat input as an HTML element.
@@ -1122,7 +1099,7 @@ Example code:
1122
1099
 
1123
1100
  ```js
1124
1101
  const newChatBtn = chatgpt.getNewChatButton();
1125
- newChatBtn.click();
1102
+ newChatBtn.style.display = 'none'; // hide New Chat button
1126
1103
  ```
1127
1104
 
1128
1105
  ### getNewChatLink
@@ -1133,7 +1110,7 @@ Example code:
1133
1110
 
1134
1111
  ```js
1135
1112
  const newChatLink = chatgpt.getNewChatLink();
1136
- newChatLink.click();
1113
+ newChatLink.style.display = 'none'; // hide New Chat link
1137
1114
  ```
1138
1115
 
1139
1116
  ### getRegenerateButton
@@ -1295,6 +1272,42 @@ if (chatgpt.browser.isChromium()) {
1295
1272
  }
1296
1273
  ```
1297
1274
 
1275
+ ### isChrome
1276
+
1277
+ Returns a boolean value. `true` if the browser is Chrome and `false` otherwise.
1278
+
1279
+ Example code:
1280
+
1281
+ ```js
1282
+ if (chatgpt.browser.isChrome()) {
1283
+ // Do something
1284
+ }
1285
+ ```
1286
+
1287
+ ### isEdge
1288
+
1289
+ Returns a boolean value. `true` if the browser is Edge and `false` otherwise.
1290
+
1291
+ Example code:
1292
+
1293
+ ```js
1294
+ if (chatgpt.browser.isEdge()) {
1295
+ // Do something
1296
+ }
1297
+ ```
1298
+
1299
+ ### isBrave
1300
+
1301
+ Returns a boolean value. `true` if the browser is Brave and `false` otherwise.
1302
+
1303
+ Example code:
1304
+
1305
+ ```js
1306
+ if (chatgpt.browser.isBrave()) {
1307
+ // Do something
1308
+ }
1309
+ ```
1310
+
1298
1311
  ### isFirefox
1299
1312
 
1300
1313
  Returns a boolean value. `true` if the browser is Firefox and `false` otherwise.
@@ -1414,6 +1427,20 @@ Example code:
1414
1427
  })();
1415
1428
  ```
1416
1429
 
1430
+ ### isIdle `async`
1431
+
1432
+ Resolves a promise when code has finished generating.
1433
+
1434
+ Example code:
1435
+
1436
+ ```js
1437
+ (async () => {
1438
+ chatgpt.send('Type me a short code block');
1439
+ await chatgpt.code.isIdle();
1440
+ console.log('Code finished generating'); // non-code may still be generating
1441
+ })();
1442
+ ```
1443
+
1417
1444
  ### obfuscate `async`
1418
1445
 
1419
1446
  Asks ChatGPT to obfuscate the given code.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kudoai/chatgpt.js",
3
- "version": "2.9.3",
3
+ "version": "3.0.1",
4
4
  "description": "Client-side JavaScript library for ChatGPT",
5
5
  "author": {
6
6
  "name": "KudoAI & contributors",
@@ -64,11 +64,11 @@
64
64
  "url": "https://github.com/sponsors/KudoAI"
65
65
  },
66
66
  "devDependencies": {
67
- "@adamlui/minify.js": "^1.7.0",
68
- "@adamlui/scss-to-css": "^1.10.0",
67
+ "@adamlui/minify.js": "^1.8.1",
68
+ "@adamlui/scss-to-css": "^1.10.3",
69
69
  "docsify-cli": "^4.4.4",
70
- "eslint": "^9.3.0",
71
- "eslint-plugin-json-schema-validator": "^5.1.0",
72
- "husky": "^9.0.11"
70
+ "eslint": "^9.5.0",
71
+ "eslint-plugin-json": "^4.0.0",
72
+ "husky": "^9.1.0"
73
73
  }
74
74
  }
@@ -1,8 +1,8 @@
1
1
  <div align="center">
2
2
  <h6>
3
3
  <picture>
4
- <source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://media.chatgptjs.org/images/icons/earth-americas-white-icon32.svg">
5
- <img height=14 src="https://media.chatgptjs.org/images/icons/earth-americas-icon32.svg">
4
+ <source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://media.chatgptjs.org/images/icons/earth-americas-white-icon32.svg?main">
5
+ <img height=14 src="https://media.chatgptjs.org/images/icons/earth-americas-icon32.svg?main">
6
6
  </picture>
7
7
  &nbsp;English |
8
8
  <a href="docs/zh-cn/LICENSE.md">简体中文</a> |
@@ -1,8 +1,8 @@
1
1
  <div align="center">
2
2
  <h6>
3
3
  <picture>
4
- <source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://media.chatgptjs.org/images/icons/earth-americas-white-icon32.svg">
5
- <img height=14 src="https://media.chatgptjs.org/images/icons/earth-americas-icon32.svg">
4
+ <source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://media.chatgptjs.org/images/icons/earth-americas-white-icon32.svg?main">
5
+ <img height=14 src="https://media.chatgptjs.org/images/icons/earth-americas-icon32.svg?main">
6
6
  </picture>
7
7
  &nbsp;English |
8
8
  <a href="zh-cn#readme">简体中文</a> |
@@ -1,8 +1,8 @@
1
1
  <div align="right">
2
2
  <h6>
3
3
  <picture>
4
- <source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://media.chatgptjs.org/images/icons/earth-americas-white-icon32.svg">
5
- <img height=14 src="https://media.chatgptjs.org/images/icons/earth-americas-icon32.svg">
4
+ <source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://media.chatgptjs.org/images/icons/earth-americas-white-icon32.svg?main">
5
+ <img height=14 src="https://media.chatgptjs.org/images/icons/earth-americas-icon32.svg?main">
6
6
  </picture>
7
7
  &nbsp;English |
8
8
  <a href="https://github.com/KudoAI/chatgpt.js-chrome-starter/blob/main/docs/zh-cn/SECURITY.md">简体中文</a> |