@kudoai/chatgpt.js 3.6.2 → 3.7.0
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 +31 -7
- package/chatgpt.js +1036 -1033
- package/dist/chatgpt.min.js +76 -18
- package/docs/README.md +25 -8
- package/docs/USERGUIDE.md +63 -3
- package/package.json +8 -8
- package/starters/chrome/extension/components/icons.js +1 -1
- package/starters/chrome/extension/components/modals.js +8 -5
- package/starters/chrome/extension/content.js +8 -6
- package/starters/chrome/extension/lib/chatgpt.js +1036 -1033
- package/starters/chrome/extension/lib/dom.js +6 -6
- package/starters/chrome/extension/lib/settings.js +2 -2
- package/starters/chrome/extension/manifest.json +1 -1
- package/starters/chrome/extension/popup/controller.js +66 -74
- package/starters/chrome/extension/popup/index.html +1 -6
- package/starters/chrome/extension/popup/style.css +33 -34
- package/starters/chrome/extension/service-worker.js +12 -11
- package/starters/greasemonkey/chatgpt.js-greasemonkey-starter.user.js +2 -2
package/docs/USERGUIDE.md
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
- [getUserLanguage](#getuserlanguage)
|
|
26
26
|
- [isFullScreen](#isfullscreen)
|
|
27
27
|
- [isLoaded `async`](#isloaded-async)
|
|
28
|
+
- [isTempChat](#istempchat)
|
|
28
29
|
- [printAllFunctions](#printallfunctions)
|
|
29
30
|
- [randomFloat](#randomfloat)
|
|
30
31
|
- [renderHTML](#renderhtml)
|
|
@@ -45,6 +46,7 @@
|
|
|
45
46
|
- [User session](#user-session)
|
|
46
47
|
- [getAccessToken `async`](#getaccesstoken-async)
|
|
47
48
|
- [getAccountDetails `async`](#getaccountdetails-async)
|
|
49
|
+
- [login](#login)
|
|
48
50
|
- [logout](#logout)
|
|
49
51
|
- [Chats](#chats)
|
|
50
52
|
- [askAndGetReply `async`](#askandgetreply-async)
|
|
@@ -52,6 +54,7 @@
|
|
|
52
54
|
- [exportChat `async`](#exportchat-async)
|
|
53
55
|
- [getChatData `async`](#getchatdata-async)
|
|
54
56
|
- [getChatInput](#getchatinput)
|
|
57
|
+
- [getErrorMsg](#geterrormsg)
|
|
55
58
|
- [getLastPrompt `async`](#getlastprompt-async)
|
|
56
59
|
- [getLastResponse `async`](#getlastresponse-async)
|
|
57
60
|
- [getResponse](#getresponse)
|
|
@@ -74,12 +77,14 @@
|
|
|
74
77
|
- [getContinueButton](#getContinueButton)
|
|
75
78
|
- [getFooterDiv](#getfooterdiv)
|
|
76
79
|
- [getHeaderDiv](#getheaderdiv)
|
|
80
|
+
- [getLoginButton](#getloginbutton)
|
|
77
81
|
- [getNewChatButton](#getnewchatbutton)
|
|
78
82
|
- [getNewChatLink](#getnewchatlink)
|
|
79
83
|
- [getRegenerateButton](#getregeneratebutton)
|
|
80
84
|
- [getScrollToBottomButton](#getscrolltobottombutton)
|
|
81
85
|
- [getSendButton](#getsendbutton)
|
|
82
86
|
- [getStopGeneratingButton](#getstopgeneratingbutton)
|
|
87
|
+
- [getVoiceButton](#getVoiceButton)
|
|
83
88
|
- [hideFooter](#hidefooter)
|
|
84
89
|
- [hideHeader](#hideheader)
|
|
85
90
|
- [showFooter](#showfooter)
|
|
@@ -160,7 +165,7 @@
|
|
|
160
165
|
|
|
161
166
|
```js
|
|
162
167
|
(async () => {
|
|
163
|
-
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.
|
|
168
|
+
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.7.0/dist/chatgpt.min.js');
|
|
164
169
|
// Your code here...
|
|
165
170
|
})();
|
|
166
171
|
```
|
|
@@ -169,7 +174,7 @@
|
|
|
169
174
|
|
|
170
175
|
```js
|
|
171
176
|
var xhr = new XMLHttpRequest();
|
|
172
|
-
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.
|
|
177
|
+
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.7.0/dist/chatgpt.min.js');
|
|
173
178
|
xhr.onload = function () {
|
|
174
179
|
if (xhr.status === 200) {
|
|
175
180
|
var chatgptJS = document.createElement('script');
|
|
@@ -191,7 +196,7 @@ function yourCode() {
|
|
|
191
196
|
|
|
192
197
|
```js
|
|
193
198
|
...
|
|
194
|
-
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.
|
|
199
|
+
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.7.0/dist/chatgpt.min.js
|
|
195
200
|
// ==/UserScript==
|
|
196
201
|
|
|
197
202
|
// Your code here...
|
|
@@ -329,6 +334,18 @@ Example code:
|
|
|
329
334
|
})();
|
|
330
335
|
```
|
|
331
336
|
|
|
337
|
+
### isTempChat
|
|
338
|
+
|
|
339
|
+
Returns a boolean value. `true` if the website is in Temporary Chat mode and `false` otherwise.
|
|
340
|
+
|
|
341
|
+
Example code:
|
|
342
|
+
|
|
343
|
+
```js
|
|
344
|
+
if (chatgpt.isTempChat()) {
|
|
345
|
+
// Do something
|
|
346
|
+
}
|
|
347
|
+
```
|
|
348
|
+
|
|
332
349
|
### printAllFunctions
|
|
333
350
|
|
|
334
351
|
Prints all the library functions to the console.
|
|
@@ -621,6 +638,16 @@ Can be the following: `email`, `id`, `image`, `name`, `picture`. If a single det
|
|
|
621
638
|
})();
|
|
622
639
|
```
|
|
623
640
|
|
|
641
|
+
### login
|
|
642
|
+
|
|
643
|
+
Navs to login page.
|
|
644
|
+
|
|
645
|
+
Example code:
|
|
646
|
+
|
|
647
|
+
```js
|
|
648
|
+
chatgpt.login();
|
|
649
|
+
```
|
|
650
|
+
|
|
624
651
|
### logout
|
|
625
652
|
|
|
626
653
|
Logs out the user from the website.
|
|
@@ -846,6 +873,17 @@ const chatInput = chatgpt.getChatInput();
|
|
|
846
873
|
chatgpt.alert(chatInput); // Example output: 'Hello from chatgpt.js!'
|
|
847
874
|
```
|
|
848
875
|
|
|
876
|
+
### getErrorMsg
|
|
877
|
+
|
|
878
|
+
Returns the error message (if any) of the last generation as a string.
|
|
879
|
+
|
|
880
|
+
Example code:
|
|
881
|
+
|
|
882
|
+
```js
|
|
883
|
+
const chatErrorMsg = chatgpt.getErrorMsg();
|
|
884
|
+
chatgpt.alert(chatErrorMsg); // Example output: 'Conversation not found'
|
|
885
|
+
```
|
|
886
|
+
|
|
849
887
|
### getLastPrompt `async`
|
|
850
888
|
|
|
851
889
|
Returns the last message sent by the user as a string.
|
|
@@ -1122,6 +1160,17 @@ const headerDiv = chatgpt.getHeaderDiv();
|
|
|
1122
1160
|
headerDiv.style.display = none; // hide the header
|
|
1123
1161
|
```
|
|
1124
1162
|
|
|
1163
|
+
### getLoginButton
|
|
1164
|
+
|
|
1165
|
+
Returns the login button as an HTML element.
|
|
1166
|
+
|
|
1167
|
+
Example code:
|
|
1168
|
+
|
|
1169
|
+
```js
|
|
1170
|
+
const loginBtn = chatgpt.getLoginButton();
|
|
1171
|
+
loginBtn.click(); // navs to login page
|
|
1172
|
+
```
|
|
1173
|
+
|
|
1125
1174
|
### getNewChatButton
|
|
1126
1175
|
|
|
1127
1176
|
Returns the sidebar button (w/ icon) that creates a new chat as an HTML element.
|
|
@@ -1188,6 +1237,17 @@ const stopBtn = chatgpt.getStopGeneratingButton();
|
|
|
1188
1237
|
stopBtn.click();
|
|
1189
1238
|
```
|
|
1190
1239
|
|
|
1240
|
+
### getVoiceButton
|
|
1241
|
+
|
|
1242
|
+
Returns the chatbar button that activates Voice mode as an HTML element.
|
|
1243
|
+
|
|
1244
|
+
Example code:
|
|
1245
|
+
|
|
1246
|
+
```js
|
|
1247
|
+
const voiceBtn = chatgpt.getVoiceButton();
|
|
1248
|
+
getVoiceButton.click(); // activates Voice mode
|
|
1249
|
+
```
|
|
1250
|
+
|
|
1191
1251
|
### hideFooter
|
|
1192
1252
|
|
|
1193
1253
|
Hides the footer div.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kudoai/chatgpt.js",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"description": "Client-side JavaScript library for ChatGPT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "KudoAI & contributors",
|
|
@@ -67,18 +67,18 @@
|
|
|
67
67
|
"bugs": "https://github.com/KudoAI/chatgpt.js/issues",
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@adamlui/minify.js": "^1.8.5",
|
|
70
|
-
"@adamlui/scss-to-css": "^1.10.
|
|
71
|
-
"@eslint/css": "^0.
|
|
70
|
+
"@adamlui/scss-to-css": "^1.10.26",
|
|
71
|
+
"@eslint/css": "^0.3.0",
|
|
72
72
|
"@eslint/json": "^0.10.0",
|
|
73
73
|
"@eslint/markdown": "^6.2.2",
|
|
74
|
-
"@html-eslint/eslint-plugin": "^0.
|
|
75
|
-
"@html-eslint/parser": "^0.
|
|
76
|
-
"@stylistic/eslint-plugin-js": "^
|
|
74
|
+
"@html-eslint/eslint-plugin": "^0.35.0",
|
|
75
|
+
"@html-eslint/parser": "^0.35.0",
|
|
76
|
+
"@stylistic/eslint-plugin-js": "^4.0.1",
|
|
77
77
|
"docsify-cli": "^4.4.4",
|
|
78
|
-
"eslint": "^9.20.
|
|
78
|
+
"eslint": "^9.20.1",
|
|
79
79
|
"eslint-plugin-import": "^2.31.0",
|
|
80
80
|
"eslint-plugin-regexp": "^2.7.0",
|
|
81
|
-
"eslint-plugin-yml": "^1.
|
|
81
|
+
"eslint-plugin-yml": "^1.17.0",
|
|
82
82
|
"get-port": "^7.1.0",
|
|
83
83
|
"husky": "^9.1.7"
|
|
84
84
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
window.icons = {
|
|
4
4
|
import(deps) { Object.assign(this.imports = this.imports || {}, deps) },
|
|
5
5
|
|
|
6
|
-
create(
|
|
6
|
+
create(name, { size = 16, width, height, ...additionalAttrs } = {}) {
|
|
7
7
|
const iconData = icons[name],
|
|
8
8
|
iconAttrs = { width: width || size, height: height || size, ...additionalAttrs }
|
|
9
9
|
if (iconData.type == 'svg') {
|
|
@@ -9,16 +9,19 @@ window.modals = {
|
|
|
9
9
|
about() {
|
|
10
10
|
|
|
11
11
|
// Show modal
|
|
12
|
+
const labelStyles = 'text-transform: uppercase ; font-size: 17px ; font-weight: bold ;'
|
|
13
|
+
+ `color: ${ this.imports.env.ui.scheme == 'dark' ? 'white' : '#494141' }`
|
|
12
14
|
const aboutModal = this.alert(
|
|
13
15
|
`${this.imports.app.symbol} ${chrome.runtime.getManifest().name}`, // title
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
`<span style="${labelStyles}">🧠 Author:</span> `
|
|
17
|
+
+ `<a href="${this.imports.app.author.url}">${this.imports.app.author.name}</a> `
|
|
16
18
|
+ `& <a href="${this.imports.app.urls.contributors}">contributors</a>\n`
|
|
17
|
-
+
|
|
18
|
-
|
|
19
|
+
+ `<span style="${labelStyles}">🏷️ Version:</span> `
|
|
20
|
+
+ `<span class="about-em">${this.imports.app.version}</span>\n`
|
|
21
|
+
+ `<span style="${labelStyles}">📜 Open source code:</span> `
|
|
19
22
|
+ `<a href="${this.imports.app.urls.gitHub}" target="_blank" rel="nopener">`
|
|
20
23
|
+ this.imports.app.urls.gitHub + '</a>\n'
|
|
21
|
-
+
|
|
24
|
+
+ `<span style="${labelStyles}">⚡ Powered by:</span> `
|
|
22
25
|
+ `<a href="${this.imports.app.urls.chatgptJS}" target="_blank" rel="noopener">chatgpt.js</a>`,
|
|
23
26
|
[ function getSupport(){}, function rateUs(){}, function moreAiExtensions(){} ], // button labels
|
|
24
27
|
'', 656 // modal width
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
env.browser.isPortrait = env.browser.isMobile && (window.innerWidth < window.innerHeight)
|
|
13
13
|
|
|
14
14
|
// Import APP data
|
|
15
|
-
const { app } = await chrome.storage.
|
|
15
|
+
const { app } = await chrome.storage.local.get('app')
|
|
16
16
|
|
|
17
17
|
// Export DEPENDENCIES to imported resources
|
|
18
18
|
dom.import({ env }) // for env.ui.scheme
|
|
@@ -24,12 +24,14 @@
|
|
|
24
24
|
notify(...['msg', 'pos', 'notifDuration', 'shadow'].map(arg => req.options[arg]))
|
|
25
25
|
else if (req.action == 'alert')
|
|
26
26
|
modals.alert(...['title', 'msg', 'btns', 'checkbox', 'width'].map(arg => req.options[arg]))
|
|
27
|
-
else if (req.action == 'showAbout')
|
|
28
|
-
|
|
27
|
+
else if (req.action == 'showAbout') {
|
|
28
|
+
config.skipAlert = true ; chatgpt.isLoaded().then(() => modals.open('about'))
|
|
29
|
+
} else if (req.action == 'syncConfigToUI') syncConfigToUI(req.options)
|
|
29
30
|
})
|
|
30
31
|
|
|
31
32
|
// Init SETTINGS
|
|
32
|
-
await settings.load(Object.keys(settings.controls)
|
|
33
|
+
await settings.load(Object.keys(settings.controls))
|
|
34
|
+
if (!config.skipAlert) await settings.load('skipAlert') // only if not showing About modal
|
|
33
35
|
|
|
34
36
|
// Define FUNCTIONS
|
|
35
37
|
|
|
@@ -48,7 +50,7 @@
|
|
|
48
50
|
const stateStyles = {
|
|
49
51
|
on: {
|
|
50
52
|
light: 'color: #5cef48 ; text-shadow: rgba(255,250,169,0.38) 2px 1px 5px',
|
|
51
|
-
dark: 'color: #5cef48 ; text-shadow: rgb(55,
|
|
53
|
+
dark: 'color: #5cef48 ; text-shadow: rgb(55,255,0) 3px 0 10px'
|
|
52
54
|
},
|
|
53
55
|
off: {
|
|
54
56
|
light: 'color: #ef4848 ; text-shadow: rgba(255,169,225,0.44) 2px 1px 5px',
|
|
@@ -99,7 +101,7 @@
|
|
|
99
101
|
modals.alert('≫ ChatGPT extension loaded! 🚀', // title
|
|
100
102
|
'Success! Press Ctrl+Shift+J to view all chatgpt.js methods.', // msg
|
|
101
103
|
function getHelp() { // button
|
|
102
|
-
|
|
104
|
+
open(`${app.urls.gitHub}/issues`) },
|
|
103
105
|
function dontShowAgain() { // checkbox
|
|
104
106
|
settings.save('skipAlert', !config.skipAlert) }
|
|
105
107
|
)
|