@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/README.md
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<h6>
|
|
5
5
|
<a href="https://github.com/KudoAI/chatgpt.js/tree/main/docs">
|
|
6
6
|
<picture>
|
|
7
|
-
<source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://
|
|
8
|
-
<img src="https://
|
|
7
|
+
<source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://media.chatgptjs.org/images/icons/earth-americas-white-padded-icon17x15.svg?714b6a1">
|
|
8
|
+
<img src="https://media.chatgptjs.org/images/icons/earth-americas-padded-icon17x15.svg?714b6a1">
|
|
9
9
|
</picture>
|
|
10
10
|
</a>
|
|
11
11
|
English |
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
|
|
30
30
|
<a href="https://chatgpt.js.org">
|
|
31
31
|
<picture>
|
|
32
|
-
<source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://
|
|
33
|
-
<img width=800 src="https://
|
|
32
|
+
<source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://media.chatgptjs.org/images/logos/chatgpt.js/with-reflection/darkmode.png?bc68d0c">
|
|
33
|
+
<img width=800 src="https://media.chatgptjs.org/images/logos/chatgpt.js/with-reflection/lightmode.png?bc68d0c">
|
|
34
34
|
</picture>
|
|
35
35
|
</a>
|
|
36
36
|
|
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
[](https://github.com/KudoAI/chatgpt.js/stargazers)
|
|
46
46
|
[](https://github.com/KudoAI/chatgpt.js/blob/main/LICENSE.md)
|
|
47
47
|
[](https://github.com/KudoAI/chatgpt.js/commits/main)
|
|
48
|
-

|
|
48
|
+
[](https://github.com/KudoAI/chatgpt.js/tree/v2.6.10/dist/chatgpt.min.js)
|
|
49
49
|
[](https://www.codefactor.io/repository/github/kudoai/chatgpt.js)
|
|
50
50
|
[](https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=kudoai_chatgpt.js)
|
|
51
51
|
[](https://github.com/sindresorhus/awesome-chatgpt#javascript)
|
|
52
52
|
[](https://www.producthunt.com/posts/chatgpt-js)
|
|
53
|
-
|
|
53
|
+

|
|
54
54
|
|
|
55
55
|
</div>
|
|
56
56
|
|
|
57
|
-
<img height=8px width="100%" src="https://
|
|
57
|
+
<img height=8px width="100%" src="https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@5e41346/docs/assets/images/aqua-separator.png">
|
|
58
58
|
|
|
59
59
|
<div id="intro">
|
|
60
60
|
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
- Easy-to-use
|
|
70
70
|
- Lightweight (yet optimally performant)
|
|
71
71
|
|
|
72
|
-
<img height=8px width="100%" src="https://
|
|
72
|
+
<img height=8px width="100%" src="https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@5e41346/docs/assets/images/aqua-separator.png">
|
|
73
73
|
|
|
74
74
|
<div id="importing">
|
|
75
75
|
|
|
@@ -77,13 +77,13 @@
|
|
|
77
77
|
|
|
78
78
|
</div>
|
|
79
79
|
|
|
80
|
-
> **Note** _To always import the latest version (
|
|
80
|
+
> **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`_
|
|
81
81
|
|
|
82
82
|
### ES6:
|
|
83
83
|
|
|
84
84
|
```js
|
|
85
85
|
(async () => {
|
|
86
|
-
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.6.
|
|
86
|
+
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.6.10/dist/chatgpt.min.js');
|
|
87
87
|
// Your code here...
|
|
88
88
|
})();
|
|
89
89
|
```
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
|
|
93
93
|
```js
|
|
94
94
|
var xhr = new XMLHttpRequest();
|
|
95
|
-
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.6.
|
|
95
|
+
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.6.10/dist/chatgpt.min.js');
|
|
96
96
|
xhr.onload = function () {
|
|
97
97
|
if (xhr.status === 200) {
|
|
98
98
|
var chatgptJS = document.createElement('script');
|
|
@@ -108,13 +108,13 @@ function yourCode() {
|
|
|
108
108
|
}
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
-
### <img style="margin: 0 2px -0.065rem 0" height=17 src="https://
|
|
111
|
+
### <img style="margin: 0 2px -0.065rem 0" height=17 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=17.5 src="https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@0c37090/starters/media/images/icons/violentmonkey-icon100.png"> Greasemonkey:
|
|
112
112
|
|
|
113
113
|
> **Note** _To use a starter template: [kudoai/chatgpt.js-greasemonkey-starter](https://github.com/KudoAI/chatgpt.js-greasemonkey-starter)_
|
|
114
114
|
|
|
115
115
|
```js
|
|
116
116
|
...
|
|
117
|
-
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.6.
|
|
117
|
+
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.6.10/dist/chatgpt.min.js
|
|
118
118
|
// ==/UserScript==
|
|
119
119
|
|
|
120
120
|
// Your code here...
|
|
@@ -150,7 +150,7 @@ export { chatgpt }
|
|
|
150
150
|
})();
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
-
<img height=8px width="100%" src="https://
|
|
153
|
+
<img height=8px width="100%" src="https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@5e41346/docs/assets/images/aqua-separator.png">
|
|
154
154
|
|
|
155
155
|
<div id="npm">
|
|
156
156
|
|
|
@@ -164,11 +164,11 @@ To download **chatgpt.js** for local customization, run the following command in
|
|
|
164
164
|
npm install @kudoai/chatgpt.js
|
|
165
165
|
```
|
|
166
166
|
|
|
167
|
-
After installation, navigate to `node_modules/@kudoai/chatgpt.js` to find the library source
|
|
167
|
+
After installation, navigate to `node_modules/@kudoai/chatgpt.js` to find the library source.
|
|
168
168
|
|
|
169
169
|
</div>
|
|
170
170
|
|
|
171
|
-
<img height=8px width="100%" src="https://
|
|
171
|
+
<img height=8px width="100%" src="https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@5e41346/docs/assets/images/aqua-separator.png">
|
|
172
172
|
|
|
173
173
|
<div id="usage">
|
|
174
174
|
|
|
@@ -191,7 +191,7 @@ Each call equally fetches the last response. If you think it works, it probably
|
|
|
191
191
|
|
|
192
192
|
If it didn't, check out the extended [userguide](https://github.com/KudoAI/chatgpt.js/blob/main/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
193
|
|
|
194
|
-
<img height=8px width="100%" src="https://
|
|
194
|
+
<img height=8px width="100%" src="https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@5e41346/docs/assets/images/aqua-separator.png">
|
|
195
195
|
|
|
196
196
|
<div id="showcase">
|
|
197
197
|
|
|
@@ -210,13 +210,6 @@ https://github.com/KudoAI/chatgpt.js/assets/10906554/f53c740f-d5e0-49b6-ae02-3b3
|
|
|
210
210
|
[Readme](https://github.com/adamlui/autoclear-chatgpt-history#readme) /
|
|
211
211
|
[Discuss](https://autoclearchatgpt.com/discuss)
|
|
212
212
|
|
|
213
|
-
### <img width=16 src="https://i.imgur.com/1yjmK3W.png"> [Automatic ChatGPT DAN](https://github.com/madkarmaa/automatic-chatgpt-dan)
|
|
214
|
-
|
|
215
|
-
> Automatically send DAN prompts to ChatGPT.
|
|
216
|
-
<br>[Install](https://github.com/madkarmaa/automatic-chatgpt-dan#%EF%B8%8F-installation) /
|
|
217
|
-
[Readme](https://github.com/madkarmaa/automatic-chatgpt-dan#readme) /
|
|
218
|
-
[Discuss](https://github.com/madkarmaa/automatic-chatgpt-dan/issues)
|
|
219
|
-
|
|
220
213
|
### <img src="https://media.bravegpt.com/images/icons/bravegpt/icon48.png" width=18> [BraveGPT](https://bravegpt.com) <a href="https://www.producthunt.com/posts/bravegpt?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-bravegpt" target="_blank" rel="noopener"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=385630&theme=light" style="width: 112px; height: 24px; margin:0 0 -4px 5px;" width="112" height="24" /></a>
|
|
221
214
|
|
|
222
215
|
> Display ChatGPT answers in Brave Search sidebar (powered by GPT-4!)
|
|
@@ -270,7 +263,7 @@ https://github.com/KudoAI/chatgpt.js/assets/10906554/f53c740f-d5e0-49b6-ae02-3b3
|
|
|
270
263
|
If you've made something w/ chatgpt.js you want to share, email <a href="mailto:showcase@chatgptjs.org">showcase@chatgptjs.org</a> or just open a <a href="https://github.com/KudoAI/chatgpt.js/pulls" target="_blank" rel="noopener">pull request</a>!
|
|
271
264
|
</p>
|
|
272
265
|
|
|
273
|
-
<img height=8px width="100%" src="https://
|
|
266
|
+
<img height=8px width="100%" src="https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@5e41346/docs/assets/images/aqua-separator.png">
|
|
274
267
|
|
|
275
268
|
<div id="contributors">
|
|
276
269
|
|
|
@@ -303,16 +296,18 @@ This library exists thanks to code, translations, issues & ideas from the follow
|
|
|
303
296
|
[](https://github.com/philly88r)
|
|
304
297
|
[](https://github.com/thomasgauthier)
|
|
305
298
|
[](https://github.com/pranav-bhatt)
|
|
306
|
-
[](https://github.com/hopana)
|
|
300
|
+
[](https://github.com/emtry)
|
|
301
|
+
[](https://github.com/thedayofcondor)
|
|
307
302
|
[](https://github.com/Luwa-Tech)
|
|
308
303
|
[](https://github.com/dependabot)
|
|
309
304
|
[](https://chat.openai.com)
|
|
310
|
-
[](https://poe.com)
|
|
311
306
|
[](https://github.com/ImgBotApp)
|
|
312
307
|
|
|
313
308
|
</div><br>
|
|
314
309
|
|
|
315
|
-
<img height=8px width="100%" src="https://
|
|
310
|
+
<img height=8px width="100%" src="https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@5e41346/docs/assets/images/aqua-separator.png">
|
|
316
311
|
|
|
317
312
|
<div id="partners">
|
|
318
313
|
|
|
@@ -325,21 +320,21 @@ This library exists thanks to code, translations, issues & ideas from the follow
|
|
|
325
320
|
<div id="partners-collage" align="center">
|
|
326
321
|
|
|
327
322
|
<picture>
|
|
328
|
-
<source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://
|
|
329
|
-
<img width=888 src="https://
|
|
323
|
+
<source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://media.chatgptjs.org/images/logos/partners/collage/white.png?3109608">
|
|
324
|
+
<img width=888 src="https://media.chatgptjs.org/images/logos/partners/collage/black.png?3109608">
|
|
330
325
|
</picture>
|
|
331
326
|
|
|
332
327
|
</div>
|
|
333
328
|
|
|
334
329
|
<br>
|
|
335
330
|
|
|
336
|
-
<img height=8px width="100%" src="https://
|
|
331
|
+
<img height=8px width="100%" src="https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@5e41346/docs/assets/images/aqua-separator.png">
|
|
337
332
|
|
|
338
333
|
<div align="center">
|
|
339
334
|
|
|
340
|
-
**[Releases](https://
|
|
335
|
+
**[Releases](https://github.com/KudoAI/chatgpt.js/releases)** /
|
|
341
336
|
[Userguide](https://github.com/KudoAI/chatgpt.js/blob/main/docs/USERGUIDE.md) /
|
|
342
337
|
[Discuss](https://github.com/KudoAI/chatgpt.js/discussions) /
|
|
343
|
-
<a href="
|
|
338
|
+
<a href="#--------------------------------------------------------------------------------english---------简体中文---------繁體中文---------日本---------한국인---------हिंदी---------नेपाली---------deutsch---------español---------français---------italiano---------nederlands---------português---------việt----">Back to top ↑</a>
|
|
344
339
|
|
|
345
340
|
</div>
|
package/chatgpt.js
CHANGED
|
@@ -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
|