@kudoai/chatgpt.js 2.6.8 → 2.6.10
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 +28 -33
- package/chatgpt.js +19 -99
- package/dist/chatgpt.min.js +9 -3
- package/docs/README.md +28 -33
- package/docs/USERGUIDE.md +6 -65
- package/package.json +13 -13
- package/starters/chrome/LICENSE.md +2 -2
- package/starters/chrome/docs/README.md +2 -2
- package/starters/chrome/docs/SECURITY.md +2 -2
- package/starters/chrome/extension/lib/chatgpt.js +19 -99
- package/starters/chrome/extension/manifest.json +1 -1
- package/starters/chrome/extension/popup/index.html +1 -1
- package/starters/chrome/extension/popup/popup.js +1 -1
- package/starters/docs/README.md +1 -1
- package/starters/greasemonkey/LICENSE.md +2 -2
- package/starters/greasemonkey/chatgpt.js-greasemonkey-starter.user.js +2 -2
- package/starters/greasemonkey/docs/SECURITY.md +2 -2
- package/docs/de/LICENSE.md +0 -29
- package/docs/de/README.md +0 -345
- package/docs/de/SECURITY.md +0 -25
- package/docs/es/LICENSE.md +0 -29
- package/docs/es/README.md +0 -345
- package/docs/es/SECURITY.md +0 -25
- package/docs/fr/LICENSE.md +0 -29
- package/docs/fr/README.md +0 -345
- package/docs/fr/SECURITY.md +0 -25
- package/docs/hi/LICENSE.md +0 -29
- package/docs/hi/README.md +0 -346
- package/docs/hi/SECURITY.md +0 -25
- package/docs/it/LICENSE.md +0 -27
- package/docs/it/README.md +0 -345
- package/docs/it/SECURITY.md +0 -25
- package/docs/ja/LICENSE.md +0 -29
- package/docs/ja/README.md +0 -345
- package/docs/ja/SECURITY.md +0 -25
- package/docs/ko/LICENSE.md +0 -32
- package/docs/ko/README.md +0 -350
- package/docs/ko/SECURITY.md +0 -25
- package/docs/ne/LICENSE.md +0 -35
- package/docs/ne/README.md +0 -346
- package/docs/ne/SECURITY.md +0 -25
- package/docs/nl/LICENSE.md +0 -29
- package/docs/nl/README.md +0 -345
- package/docs/nl/SECURITY.md +0 -25
- package/docs/pt/LICENSE.md +0 -29
- package/docs/pt/README.md +0 -345
- package/docs/pt/SECURITY.md +0 -25
- package/docs/vi/LICENSE.md +0 -29
- package/docs/vi/README.md +0 -345
- package/docs/vi/SECURITY.md +0 -25
- package/docs/zh-cn/LICENSE.md +0 -29
- package/docs/zh-cn/README.md +0 -344
- package/docs/zh-cn/SECURITY.md +0 -25
- package/docs/zh-tw/LICENSE.md +0 -29
- package/docs/zh-tw/README.md +0 -344
- package/docs/zh-tw/SECURITY.md +0 -25
- package/starters/chrome/docs/de/LICENSE.md +0 -31
- package/starters/chrome/docs/de/README.md +0 -93
- package/starters/chrome/docs/es/LICENSE.md +0 -31
- package/starters/chrome/docs/es/README.md +0 -93
- package/starters/chrome/docs/fr/LICENSE.md +0 -31
- package/starters/chrome/docs/fr/README.md +0 -93
- package/starters/chrome/docs/hi/LICENSE.md +0 -31
- package/starters/chrome/docs/hi/README.md +0 -93
- package/starters/chrome/docs/hi/SECURITY.md +0 -17
- package/starters/chrome/docs/it/LICENSE.md +0 -29
- package/starters/chrome/docs/it/README.md +0 -93
- package/starters/chrome/docs/ja/LICENSE.md +0 -31
- package/starters/chrome/docs/ja/README.md +0 -93
- package/starters/chrome/docs/ko/LICENSE.md +0 -34
- package/starters/chrome/docs/ko/README.md +0 -93
- package/starters/chrome/docs/nl/LICENSE.md +0 -31
- package/starters/chrome/docs/nl/README.md +0 -93
- package/starters/chrome/docs/pt/LICENSE.md +0 -31
- package/starters/chrome/docs/pt/README.md +0 -93
- package/starters/chrome/docs/vi/LICENSE.md +0 -31
- package/starters/chrome/docs/vi/README.md +0 -93
- package/starters/chrome/docs/zh-cn/LICENSE.md +0 -31
- package/starters/chrome/docs/zh-cn/README.md +0 -93
- package/starters/chrome/docs/zh-cn/SECURITY.md +0 -17
- package/starters/chrome/docs/zh-tw/LICENSE.md +0 -31
- package/starters/chrome/docs/zh-tw/README.md +0 -93
- package/starters/docs/de/LICENSE.md +0 -13
- package/starters/docs/de/README.md +0 -29
- package/starters/docs/es/LICENSE.md +0 -13
- package/starters/docs/es/README.md +0 -29
- package/starters/docs/fr/LICENSE.md +0 -13
- package/starters/docs/fr/README.md +0 -29
- package/starters/docs/hi/LICENSE.md +0 -13
- package/starters/docs/hi/README.md +0 -29
- package/starters/docs/it/LICENSE.md +0 -11
- package/starters/docs/it/README.md +0 -29
- package/starters/docs/ja/LICENSE.md +0 -13
- package/starters/docs/ja/README.md +0 -30
- package/starters/docs/ko/LICENSE.md +0 -16
- package/starters/docs/ko/README.md +0 -29
- package/starters/docs/nl/LICENSE.md +0 -13
- package/starters/docs/nl/README.md +0 -29
- package/starters/docs/pt/LICENSE.md +0 -13
- package/starters/docs/pt/README.md +0 -29
- package/starters/docs/vi/LICENSE.md +0 -13
- package/starters/docs/vi/README.md +0 -29
- package/starters/docs/zh-cn/LICENSE.md +0 -13
- package/starters/docs/zh-cn/README.md +0 -30
- package/starters/docs/zh-tw/LICENSE.md +0 -13
- package/starters/docs/zh-tw/README.md +0 -29
- package/starters/greasemonkey/docs/de/LICENSE.md +0 -31
- package/starters/greasemonkey/docs/es/LICENSE.md +0 -31
- package/starters/greasemonkey/docs/fr/LICENSE.md +0 -31
- package/starters/greasemonkey/docs/hi/LICENSE.md +0 -31
- package/starters/greasemonkey/docs/hi/SECURITY.md +0 -17
- package/starters/greasemonkey/docs/it/LICENSE.md +0 -29
- package/starters/greasemonkey/docs/ja/LICENSE.md +0 -31
- package/starters/greasemonkey/docs/ko/LICENSE.md +0 -34
- package/starters/greasemonkey/docs/nl/LICENSE.md +0 -31
- package/starters/greasemonkey/docs/pt/LICENSE.md +0 -31
- package/starters/greasemonkey/docs/vi/LICENSE.md +0 -31
- package/starters/greasemonkey/docs/zh-cn/LICENSE.md +0 -31
- package/starters/greasemonkey/docs/zh-cn/SECURITY.md +0 -17
- package/starters/greasemonkey/docs/zh-tw/LICENSE.md +0 -31
package/docs/USERGUIDE.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
3
|
<picture>
|
|
4
|
-
<source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://
|
|
5
|
-
<img width=700 src="https://
|
|
4
|
+
<source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://media.chatgptjs.org/images/logos/chatgpt.js/with-reflection/darkmode.png?bc68d0c">
|
|
5
|
+
<img width=700 src="https://media.chatgptjs.org/images/logos/chatgpt.js/with-reflection/lightmode.png?bc68d0c">
|
|
6
6
|
</picture>
|
|
7
7
|
|
|
8
8
|
**chatgpt.js** is a powerful JavaScript library that allows for super easy interaction w/ the ChatGPT DOM.
|
|
@@ -99,12 +99,7 @@
|
|
|
99
99
|
- [unminify `async`](#unminify-async)
|
|
100
100
|
- [write `async`](#write-async)
|
|
101
101
|
- [history `api`](#history-api)
|
|
102
|
-
- [isOn](#ison)
|
|
103
|
-
- [isOff](#isoff)
|
|
104
|
-
- [activate](#activate-1)
|
|
105
|
-
- [deactivate](#deactivate-1)
|
|
106
102
|
- [isLoaded](#isloaded-async-1)
|
|
107
|
-
- [toggle](#toggle)
|
|
108
103
|
- [instructions `api`](#instructions-api)
|
|
109
104
|
- [add `async`](#add-async)
|
|
110
105
|
- [clear `async`](#clear-async)
|
|
@@ -137,13 +132,13 @@
|
|
|
137
132
|
|
|
138
133
|
# Importing the library
|
|
139
134
|
|
|
140
|
-
> **Note** _To always import the latest version (
|
|
135
|
+
> **Note** _To always import the latest version (not recommended in production!) replace the versioned jsDelivr URL with: `https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js/chatgpt.min.js`_
|
|
141
136
|
|
|
142
137
|
## ES6
|
|
143
138
|
|
|
144
139
|
```js
|
|
145
140
|
(async () => {
|
|
146
|
-
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.6.
|
|
141
|
+
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.6.10/dist/chatgpt.min.js');
|
|
147
142
|
// Your code here...
|
|
148
143
|
})();
|
|
149
144
|
```
|
|
@@ -152,7 +147,7 @@
|
|
|
152
147
|
|
|
153
148
|
```js
|
|
154
149
|
var xhr = new XMLHttpRequest();
|
|
155
|
-
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.6.
|
|
150
|
+
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.6.10/dist/chatgpt.min.js');
|
|
156
151
|
xhr.onload = function () {
|
|
157
152
|
if (xhr.status === 200) {
|
|
158
153
|
var chatgptJS = document.createElement('script');
|
|
@@ -174,7 +169,7 @@ function yourCode() {
|
|
|
174
169
|
|
|
175
170
|
```js
|
|
176
171
|
...
|
|
177
|
-
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.6.
|
|
172
|
+
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.6.10/dist/chatgpt.min.js
|
|
178
173
|
// ==/UserScript==
|
|
179
174
|
|
|
180
175
|
// Your code here...
|
|
@@ -1450,50 +1445,6 @@ Example code:
|
|
|
1450
1445
|
|
|
1451
1446
|
API related to the chat history.
|
|
1452
1447
|
|
|
1453
|
-
### isOn
|
|
1454
|
-
|
|
1455
|
-
Returns a boolean value. `true` if the chat history is enabled, `false` otherwise.
|
|
1456
|
-
|
|
1457
|
-
Example code:
|
|
1458
|
-
|
|
1459
|
-
```js
|
|
1460
|
-
if (chatgpt.history.isOn()) {
|
|
1461
|
-
// Do something
|
|
1462
|
-
}
|
|
1463
|
-
```
|
|
1464
|
-
|
|
1465
|
-
### isOff
|
|
1466
|
-
|
|
1467
|
-
Returns a boolean value. `true` if the chat history is disabled, `false` otherwise.
|
|
1468
|
-
|
|
1469
|
-
Example code:
|
|
1470
|
-
|
|
1471
|
-
```js
|
|
1472
|
-
if (chatgpt.history.isOff()) {
|
|
1473
|
-
// Do something
|
|
1474
|
-
}
|
|
1475
|
-
```
|
|
1476
|
-
|
|
1477
|
-
### activate
|
|
1478
|
-
|
|
1479
|
-
Activates the chat history.
|
|
1480
|
-
|
|
1481
|
-
Example code:
|
|
1482
|
-
|
|
1483
|
-
```js
|
|
1484
|
-
chatgpt.history.activate();
|
|
1485
|
-
```
|
|
1486
|
-
|
|
1487
|
-
### deactivate
|
|
1488
|
-
|
|
1489
|
-
Deactivates the chat history.
|
|
1490
|
-
|
|
1491
|
-
Example code:
|
|
1492
|
-
|
|
1493
|
-
```js
|
|
1494
|
-
chatgpt.history.deactivate();
|
|
1495
|
-
```
|
|
1496
|
-
|
|
1497
1448
|
### isLoaded `async`
|
|
1498
1449
|
|
|
1499
1450
|
Resolves a promise when chat history has finished loading.
|
|
@@ -1507,16 +1458,6 @@ Example code:
|
|
|
1507
1458
|
})();
|
|
1508
1459
|
```
|
|
1509
1460
|
|
|
1510
|
-
### toggle
|
|
1511
|
-
|
|
1512
|
-
Toggles the chat history.
|
|
1513
|
-
|
|
1514
|
-
Example code:
|
|
1515
|
-
|
|
1516
|
-
```js
|
|
1517
|
-
chatgpt.history.toggle();
|
|
1518
|
-
```
|
|
1519
|
-
|
|
1520
1461
|
## instructions `api`
|
|
1521
1462
|
|
|
1522
1463
|
### add `async`
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kudoai/chatgpt.js",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.10",
|
|
4
4
|
"description": "Client-side JavaScript library for ChatGPT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "KudoAI & contributors",
|
|
7
|
-
"email": "
|
|
7
|
+
"email": "opensource@kudoai.com",
|
|
8
8
|
"url": "https://www.kudoai.com"
|
|
9
9
|
},
|
|
10
10
|
"homepage": "https://chatgpt.js.org",
|
|
@@ -13,17 +13,18 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"chatgpt.js",
|
|
15
15
|
"dist/chatgpt.min.js",
|
|
16
|
-
"docs
|
|
17
|
-
"starters/"
|
|
16
|
+
"docs/*.md",
|
|
17
|
+
"starters/",
|
|
18
|
+
"!starters/**/docs/*/"
|
|
18
19
|
],
|
|
19
20
|
"scripts": {
|
|
20
|
-
"lint": "eslint . --
|
|
21
|
-
"lint:all": "eslint .
|
|
22
|
-
"lint:fix": "eslint . --
|
|
23
|
-
"lint:fix-all": "eslint . --
|
|
21
|
+
"lint": "eslint . --cache",
|
|
22
|
+
"lint:all": "eslint .",
|
|
23
|
+
"lint:fix": "eslint . --fix --cache",
|
|
24
|
+
"lint:fix-all": "eslint . --fix",
|
|
24
25
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
25
26
|
"preview:docs": "docsify serve docs",
|
|
26
|
-
"build:js": "
|
|
27
|
+
"build:js": "bash utils/build.sh",
|
|
27
28
|
"build:css": "scss-to-css",
|
|
28
29
|
"bump:patch": "bash utils/bump.sh patch",
|
|
29
30
|
"bump:minor": "bash utils/bump.sh minor",
|
|
@@ -62,12 +63,11 @@
|
|
|
62
63
|
"url": "https://github.com/sponsors/KudoAI"
|
|
63
64
|
},
|
|
64
65
|
"devDependencies": {
|
|
65
|
-
"@adamlui/minify.js": "^1.
|
|
66
|
-
"@adamlui/scss-to-css": "^1.
|
|
66
|
+
"@adamlui/minify.js": "^1.6.1",
|
|
67
|
+
"@adamlui/scss-to-css": "^1.9.0",
|
|
67
68
|
"docsify-cli": "^4.4.4",
|
|
68
|
-
"eslint": "^
|
|
69
|
+
"eslint": "^9.2.0",
|
|
69
70
|
"eslint-plugin-json-schema-validator": "^5.1.0",
|
|
70
|
-
"eslint-plugin-yml": "^1.14.0",
|
|
71
71
|
"husky": "^9.0.11"
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -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://
|
|
5
|
-
<img height=14 src="https://
|
|
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">
|
|
6
6
|
</picture>
|
|
7
7
|
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://
|
|
5
|
-
<img height=14 src="https://
|
|
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">
|
|
6
6
|
</picture>
|
|
7
7
|
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://
|
|
5
|
-
<img height=14 src="https://
|
|
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">
|
|
6
6
|
</picture>
|
|
7
7
|
English |
|
|
8
8
|
<a href="https://github.com/KudoAI/chatgpt.js-chrome-starter/blob/main/docs/zh-cn/SECURITY.md">简体中文</a> |
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// © 2023–2024 KudoAI & contributors under the MIT license.
|
|
2
2
|
// Source: https://github.com/KudoAI/chatgpt.js
|
|
3
|
+
// User guide: https://chatgptjs.org/userguide
|
|
3
4
|
// Latest minified release: https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js/chatgpt.min.js
|
|
4
5
|
|
|
5
6
|
// Init endpoints
|
|
6
7
|
const endpoints = {
|
|
7
|
-
assets: 'https://
|
|
8
|
+
assets: 'https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js',
|
|
8
9
|
openAI: {
|
|
9
|
-
session: 'https://
|
|
10
|
+
session: 'https://chatgpt.com/api/auth/session',
|
|
10
11
|
chats: 'https://chat.openai.com/backend-api/conversations',
|
|
11
12
|
chat: 'https://chat.openai.com/backend-api/conversation',
|
|
12
13
|
share_create: 'https://chat.openai.com/backend-api/share/create',
|
|
@@ -17,50 +18,10 @@ const endpoints = {
|
|
|
17
18
|
|
|
18
19
|
// Init feedback properties
|
|
19
20
|
localStorage.alertQueue = JSON.stringify([]);
|
|
20
|
-
localStorage.notifyProps = JSON.stringify({
|
|
21
|
-
queue: { topRight: [], bottomRight: [], bottomLeft: [], topLeft: [] },
|
|
22
|
-
lastNthAudio: 0 // to prevent immediate repetition of base sound
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Init environment flags & functions
|
|
26
|
-
const isChromeUserScript = navigator.userAgent.includes('Chrome') && typeof unsafeWindow != 'undefined',
|
|
27
|
-
isFFuserScript = navigator.userAgent.includes('Firefox') && typeof unsafeWindow != 'undefined',
|
|
28
|
-
isFFtmScript = isFFuserScript && GM_info.scriptHandler == 'Tampermonkey';
|
|
29
|
-
|
|
30
|
-
// Define messages
|
|
31
|
-
let cjsMessages;
|
|
32
|
-
if (!isChromeUserScript && !(isFFuserScript && !isFFtmScript)) { (async () => {
|
|
33
|
-
const cjsMsgsLoaded = new Promise(resolve => {
|
|
34
|
-
const userLanguage = navigator.languages[0] || navigator.language || navigator.browserLanguage ||
|
|
35
|
-
navigator.systemLanguage || navigator.userLanguage || '',
|
|
36
|
-
msgHostDir = endpoints.assets + '/data/_locales/',
|
|
37
|
-
msgLocaleDir = ( userLanguage ? userLanguage.replace('-', '_') : 'en' ) + '/';
|
|
38
|
-
let msgHref = msgHostDir + msgLocaleDir + 'messages.json', msgXHRtries = 0;
|
|
39
|
-
(function loadMsgs() {
|
|
40
|
-
const xhr = new XMLHttpRequest();
|
|
41
|
-
xhr.open('GET', msgHref); xhr.send();
|
|
42
|
-
xhr.onload = () => {
|
|
43
|
-
try { // to return localized messages.json
|
|
44
|
-
const messages = new Proxy(JSON.parse(xhr.responseText), {
|
|
45
|
-
get(target, prop) { // remove need to ref nested keys
|
|
46
|
-
if (typeof target[prop] == 'object' && target[prop] !== null && 'message' in target[prop]) {
|
|
47
|
-
return target[prop].message;
|
|
48
|
-
}}}); resolve(messages);
|
|
49
|
-
} catch (err) {
|
|
50
|
-
msgXHRtries++; if (msgXHRtries === 3) resolve({}); // try up to 3X (original/region-stripped/EN) only
|
|
51
|
-
msgHref = userLanguage.includes('-') && msgXHRtries === 1 ? // if regional lang on 1st try...
|
|
52
|
-
msgHref.replace(/([^_]*)_[^/]*(\/.*)/, '$1$2') // ...strip region before retrying
|
|
53
|
-
: ( msgHostDir + 'en/messages.json' ); // else use default English messages
|
|
54
|
-
loadMsgs();
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
xhr.onerror = () => { resolve({}); };
|
|
58
|
-
})();
|
|
59
|
-
}); cjsMessages = await cjsMsgsLoaded;
|
|
60
|
-
})();}
|
|
21
|
+
localStorage.notifyProps = JSON.stringify({ queue: { topRight: [], bottomRight: [], bottomLeft: [], topLeft: [] }});
|
|
61
22
|
|
|
62
23
|
// Define chatgpt.methods
|
|
63
|
-
const chatgpt = {
|
|
24
|
+
const chatgpt = { // eslint-disable-line no-redeclare
|
|
64
25
|
openAIaccessToken: {},
|
|
65
26
|
|
|
66
27
|
actAs: function(persona) {
|
|
@@ -236,7 +197,7 @@ const chatgpt = {
|
|
|
236
197
|
|
|
237
198
|
// Create close button
|
|
238
199
|
const closeBtn = document.createElement('div');
|
|
239
|
-
closeBtn.title =
|
|
200
|
+
closeBtn.title = 'Close'; closeBtn.classList.add('modal-close-btn');
|
|
240
201
|
const closeSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
241
202
|
closeSVG.setAttribute('height', '10px');
|
|
242
203
|
closeSVG.setAttribute('viewBox', '0 0 14 14');
|
|
@@ -426,23 +387,17 @@ const chatgpt = {
|
|
|
426
387
|
|
|
427
388
|
if (method == 'dom') {
|
|
428
389
|
try { await chatgpt.getChatData(); } catch { return; } // check if chat history exists
|
|
429
|
-
chatgpt.menu.open();
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
if (/settings/i.test(menuItem.text)) { menuItem.click(); break; }
|
|
390
|
+
chatgpt.menu.open(); setTimeout(() => { // open settings
|
|
391
|
+
const settingsBtn = document.querySelector(
|
|
392
|
+
'a[role="menuitem"] svg path[d*="M11.6439 3C10.9352"]').parentNode.parentNode;
|
|
393
|
+
if (settingsBtn) settingsBtn.click();
|
|
434
394
|
setTimeout(() => { // clear chats
|
|
435
|
-
const settingsBtns = document.querySelectorAll('[id*=radix] button')
|
|
436
|
-
|
|
437
|
-
|
|
395
|
+
const settingsBtns = document.querySelectorAll('[id*=radix] button'),
|
|
396
|
+
deleteBtn = settingsBtns[settingsBtns.length - 1];
|
|
397
|
+
if (deleteBtn) deleteBtn.click();
|
|
438
398
|
setTimeout(() => { // confirm clear
|
|
439
|
-
document.querySelector('[
|
|
440
|
-
setTimeout(() => {
|
|
441
|
-
exitMenu();
|
|
442
|
-
try { document.querySelector('#prompt-textarea').focus(); } catch (err) {}
|
|
443
|
-
}, 10);
|
|
399
|
+
document.querySelector('button[class*="danger"').click();
|
|
444
400
|
}, 10); }, 333); }, 10);
|
|
445
|
-
const exitMenu = () => { document.querySelector('div[id*=radix] button').click(); };
|
|
446
401
|
|
|
447
402
|
} else { // API method
|
|
448
403
|
// NOTE: DOM is not updated to reflect new empty chat list (until session refresh)
|
|
@@ -835,7 +790,7 @@ const chatgpt = {
|
|
|
835
790
|
|
|
836
791
|
// Fill [userMessages]
|
|
837
792
|
for (const key in data)
|
|
838
|
-
if (
|
|
793
|
+
if (data[key].message != null && data[key].message.author.role == 'user')
|
|
839
794
|
userMessages.push({ id: data[key].id, msg: data[key].message });
|
|
840
795
|
userMessages.sort((a, b) => a.msg.create_time - b.msg.create_time); // sort in chronological order
|
|
841
796
|
|
|
@@ -847,7 +802,7 @@ const chatgpt = {
|
|
|
847
802
|
for (const userMessage of userMessages) {
|
|
848
803
|
let sub = [];
|
|
849
804
|
for (const key in data) {
|
|
850
|
-
if (
|
|
805
|
+
if (data[key].message != null && data[key].message.author.role == 'assistant' && data[key].parent == userMessage.id) {
|
|
851
806
|
sub.push(data[key].message);
|
|
852
807
|
}
|
|
853
808
|
}
|
|
@@ -944,17 +899,6 @@ const chatgpt = {
|
|
|
944
899
|
navigator.systemLanguage || navigator.userLanguage || ''; },
|
|
945
900
|
|
|
946
901
|
history: {
|
|
947
|
-
activate: function() { this.isOff() ? this.toggle() : console.info('Chat history is already enabled!'); },
|
|
948
|
-
deactivate: function() { this.isOn() ? this.toggle() : console.info('Chat history is already disabled!'); },
|
|
949
|
-
|
|
950
|
-
isOn: function() {
|
|
951
|
-
const navDivs = document.querySelectorAll('nav div'),
|
|
952
|
-
offDiv = [...navDivs].find(div => div.textContent.includes('Chat History is off')) || {};
|
|
953
|
-
return offDiv.classList.toString().includes('invisible');
|
|
954
|
-
},
|
|
955
|
-
|
|
956
|
-
isOff: function() { return !this.isOn(); },
|
|
957
|
-
|
|
958
902
|
isLoaded: function() {
|
|
959
903
|
return new Promise(resolve => {
|
|
960
904
|
const checkChatHistory = () => {
|
|
@@ -962,13 +906,7 @@ const chatgpt = {
|
|
|
962
906
|
else setTimeout(checkChatHistory, 100);
|
|
963
907
|
};
|
|
964
908
|
checkChatHistory();
|
|
965
|
-
});}
|
|
966
|
-
|
|
967
|
-
toggle: function() {
|
|
968
|
-
for (const navBtn of document.querySelectorAll('nav button')) {
|
|
969
|
-
if (/chat history/i.test(navBtn.textContent)) {
|
|
970
|
-
navBtn.click(); return;
|
|
971
|
-
}}}
|
|
909
|
+
});}
|
|
972
910
|
},
|
|
973
911
|
|
|
974
912
|
instructions: {
|
|
@@ -1239,7 +1177,7 @@ const chatgpt = {
|
|
|
1239
1177
|
|
|
1240
1178
|
// Create/append close button
|
|
1241
1179
|
const closeBtn = document.createElement('div');
|
|
1242
|
-
closeBtn.title =
|
|
1180
|
+
closeBtn.title = 'Dismiss'; closeBtn.classList.add('notif-close-btn');
|
|
1243
1181
|
const closeSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
1244
1182
|
closeSVG.setAttribute('height', '8px');
|
|
1245
1183
|
closeSVG.setAttribute('viewBox', '0 0 14 14');
|
|
@@ -1318,28 +1256,10 @@ const chatgpt = {
|
|
|
1318
1256
|
const hideDelay = fadeDuration > notifDuration ? 0 // don't delay if fade exceeds notification duration
|
|
1319
1257
|
: notifDuration - fadeDuration; // otherwise delay for difference
|
|
1320
1258
|
|
|
1321
|
-
// Init/schedule audio feedback
|
|
1322
|
-
let dismissAudio, dismissAudioTID; // be accessible to `dismissNotif()`
|
|
1323
|
-
if (isFFtmScript) {
|
|
1324
|
-
// Init base audio index
|
|
1325
|
-
let nthAudio; do nthAudio = Math.floor(Math.random() * 3) + 1; // randomize between 1-3...
|
|
1326
|
-
while (nthAudio === notifyProps.lastNthAudio); // ...until distinct from prev index (for variety)
|
|
1327
|
-
notifyProps.lastNthAudio = nthAudio; localStorage.notifyProps = JSON.stringify(notifyProps);
|
|
1328
|
-
|
|
1329
|
-
// Build audio element + src URL
|
|
1330
|
-
dismissAudio = new Audio();
|
|
1331
|
-
dismissAudio.src = endpoints.assets + '/media/audio/notifications/bubble-pop/'
|
|
1332
|
-
+ `${ nthAudio }-${ notificationDiv.isRight ? 'right' : 'left' }.mp3`;
|
|
1333
|
-
|
|
1334
|
-
// Schedule playback
|
|
1335
|
-
dismissAudioTID = setTimeout(() => dismissAudio.play().catch(() => {}), hideDelay * 1000);
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
1259
|
// Add notification dismissal to timeout schedule + button clicks
|
|
1339
1260
|
const dismissNotif = () => {
|
|
1340
1261
|
notificationDiv.style.animation = `notif-zoom-fade-out ${ fadeDuration }s ease-out`;
|
|
1341
|
-
|
|
1342
|
-
clearTimeout(dismissFuncTID); clearTimeout(dismissAudioTID);
|
|
1262
|
+
clearTimeout(dismissFuncTID);
|
|
1343
1263
|
};
|
|
1344
1264
|
const dismissFuncTID = setTimeout(dismissNotif, hideDelay * 1000); // maintain visibility for `hideDelay` secs, then dismiss
|
|
1345
1265
|
closeSVG.addEventListener('click', dismissNotif, { once: true }); // add to close button clicks
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
</div>
|
|
43
43
|
-->
|
|
44
44
|
<footer>
|
|
45
|
-
<div class="chatgpt-js"><a title="Powered by chatgpt.js" href="https://chatgpt.js.org" target="_blank" rel="noopener"><img src="https://
|
|
45
|
+
<div class="chatgpt-js"><a title="Powered by chatgpt.js" href="https://chatgpt.js.org" target="_blank" rel="noopener"><img src="https://media.chatgptjs.org/images/badges/powered-by-chatgpt.js-faded.png"></a></div>
|
|
46
46
|
<span title="Check for Updates" class="menu-icon menu-area" style="right:58px ; padding-top: 7px" >
|
|
47
47
|
<img width=15 height=15 src="https://i.imgur.com/Luxs8j5.png" style="margin-top: 0.04rem">
|
|
48
48
|
</span>
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
// Add Powered by chatgpt.js hover-listener
|
|
45
|
-
const chatGPTjsHostPath = 'https://
|
|
45
|
+
const chatGPTjsHostPath = 'https://media.chatgptjs.org/images/badges/',
|
|
46
46
|
chatGPTjsImg = document.querySelector('.chatgpt-js img');
|
|
47
47
|
chatGPTjsImg.addEventListener('mouseover', () => {
|
|
48
48
|
chatGPTjsImg.src = chatGPTjsHostPath + 'powered-by-chatgpt.js.png'; });
|
package/starters/docs/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Template for creating a Chrome extension using chatgpt.js (including pop-up menu
|
|
|
18
18
|
|
|
19
19
|
[Repo](https://github.com/KudoAI/chatgpt.js-chrome-starter) / [Readme](../chrome#readme) / [Get help](https://github.com/KudoAI/chatgpt.js-chrome-starter/issues)
|
|
20
20
|
|
|
21
|
-
<h2><a href="../greasemonkey"><img style="margin: 0 2px -0.065rem 0" height=19 src="https://
|
|
21
|
+
<h2><a href="../greasemonkey"><img style="margin: 0 2px -0.065rem 0" height=19 src="https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@e26f2cf/starters/media/images/icons/tampermonkey-icon28.png"><img style="margin: 0 2px -0.035rem 1px" height=19.5 src="https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@0c37090/starters/media/images/icons/violentmonkey-icon100.png"></a> <a href="../greasemonkey">Greasemonkey starter</a></h2>
|
|
22
22
|
|
|
23
23
|
Template for creating a Greasemonkey userscript using chatgpt.js
|
|
24
24
|
|
|
@@ -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://
|
|
5
|
-
<img height=14 src="https://
|
|
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">
|
|
6
6
|
</picture>
|
|
7
7
|
English |
|
|
8
8
|
<a href="docs/zh-cn/LICENSE.md">简体中文</a> |
|
|
@@ -3,12 +3,12 @@
|
|
|
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.
|
|
6
|
+
// @version 2024.5.7
|
|
7
7
|
// @license MIT
|
|
8
8
|
// @match https://chat.openai.com/*
|
|
9
9
|
// @icon https://raw.githubusercontent.com/KudoAI/chatgpt.js-greasemonkey-starter/main/media/images/icons/robot/icon48.png
|
|
10
10
|
// @icon64 https://raw.githubusercontent.com/KudoAI/chatgpt.js-greasemonkey-starter/main/media/images/icons/robot/icon64.png
|
|
11
|
-
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.6.
|
|
11
|
+
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.6.10/dist/chatgpt.min.js
|
|
12
12
|
// @grant GM_getValue
|
|
13
13
|
// @grant GM_setValue
|
|
14
14
|
// @noframes
|
|
@@ -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://
|
|
5
|
-
<img height=14 src="https://
|
|
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">
|
|
6
6
|
</picture>
|
|
7
7
|
English |
|
|
8
8
|
<a href="https://github.com/KudoAI/chatgpt.js-greasemonkey-starter/blob/main/docs/zh-cn/SECURITY.md">简体中文</a> |
|
package/docs/de/LICENSE.md
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<h6>
|
|
3
|
-
<a href="../"><img height=15 style="margin: 0 3px -2px" src="https://raw.githubusercontent.com/KudoAI/chatgpt.js/6fa1659feadaf70853996dc7d7f6e1ab5a1e6301/media/images/icons/earth-americas.svg"></a>
|
|
4
|
-
Deutsch |
|
|
5
|
-
<a href="../../LICENSE.md">English</a> |
|
|
6
|
-
<a href="../zh-cn/LICENSE.md">简体中文</a> |
|
|
7
|
-
<a href="../zh-tw/LICENSE.md">繁體中文</a> |
|
|
8
|
-
<a href="../ja/LICENSE.md">日本</a> |
|
|
9
|
-
<a href="../ko/LICENSE.md">한국인</a> |
|
|
10
|
-
<a href="../hi/LICENSE.md">हिंदी</a> |
|
|
11
|
-
<a href="../ne/LICENSE.md">नेपाली</a> |
|
|
12
|
-
<a href="../es/LICENSE.md">Español</a> |
|
|
13
|
-
<a href="../fr/LICENSE.md">Français</a> |
|
|
14
|
-
<a href="../it/LICENSE.md">Italiano</a> |
|
|
15
|
-
<a href="../nl/LICENSE.md">Nederlands</a> |
|
|
16
|
-
<a href="../pt/LICENSE.md">Português</a> |
|
|
17
|
-
<a href="../vi/LICENSE.md">Việt</a>
|
|
18
|
-
</h6>
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
|
-
# MIT-Lizenz
|
|
22
|
-
|
|
23
|
-
Urheberrechte © 2023–2024 [KudoAI](https://github.com/KudoAI) & [Mitwirkende](.#-Mitwirkende)
|
|
24
|
-
|
|
25
|
-
Hiermit wird jeder Person, die eine Kopie erhält, kostenlos die Erlaubnis erteilt dieser Software und der zugehörigen Dokumentationsdateien (die „Software“) zu handeln an der Software ohne Einschränkung, einschließlich und ohne Einschränkung der Rechte zum Verwenden, Kopieren, Modifizieren, Zusammenführen, Veröffentlichen, Verteilen, Unterlizenzieren und/oder Verkaufen Kopien der Software zu erwerben und Personen zu gestatten, denen die Software gehört unter folgenden Bedingungen zur Verfügung gestellt:
|
|
26
|
-
|
|
27
|
-
Der obige Urheberrechtshinweis und dieser Genehmigungshinweis sind in allen Bestandteilen enthalten Kopien oder wesentliche Teile der Software.
|
|
28
|
-
|
|
29
|
-
DIE SOFTWARE WIRD „WIE BESEHEN“ ZUR VERFÜGUNG GESTELLT, OHNE JEGLICHE AUSDRÜCKLICHE ODER GEWÄHRLEISTUNG STILLSCHWEIGEND, EINSCHLIESSLICH, ABER NICHT BESCHRÄNKT AUF DIE GARANTIEN DER MARKTGÄNGIGKEIT, EIGNUNG FÜR EINEN BESTIMMTEN ZWECK UND NICHTVERLETZUNG. IN KEINEM FALL DÜRFEN DIE Die Autoren oder Urheberrechtsinhaber haften für Ansprüche, Schäden oder sonstiges HAFTUNG, SEI ES AUS EINEM VERTRAG, EINER HANDLUNG AUS VERLETZLICHER HANDLUNG ODER ANDERWEITIG, ENTSTEHEND AUS: AUS ODER IN VERBINDUNG MIT DER SOFTWARE ODER DER NUTZUNG ODER ANDEREN HANDELN IN DER SOFTWARE.
|