@kudoai/chatgpt.js 3.2.1 → 3.3.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/README.md +7 -7
- package/chatgpt.js +123 -96
- package/dist/chatgpt.min.js +3 -3
- package/docs/README.md +7 -7
- package/docs/USERGUIDE.md +186 -76
- package/package.json +2 -2
- package/starters/chrome/extension/lib/chatgpt.js +123 -96
- package/starters/chrome/extension/manifest.json +1 -1
- package/starters/greasemonkey/chatgpt.js-greasemonkey-starter.user.js +4 -4
package/docs/USERGUIDE.md
CHANGED
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
- [DOM related](#dom-related)
|
|
71
71
|
- [focusChatbar](#focuschatbar)
|
|
72
72
|
- [getChatBox](#getchatbox)
|
|
73
|
-
- [
|
|
73
|
+
- [getContinueButton](#getContinueButton)
|
|
74
74
|
- [getFooterDiv](#getfooterdiv)
|
|
75
75
|
- [getHeaderDiv](#getheaderdiv)
|
|
76
76
|
- [getNewChatButton](#getnewchatbutton)
|
|
@@ -108,6 +108,14 @@
|
|
|
108
108
|
- [review `async`](#review-async)
|
|
109
109
|
- [unminify `async`](#unminify-async)
|
|
110
110
|
- [write `async`](#write-async)
|
|
111
|
+
- [footer `api`](#footer-api)
|
|
112
|
+
- [get](#get)
|
|
113
|
+
- [hide](#hide)
|
|
114
|
+
- [show](#show)
|
|
115
|
+
- [header `api`](#header-api)
|
|
116
|
+
- [get](#get-1)
|
|
117
|
+
- [hide](#hide-1)
|
|
118
|
+
- [show](#show-1)
|
|
111
119
|
- [history `api`](#history-api)
|
|
112
120
|
- [isLoaded](#isloaded-async-1)
|
|
113
121
|
- [instructions `api`](#instructions-api)
|
|
@@ -121,7 +129,7 @@
|
|
|
121
129
|
- [close](#close)
|
|
122
130
|
- [response `api`](#response-api)
|
|
123
131
|
- [continue](#continue)
|
|
124
|
-
- [get](#get-
|
|
132
|
+
- [get](#get-2)
|
|
125
133
|
- [getFromAPI `async`](#getfromapi-async)
|
|
126
134
|
- [getFromDOM](#getfromdom)
|
|
127
135
|
- [getLast `async`](#getlast-async)
|
|
@@ -135,11 +143,12 @@
|
|
|
135
143
|
- [toggle](#toggle-1)
|
|
136
144
|
- [sidebar `api`](#sidebar-api)
|
|
137
145
|
- [append](#append)
|
|
138
|
-
- [
|
|
139
|
-
- [
|
|
140
|
-
- [
|
|
141
|
-
- [
|
|
142
|
-
- [
|
|
146
|
+
- [exists](#exists)
|
|
147
|
+
- [isOn](#ison)
|
|
148
|
+
- [isOff](#isoff)
|
|
149
|
+
- [hide](#hide-2)
|
|
150
|
+
- [show](#show-2)
|
|
151
|
+
- [toggle](#toggle-1)
|
|
143
152
|
- [isLoaded](#isloaded-async-2)
|
|
144
153
|
|
|
145
154
|
# Importing the library
|
|
@@ -150,7 +159,7 @@
|
|
|
150
159
|
|
|
151
160
|
```js
|
|
152
161
|
(async () => {
|
|
153
|
-
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.
|
|
162
|
+
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.1/dist/chatgpt.min.js');
|
|
154
163
|
// Your code here...
|
|
155
164
|
})();
|
|
156
165
|
```
|
|
@@ -159,7 +168,7 @@
|
|
|
159
168
|
|
|
160
169
|
```js
|
|
161
170
|
var xhr = new XMLHttpRequest();
|
|
162
|
-
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.
|
|
171
|
+
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.1/dist/chatgpt.min.js');
|
|
163
172
|
xhr.onload = function () {
|
|
164
173
|
if (xhr.status === 200) {
|
|
165
174
|
var chatgptJS = document.createElement('script');
|
|
@@ -181,7 +190,7 @@ function yourCode() {
|
|
|
181
190
|
|
|
182
191
|
```js
|
|
183
192
|
...
|
|
184
|
-
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.
|
|
193
|
+
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.1/dist/chatgpt.min.js
|
|
185
194
|
// ==/UserScript==
|
|
186
195
|
|
|
187
196
|
// Your code here...
|
|
@@ -234,8 +243,8 @@ Example code:
|
|
|
234
243
|
```js
|
|
235
244
|
(async () => {
|
|
236
245
|
const language = await chatgpt.detectLanguage('我是一個大男孩');
|
|
237
|
-
|
|
238
|
-
/*
|
|
246
|
+
chatgpt.alert(language);
|
|
247
|
+
/* Alerts:
|
|
239
248
|
Chinese (Traditional) */
|
|
240
249
|
})();
|
|
241
250
|
```
|
|
@@ -252,7 +261,7 @@ Example code:
|
|
|
252
261
|
|
|
253
262
|
```js
|
|
254
263
|
(async () => {
|
|
255
|
-
|
|
264
|
+
chatgpt.alert(await chatgpt.executeCode('return 6 + 5')); // logs '11'
|
|
256
265
|
})();
|
|
257
266
|
```
|
|
258
267
|
|
|
@@ -264,7 +273,7 @@ Example code:
|
|
|
264
273
|
|
|
265
274
|
```js
|
|
266
275
|
const randomIP = chatgpt.generateRandomIP();
|
|
267
|
-
|
|
276
|
+
chatgpt.alert(randomIP); // Example output: '161.192.110.125'
|
|
268
277
|
```
|
|
269
278
|
|
|
270
279
|
### get
|
|
@@ -287,7 +296,7 @@ Example code:
|
|
|
287
296
|
|
|
288
297
|
```js
|
|
289
298
|
const userLanguage = chatgpt.getUserLanguage();
|
|
290
|
-
|
|
299
|
+
chatgpt.alert(userLanguage); // Example output: 'en-US'
|
|
291
300
|
```
|
|
292
301
|
|
|
293
302
|
### isFullScreen
|
|
@@ -306,12 +315,16 @@ if (chatgpt.isFullScreen()) {
|
|
|
306
315
|
|
|
307
316
|
Resolves a promise when ChatGPT has finished loading.
|
|
308
317
|
|
|
318
|
+
**Parameters**:
|
|
319
|
+
|
|
320
|
+
`timeout` (optional): An integer specifying the number of milliseconds to wait before resolving with `false`. If not provided, waits indefinitely until ChatGPT finishes loading.
|
|
321
|
+
|
|
309
322
|
Example code:
|
|
310
323
|
|
|
311
324
|
```js
|
|
312
325
|
(async () => {
|
|
313
326
|
await chatgpt.isLoaded();
|
|
314
|
-
|
|
327
|
+
chatgpt.alert('ChatGPT has finished loading.');
|
|
315
328
|
})();
|
|
316
329
|
```
|
|
317
330
|
|
|
@@ -333,7 +346,7 @@ Example code:
|
|
|
333
346
|
|
|
334
347
|
```js
|
|
335
348
|
const randomNumber = chatgpt.randomFloat();
|
|
336
|
-
|
|
349
|
+
chatgpt.alert(randomNumber); // Example output: 0.9472113021060851
|
|
337
350
|
```
|
|
338
351
|
|
|
339
352
|
### renderHTML
|
|
@@ -368,7 +381,7 @@ Example code:
|
|
|
368
381
|
(async () => {
|
|
369
382
|
const text = 'Are you an #OSS supporter? Do you love JavaScript? Then why not contribute to the future of #AI app development? https://chatgpt.js.org (a #100Builders project) is seeking collabs for exactly this! @withBackdrop';
|
|
370
383
|
const sentiment = await chatgpt.sentiment(text, '100 Builders');
|
|
371
|
-
|
|
384
|
+
chatgpt.alert(sentiment);
|
|
372
385
|
|
|
373
386
|
/* Example output:
|
|
374
387
|
The sentiment of the text towards the entity "100 Builders" is strongly positive. The text encourages
|
|
@@ -394,7 +407,7 @@ Example code:
|
|
|
394
407
|
```js
|
|
395
408
|
(async () => {
|
|
396
409
|
const suggestions = await chatgpt.suggest('names', 'baby boy');
|
|
397
|
-
|
|
410
|
+
chatgpt.alert(suggestions);
|
|
398
411
|
|
|
399
412
|
/* Example output:
|
|
400
413
|
1. Liam
|
|
@@ -433,7 +446,7 @@ Example code:
|
|
|
433
446
|
```js
|
|
434
447
|
(async () => {
|
|
435
448
|
const summary = await chatgpt.summarize('A very long text...');
|
|
436
|
-
|
|
449
|
+
chatgpt.alert(summary); // Example output: 'A very short text...'
|
|
437
450
|
})();
|
|
438
451
|
```
|
|
439
452
|
|
|
@@ -452,7 +465,7 @@ Example code:
|
|
|
452
465
|
```js
|
|
453
466
|
(async () => {
|
|
454
467
|
const translation = await chatgpt.translate('Hello, how are you?', 'spanish');
|
|
455
|
-
|
|
468
|
+
chatgpt.alert(translation); // Alerts: 'Hola, ¿cómo estás?'
|
|
456
469
|
})();
|
|
457
470
|
```
|
|
458
471
|
|
|
@@ -462,7 +475,7 @@ Example code:
|
|
|
462
475
|
|
|
463
476
|
```js
|
|
464
477
|
const randomID = chatgpt.uuidv4();
|
|
465
|
-
|
|
478
|
+
chatgpt.alert(randomID); // Example output: '239067d1-bcb8-4fd7-91eb-9ab94619b7b3'
|
|
466
479
|
```
|
|
467
480
|
|
|
468
481
|
## Page theme
|
|
@@ -494,7 +507,7 @@ Returns a boolean value. `true` if the theme is dark mode, `false` otherwise.
|
|
|
494
507
|
Example code:
|
|
495
508
|
|
|
496
509
|
```js
|
|
497
|
-
|
|
510
|
+
chatgpt.alert(chatgpt.settings.scheme.isDark()); // logs `true` or `false`
|
|
498
511
|
```
|
|
499
512
|
|
|
500
513
|
### isLightMode
|
|
@@ -504,7 +517,7 @@ Returns a boolean value. `true` if the theme is light mode, `false` otherwise.
|
|
|
504
517
|
Example code:
|
|
505
518
|
|
|
506
519
|
```js
|
|
507
|
-
|
|
520
|
+
chatgpt.alert(chatgpt.settings.scheme.isDark()); // logs `true` or `false`
|
|
508
521
|
```
|
|
509
522
|
|
|
510
523
|
### toggleScheme
|
|
@@ -542,10 +555,10 @@ function doSomething() { /* Your code */ }
|
|
|
542
555
|
|
|
543
556
|
function doSomethingElse() { /* Your code */ }
|
|
544
557
|
|
|
545
|
-
function sayHello() {
|
|
558
|
+
function sayHello() { chatgpt.alert('Hello!'); }
|
|
546
559
|
|
|
547
560
|
const alertID = chatgpt.alert('Hello, world!', 'The sky is blue.', [doSomething, doSomethingElse], sayHello, 200);
|
|
548
|
-
|
|
561
|
+
chatgpt.alert(alertID); // Example output: '1693237957878'
|
|
549
562
|
```
|
|
550
563
|
|
|
551
564
|
### notify
|
|
@@ -577,7 +590,7 @@ Returns an account access token as a string.
|
|
|
577
590
|
```js
|
|
578
591
|
(async () => {
|
|
579
592
|
const token = await chatgpt.getAccessToken();
|
|
580
|
-
|
|
593
|
+
chatgpt.alert(token); // Example output: 'abcdef[...]'
|
|
581
594
|
})();
|
|
582
595
|
```
|
|
583
596
|
|
|
@@ -594,10 +607,10 @@ Can be the following: `email`, `id`, `image`, `name`, `picture`. If a single det
|
|
|
594
607
|
```js
|
|
595
608
|
(async () => {
|
|
596
609
|
const accountName = await chatgpt.getAccountDetails('name');
|
|
597
|
-
|
|
610
|
+
chatgpt.alert(accountName); // Example output: 'chatgpt.js'
|
|
598
611
|
|
|
599
612
|
const accountData = await chatgpt.getAccountDetails('name', 'email');
|
|
600
|
-
|
|
613
|
+
chatgpt.alert(accountData);
|
|
601
614
|
/* Example output:
|
|
602
615
|
{
|
|
603
616
|
name: 'chatgpt.js',
|
|
@@ -628,7 +641,7 @@ Example code:
|
|
|
628
641
|
```js
|
|
629
642
|
(async () => {
|
|
630
643
|
const response = await chatgpt.askAndGetReply('Hello, ChatGPT');
|
|
631
|
-
|
|
644
|
+
chatgpt.alert(response); // Example output: 'Hello user, I'm ChatGPT!'
|
|
632
645
|
})();
|
|
633
646
|
```
|
|
634
647
|
|
|
@@ -639,7 +652,7 @@ Clears chat history.
|
|
|
639
652
|
Example code:
|
|
640
653
|
|
|
641
654
|
```js
|
|
642
|
-
chatgpt.clearChats().then(() =>
|
|
655
|
+
chatgpt.clearChats().then(() => chatgpt.alert('Chat history cleared!'));
|
|
643
656
|
```
|
|
644
657
|
|
|
645
658
|
### exportChat `async`
|
|
@@ -829,7 +842,7 @@ Example code:
|
|
|
829
842
|
|
|
830
843
|
```js
|
|
831
844
|
const chatInput = chatgpt.getChatInput();
|
|
832
|
-
|
|
845
|
+
chatgpt.alert(chatInput); // Example output: 'Hello from chatgpt.js!'
|
|
833
846
|
```
|
|
834
847
|
|
|
835
848
|
### getLastPrompt `async`
|
|
@@ -839,7 +852,7 @@ Returns the last message sent by the user as a string.
|
|
|
839
852
|
```js
|
|
840
853
|
(async () => {
|
|
841
854
|
const message = await chatgpt.getLastPrompt();
|
|
842
|
-
|
|
855
|
+
chatgpt.alert(message); // Example output: 'Hello from chatgpt.js!'
|
|
843
856
|
})();
|
|
844
857
|
```
|
|
845
858
|
|
|
@@ -850,15 +863,15 @@ Returns the last ChatGPT response as a string.
|
|
|
850
863
|
```js
|
|
851
864
|
(async () => {
|
|
852
865
|
const response = await chatgpt.getLastResponse();
|
|
853
|
-
|
|
866
|
+
chatgpt.alert(response); // Example output: 'I am ChatGPT!'
|
|
854
867
|
})();
|
|
855
868
|
```
|
|
856
869
|
|
|
857
870
|
### getResponse
|
|
858
871
|
|
|
859
|
-
If it's a previously created chat,
|
|
872
|
+
If it's a previously created chat, see [chatgpt.getResponseFromDOM](#getresponsefromdom)
|
|
860
873
|
|
|
861
|
-
If it's a new chat,
|
|
874
|
+
If it's a new chat, see [chatgpt.getResponseFromAPI](#getresponsefromapi-async)
|
|
862
875
|
|
|
863
876
|
### getResponseFromAPI `async`
|
|
864
877
|
|
|
@@ -875,7 +888,7 @@ Example code:
|
|
|
875
888
|
```js
|
|
876
889
|
(async () => {
|
|
877
890
|
const response = chatgpt.getResponseFromAPI();
|
|
878
|
-
|
|
891
|
+
chatgpt.alert(response); // Example output: 'Hello from ChatGPT!'
|
|
879
892
|
})();
|
|
880
893
|
```
|
|
881
894
|
|
|
@@ -896,19 +909,23 @@ fifthResp = chatgpt.getResponseFromDOM(5); // Returns the 5th response
|
|
|
896
909
|
fifthResp = chatgpt.getResponseFromDOM('fifth'); // Also returns the 5th response
|
|
897
910
|
fifthResp = chatgpt.getResponseFromDOM('five'); // Returns the 5th response too
|
|
898
911
|
|
|
899
|
-
|
|
912
|
+
chatgpt.alert(fifthResp); // Example output: 'Hello from ChatGPT!'
|
|
900
913
|
```
|
|
901
914
|
|
|
902
915
|
### isIdle `async`
|
|
903
916
|
|
|
904
917
|
Resolves a promise when ChatGPT has finished generating a response.
|
|
905
918
|
|
|
919
|
+
**Parameters**:
|
|
920
|
+
|
|
921
|
+
`timeout` (optional): An integer specifying the number of milliseconds to wait before resolving with `false`. If not provided, waits indefinitely until response generation finishes.
|
|
922
|
+
|
|
906
923
|
Example code:
|
|
907
924
|
|
|
908
925
|
```js
|
|
909
926
|
(async () => {
|
|
910
927
|
await chatgpt.code.isIdle();
|
|
911
|
-
|
|
928
|
+
chatgpt.alert('ChatGPT is idle');
|
|
912
929
|
})();
|
|
913
930
|
```
|
|
914
931
|
|
|
@@ -1055,17 +1072,17 @@ Example code:
|
|
|
1055
1072
|
|
|
1056
1073
|
```js
|
|
1057
1074
|
const chatbox = chatgpt.getChatBox();
|
|
1058
|
-
|
|
1075
|
+
chatgpt.alert(chatbox.value); // Example output: 'Hello from chatgpt.js!'
|
|
1059
1076
|
```
|
|
1060
1077
|
|
|
1061
|
-
###
|
|
1078
|
+
### getContinueButton
|
|
1062
1079
|
|
|
1063
1080
|
Returns the 'Continue generating' button as an HTML element.
|
|
1064
1081
|
|
|
1065
1082
|
Example code:
|
|
1066
1083
|
|
|
1067
1084
|
```js
|
|
1068
|
-
const continueBtn = chatgpt.
|
|
1085
|
+
const continueBtn = chatgpt.getContinueButton();
|
|
1069
1086
|
continueBtn.click();
|
|
1070
1087
|
```
|
|
1071
1088
|
|
|
@@ -1235,7 +1252,7 @@ Example code:
|
|
|
1235
1252
|
|
|
1236
1253
|
```js
|
|
1237
1254
|
const timeStamp = chatgpt.autoRefresh.nowTimeStamp();
|
|
1238
|
-
|
|
1255
|
+
chatgpt.alert(timeStamp); // Example output: '1:56:25 PM'
|
|
1239
1256
|
```
|
|
1240
1257
|
|
|
1241
1258
|
## browser `api`
|
|
@@ -1247,7 +1264,7 @@ Returns a boolean value. `true` if system/browser scheme preference is set to li
|
|
|
1247
1264
|
Example code:
|
|
1248
1265
|
|
|
1249
1266
|
```js
|
|
1250
|
-
|
|
1267
|
+
chatgpt.alert(chatgpt.browser.isLightMode()); // logs `true` or `false`
|
|
1251
1268
|
```
|
|
1252
1269
|
|
|
1253
1270
|
### isDarkMode
|
|
@@ -1257,7 +1274,7 @@ Returns a boolean value. `true` if system/browser scheme preference is set to da
|
|
|
1257
1274
|
Example code:
|
|
1258
1275
|
|
|
1259
1276
|
```js
|
|
1260
|
-
|
|
1277
|
+
chatgpt.alert(chatgpt.browser.isDarkMode()); // logs `true` or `false`
|
|
1261
1278
|
```
|
|
1262
1279
|
|
|
1263
1280
|
### isChromium
|
|
@@ -1369,9 +1386,9 @@ Example code:
|
|
|
1369
1386
|
replyBox.style.height = replyBox.scrollHeight + 'px'
|
|
1370
1387
|
prevLength = newLength
|
|
1371
1388
|
}`);
|
|
1372
|
-
|
|
1389
|
+
chatgpt.alert(minifiedCode);
|
|
1373
1390
|
|
|
1374
|
-
/*
|
|
1391
|
+
/* Alerts:
|
|
1375
1392
|
'function autosizeBox(){const n=replyBox.value.length;if(n<prevLength){replyBox.style.height='auto';if(parseInt(getComputedStyle(replyBox).height)<55){replyBox.style.height='2.15rem'}}replyBox.style.height=replyBox.scrollHeight+'px';prevLength=n}' */
|
|
1376
1393
|
})();
|
|
1377
1394
|
```
|
|
@@ -1388,7 +1405,7 @@ Example code:
|
|
|
1388
1405
|
|
|
1389
1406
|
```js
|
|
1390
1407
|
(async () => {
|
|
1391
|
-
|
|
1408
|
+
chatgpt.alert(await chatgpt.code.execute('return 6 + 5')); // logs '11'
|
|
1392
1409
|
})();
|
|
1393
1410
|
```
|
|
1394
1411
|
|
|
@@ -1408,9 +1425,9 @@ Example code:
|
|
|
1408
1425
|
await chatgpt.isIdle();
|
|
1409
1426
|
const response = await chatgpt.getChatData('active', 'msg', 'chatgpt', 'latest'),
|
|
1410
1427
|
scriptCode = chatgpt.code.extract(response);
|
|
1411
|
-
|
|
1428
|
+
chatgpt.alert(scriptCode);
|
|
1412
1429
|
|
|
1413
|
-
/*
|
|
1430
|
+
/* Alerts:
|
|
1414
1431
|
const fs = require('fs');
|
|
1415
1432
|
|
|
1416
1433
|
// Specify the path of the file(s) you want to delete
|
|
@@ -1421,7 +1438,7 @@ Example code:
|
|
|
1421
1438
|
if (err) {
|
|
1422
1439
|
console.error('Error deleting file:', err);
|
|
1423
1440
|
} else {
|
|
1424
|
-
|
|
1441
|
+
chatgpt.alert('File deleted successfully');
|
|
1425
1442
|
}
|
|
1426
1443
|
}); */
|
|
1427
1444
|
})();
|
|
@@ -1431,13 +1448,17 @@ Example code:
|
|
|
1431
1448
|
|
|
1432
1449
|
Resolves a promise when code has finished generating.
|
|
1433
1450
|
|
|
1451
|
+
**Parameters**:
|
|
1452
|
+
|
|
1453
|
+
`timeout` (optional): An integer specifying the number of milliseconds to wait before resolving with `false`. If not provided, waits indefinitely until code generation finishes.
|
|
1454
|
+
|
|
1434
1455
|
Example code:
|
|
1435
1456
|
|
|
1436
1457
|
```js
|
|
1437
1458
|
(async () => {
|
|
1438
1459
|
chatgpt.send('Type me a short code block');
|
|
1439
1460
|
await chatgpt.code.isIdle();
|
|
1440
|
-
|
|
1461
|
+
chatgpt.alert('Code finished generating'); // non-code may still be generating
|
|
1441
1462
|
})();
|
|
1442
1463
|
```
|
|
1443
1464
|
|
|
@@ -1455,9 +1476,9 @@ Example code:
|
|
|
1455
1476
|
(async () => {
|
|
1456
1477
|
const code = `window[elem].addEventListener('mouseover', toggleTooltip)`
|
|
1457
1478
|
const obfuscatedCode = await chatgpt.code.obfuscate(code);
|
|
1458
|
-
|
|
1479
|
+
chatgpt.alert(obfuscatedCode);
|
|
1459
1480
|
|
|
1460
|
-
/*
|
|
1481
|
+
/* Alerts:
|
|
1461
1482
|
'(window[elem])[btoa('YWxlcnRWaWV3')](btoa('bW91c2VyYm94ZXJOYW1l'), btoa('dG9nZ2VkT3V0d2FsbA==')); */
|
|
1462
1483
|
})();
|
|
1463
1484
|
```
|
|
@@ -1483,9 +1504,9 @@ Example code:
|
|
|
1483
1504
|
return false;
|
|
1484
1505
|
}`;
|
|
1485
1506
|
const refactoredCode = await chatgpt.code.refactor(code, 'brevity');
|
|
1486
|
-
|
|
1507
|
+
chatgpt.alert(refactoredCode);
|
|
1487
1508
|
|
|
1488
|
-
/*
|
|
1509
|
+
/* Alerts:
|
|
1489
1510
|
return 6 > 5; */
|
|
1490
1511
|
})();
|
|
1491
1512
|
```
|
|
@@ -1502,7 +1523,7 @@ Example code:
|
|
|
1502
1523
|
|
|
1503
1524
|
```js
|
|
1504
1525
|
(async () => {
|
|
1505
|
-
|
|
1526
|
+
chatgpt.alert(await chatgpt.code.review('btoa("Hello World")'));
|
|
1506
1527
|
|
|
1507
1528
|
/* Example output:
|
|
1508
1529
|
The code appears to be correct. It uses the `btoa` function to encode the string "Hello World" in base64. */
|
|
@@ -1524,9 +1545,9 @@ Example code:
|
|
|
1524
1545
|
const code = `function autosizeBox(){const n=replyBox.value.length;if(n<prevLength){replyBox.style.height='auto';if(parseInt(getComputedStyle(replyBox).height)<55){replyBox.style.height='2.15rem'}}replyBox.style.height=replyBox.scrollHeight+'px';prevLength=n}`;
|
|
1525
1546
|
|
|
1526
1547
|
const minifiedCode = await chatgpt.code.unminify(code);
|
|
1527
|
-
|
|
1548
|
+
chatgpt.alert(minifiedCode);
|
|
1528
1549
|
|
|
1529
|
-
/*
|
|
1550
|
+
/* Alerts:
|
|
1530
1551
|
function autosizeBox() {
|
|
1531
1552
|
const newLength = replyBox.value.length
|
|
1532
1553
|
if (newLength < prevLength) { // if deleting txt
|
|
@@ -1555,15 +1576,85 @@ Example code:
|
|
|
1555
1576
|
```js
|
|
1556
1577
|
(async () => {
|
|
1557
1578
|
const code = await chatgpt.code.write('Repeat a task every 10 seconds', 'javascript');
|
|
1558
|
-
|
|
1579
|
+
chatgpt.alert(code);
|
|
1559
1580
|
|
|
1560
|
-
/*
|
|
1581
|
+
/* Alerts:
|
|
1561
1582
|
setInterval(function() {
|
|
1562
1583
|
// Your task code here
|
|
1563
1584
|
}, 10000); */
|
|
1564
1585
|
})();
|
|
1565
1586
|
```
|
|
1566
1587
|
|
|
1588
|
+
## footer `api`
|
|
1589
|
+
|
|
1590
|
+
API related to the footer.
|
|
1591
|
+
|
|
1592
|
+
### get
|
|
1593
|
+
|
|
1594
|
+
Returns the footer div as an HTML element.
|
|
1595
|
+
|
|
1596
|
+
Example code:
|
|
1597
|
+
|
|
1598
|
+
```js
|
|
1599
|
+
const footerDiv = chatgpt.footer.get();
|
|
1600
|
+
footerDiv.style.padding = '15px'; // make the footer taller
|
|
1601
|
+
```
|
|
1602
|
+
|
|
1603
|
+
### hide
|
|
1604
|
+
|
|
1605
|
+
Hides the footer div.
|
|
1606
|
+
|
|
1607
|
+
Example code:
|
|
1608
|
+
|
|
1609
|
+
```js
|
|
1610
|
+
chatgpt.footer.hide()
|
|
1611
|
+
```
|
|
1612
|
+
|
|
1613
|
+
### show
|
|
1614
|
+
|
|
1615
|
+
Shows the footer div if hidden.
|
|
1616
|
+
|
|
1617
|
+
Example code:
|
|
1618
|
+
|
|
1619
|
+
```js
|
|
1620
|
+
chatgpt.footer.show()
|
|
1621
|
+
```
|
|
1622
|
+
|
|
1623
|
+
## header `api`
|
|
1624
|
+
|
|
1625
|
+
API related to the header.
|
|
1626
|
+
|
|
1627
|
+
### get
|
|
1628
|
+
|
|
1629
|
+
Returns the header div as an HTML element.
|
|
1630
|
+
|
|
1631
|
+
Example code:
|
|
1632
|
+
|
|
1633
|
+
```js
|
|
1634
|
+
const headerDiv = chatgpt.header.get();
|
|
1635
|
+
headerDiv.style.display = none; // hide the header
|
|
1636
|
+
```
|
|
1637
|
+
|
|
1638
|
+
### hide
|
|
1639
|
+
|
|
1640
|
+
Hides the header div.
|
|
1641
|
+
|
|
1642
|
+
Example code:
|
|
1643
|
+
|
|
1644
|
+
```js
|
|
1645
|
+
chatgpt.header.hide()
|
|
1646
|
+
```
|
|
1647
|
+
|
|
1648
|
+
### show
|
|
1649
|
+
|
|
1650
|
+
Shows the header div if hidden.
|
|
1651
|
+
|
|
1652
|
+
Example code:
|
|
1653
|
+
|
|
1654
|
+
```js
|
|
1655
|
+
chatgpt.header.show()
|
|
1656
|
+
```
|
|
1657
|
+
|
|
1567
1658
|
## history `api`
|
|
1568
1659
|
|
|
1569
1660
|
API related to the chat history.
|
|
@@ -1572,12 +1663,16 @@ API related to the chat history.
|
|
|
1572
1663
|
|
|
1573
1664
|
Resolves a promise when chat history has finished loading.
|
|
1574
1665
|
|
|
1666
|
+
**Parameters**:
|
|
1667
|
+
|
|
1668
|
+
`timeout` (optional): An integer specifying the number of milliseconds to wait before resolving with `false`. If not provided, waits indefinitely until chat history finishes loading.
|
|
1669
|
+
|
|
1575
1670
|
Example code:
|
|
1576
1671
|
|
|
1577
1672
|
```js
|
|
1578
1673
|
(async () => {
|
|
1579
1674
|
await chatgpt.history.isLoaded();
|
|
1580
|
-
|
|
1675
|
+
chatgpt.alert('ChatGPT history has finished loading.');
|
|
1581
1676
|
})();
|
|
1582
1677
|
```
|
|
1583
1678
|
|
|
@@ -1693,29 +1788,29 @@ chatgpt.response.continue();
|
|
|
1693
1788
|
|
|
1694
1789
|
### get
|
|
1695
1790
|
|
|
1696
|
-
If it's a previously created chat,
|
|
1791
|
+
If it's a previously created chat, see [chatgpt.getResponseFromDOM](#getresponsefromdom)
|
|
1697
1792
|
|
|
1698
|
-
If it's a new chat,
|
|
1793
|
+
If it's a new chat, see [chatgpt.getResponseFromAPI](#getresponsefromapi-async)
|
|
1699
1794
|
|
|
1700
1795
|
### getFromAPI `async`
|
|
1701
1796
|
|
|
1702
|
-
|
|
1797
|
+
See [chatgpt.getResponseFromAPI](#getresponsefromapi-async)
|
|
1703
1798
|
|
|
1704
1799
|
### getFromDOM
|
|
1705
1800
|
|
|
1706
|
-
|
|
1801
|
+
See [chatgpt.getResponseFromDOM](#getresponsefromdom)
|
|
1707
1802
|
|
|
1708
1803
|
### getLast `async`
|
|
1709
1804
|
|
|
1710
|
-
|
|
1805
|
+
See [chatgpt.getLastResponse](#getlastresponse-async)
|
|
1711
1806
|
|
|
1712
1807
|
### regenerate
|
|
1713
1808
|
|
|
1714
|
-
|
|
1809
|
+
See [chatgpt.regenerate](#regenerate)
|
|
1715
1810
|
|
|
1716
1811
|
### stopGenerating
|
|
1717
1812
|
|
|
1718
|
-
|
|
1813
|
+
See [chatgpt.stop](#stop)
|
|
1719
1814
|
|
|
1720
1815
|
## settings `api`
|
|
1721
1816
|
|
|
@@ -1730,7 +1825,7 @@ Returns a boolean value. `true` if the theme is dark mode, `false` otherwise.
|
|
|
1730
1825
|
Example code:
|
|
1731
1826
|
|
|
1732
1827
|
```js
|
|
1733
|
-
|
|
1828
|
+
chatgpt.alert(chatgpt.settings.scheme.isDark()); // logs `true` or `false`
|
|
1734
1829
|
````
|
|
1735
1830
|
|
|
1736
1831
|
#### isLight
|
|
@@ -1740,7 +1835,7 @@ Returns a boolean value. `true` if the theme is light mode, `false` otherwise.
|
|
|
1740
1835
|
Example code:
|
|
1741
1836
|
|
|
1742
1837
|
```js
|
|
1743
|
-
|
|
1838
|
+
chatgpt.alert(chatgpt.settings.scheme.isLight()); // logs `true` or `false`
|
|
1744
1839
|
````
|
|
1745
1840
|
|
|
1746
1841
|
#### set
|
|
@@ -1811,10 +1906,10 @@ const buttonId = chatgpt.sidebar.append('button', {
|
|
|
1811
1906
|
label: 'I am a button!',
|
|
1812
1907
|
icon: 'https://chat.openai.com/favicon-32x32.png',
|
|
1813
1908
|
onclick: function() {
|
|
1814
|
-
|
|
1909
|
+
chatgpt.alert('Clicked!');
|
|
1815
1910
|
}
|
|
1816
1911
|
});
|
|
1817
|
-
|
|
1912
|
+
chatgpt.alert(buttonId); // Example output: 1693295258727
|
|
1818
1913
|
|
|
1819
1914
|
const dropdownId = chatgpt.sidebar.append('dropdown', {
|
|
1820
1915
|
items: [
|
|
@@ -1822,7 +1917,18 @@ const dropdownId = chatgpt.sidebar.append('dropdown', {
|
|
|
1822
1917
|
{ text: 'Hello there', value: 'hellothere' }
|
|
1823
1918
|
]
|
|
1824
1919
|
});
|
|
1825
|
-
|
|
1920
|
+
chatgpt.alert(dropdownId); // Example output: 1693294795240
|
|
1921
|
+
```
|
|
1922
|
+
|
|
1923
|
+
### exists
|
|
1924
|
+
|
|
1925
|
+
Returns a boolean value. `true` if the sidebar exists , `false` otherwise (e.g. logged out UI).
|
|
1926
|
+
|
|
1927
|
+
Example code:
|
|
1928
|
+
|
|
1929
|
+
```js
|
|
1930
|
+
if (!chatgpt.sidebar.exists())
|
|
1931
|
+
chatgpt.alert('Sidebar is missing!')
|
|
1826
1932
|
```
|
|
1827
1933
|
|
|
1828
1934
|
### isOn
|
|
@@ -1881,14 +1987,18 @@ chatgpt.sidebar.toggle();
|
|
|
1881
1987
|
|
|
1882
1988
|
### isLoaded `async`
|
|
1883
1989
|
|
|
1884
|
-
Resolves a promise when the ChatGPT sidebar has finished loading.
|
|
1990
|
+
Resolves a promise when the ChatGPT sidebar has finished loading.
|
|
1991
|
+
|
|
1992
|
+
**Parameters**:
|
|
1993
|
+
|
|
1994
|
+
`timeout` (optional): An integer specifying the number of milliseconds to wait before resolving with `false`. If not provided, waits 5s or until New Chat link appears (since it is not always present).
|
|
1885
1995
|
|
|
1886
1996
|
Example code:
|
|
1887
1997
|
|
|
1888
1998
|
```js
|
|
1889
1999
|
(async () => {
|
|
1890
2000
|
await chatgpt.sidebar.isLoaded();
|
|
1891
|
-
|
|
2001
|
+
chatgpt.alert('ChatGPT sidebar has finished loading.');
|
|
1892
2002
|
})();
|
|
1893
2003
|
```
|
|
1894
2004
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kudoai/chatgpt.js",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.1",
|
|
4
4
|
"description": "Client-side JavaScript library for ChatGPT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "KudoAI & contributors",
|
|
@@ -69,6 +69,6 @@
|
|
|
69
69
|
"docsify-cli": "^4.4.4",
|
|
70
70
|
"eslint": "^9.10.0",
|
|
71
71
|
"eslint-plugin-json": "^4.0.1",
|
|
72
|
-
"husky": "^9.1.
|
|
72
|
+
"husky": "^9.1.6"
|
|
73
73
|
}
|
|
74
74
|
}
|