@kudoai/chatgpt.js 3.5.0 → 3.6.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/LICENSE.md +1 -1
- package/README.md +153 -87
- package/chatgpt.js +67 -56
- package/dist/chatgpt.min.js +4 -4
- package/docs/README.md +153 -87
- package/docs/SECURITY.md +15 -15
- package/docs/USERGUIDE.md +19 -5
- package/package.json +9 -6
- package/starters/chrome/LICENSE.md +3 -3
- package/starters/chrome/docs/README.md +5 -5
- package/starters/chrome/docs/SECURITY.md +3 -5
- package/starters/chrome/extension/components/modals.js +12 -6
- package/starters/chrome/extension/content.js +16 -9
- package/starters/chrome/extension/icons/faded/icon128.png +0 -0
- package/starters/chrome/extension/icons/faded/icon16.png +0 -0
- package/starters/chrome/extension/icons/faded/icon32.png +0 -0
- package/starters/chrome/extension/icons/faded/icon64.png +0 -0
- package/starters/chrome/extension/lib/chatgpt.js +67 -56
- package/starters/chrome/extension/lib/dom.js +65 -13
- package/starters/chrome/extension/lib/settings.js +7 -8
- package/starters/chrome/extension/manifest.json +1 -1
- package/starters/chrome/extension/popup/controller.js +6 -6
- package/starters/chrome/extension/popup/index.html +1 -1
- package/starters/chrome/extension/popup/style.css +3 -4
- package/starters/chrome/extension/service-worker.js +1 -1
- package/starters/chrome/images/icons/question-mark/icon16.png +0 -0
- package/starters/chrome/images/icons/question-mark/icon512.png +0 -0
- package/starters/docs/LICENSE.md +21 -1
- package/starters/docs/README.md +19 -6
- package/starters/greasemonkey/LICENSE.md +3 -3
- package/starters/greasemonkey/chatgpt.js-greasemonkey-starter.user.js +5 -6
- package/starters/greasemonkey/docs/README.md +1 -1
- package/starters/greasemonkey/docs/SECURITY.md +3 -5
- /package/starters/greasemonkey/{media → assets}/images/icons/robot/icon48.png +0 -0
- /package/starters/greasemonkey/{media → assets}/images/icons/robot/icon64.png +0 -0
- /package/starters/greasemonkey/{media → assets}/images/screenshots/chatgpt-userscript-on.png +0 -0
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://assets.chatgptjs.org/images/logos/chatgpt.js/with-reflection/darkmode.png?v=e638eac">
|
|
5
|
+
<img width=700 src="https://assets.chatgptjs.org/images/logos/chatgpt.js/with-reflection/lightmode.png?v=e638eac">
|
|
6
6
|
</picture>
|
|
7
7
|
|
|
8
8
|
**chatgpt.js** is a powerful JavaScript library that allows for super easy interaction w/ the ChatGPT DOM.
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
- [getResponseFromAPI `async`](#getresponsefromapi-async)
|
|
59
59
|
- [getResponseFromDOM](#getresponsefromdom)
|
|
60
60
|
- [isIdle `async`](#isidle-async)
|
|
61
|
+
- [isTyping](#istyping)
|
|
61
62
|
- [regenerate](#regenerate)
|
|
62
63
|
- [resend `async`](#resend-async)
|
|
63
64
|
- [scrollToBottom](#scrolltobottom)
|
|
@@ -159,7 +160,7 @@
|
|
|
159
160
|
|
|
160
161
|
```js
|
|
161
162
|
(async () => {
|
|
162
|
-
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.
|
|
163
|
+
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.0/dist/chatgpt.min.js');
|
|
163
164
|
// Your code here...
|
|
164
165
|
})();
|
|
165
166
|
```
|
|
@@ -168,7 +169,7 @@
|
|
|
168
169
|
|
|
169
170
|
```js
|
|
170
171
|
var xhr = new XMLHttpRequest();
|
|
171
|
-
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.
|
|
172
|
+
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.0/dist/chatgpt.min.js');
|
|
172
173
|
xhr.onload = function () {
|
|
173
174
|
if (xhr.status === 200) {
|
|
174
175
|
var chatgptJS = document.createElement('script');
|
|
@@ -190,7 +191,7 @@ function yourCode() {
|
|
|
190
191
|
|
|
191
192
|
```js
|
|
192
193
|
...
|
|
193
|
-
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.
|
|
194
|
+
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.0/dist/chatgpt.min.js
|
|
194
195
|
// ==/UserScript==
|
|
195
196
|
|
|
196
197
|
// Your code here...
|
|
@@ -929,6 +930,18 @@ Example code:
|
|
|
929
930
|
})();
|
|
930
931
|
```
|
|
931
932
|
|
|
933
|
+
### isTyping
|
|
934
|
+
|
|
935
|
+
Returns a boolean value. `true` if ChatGPT is generating a response, `false` otherwise.
|
|
936
|
+
|
|
937
|
+
Example code:
|
|
938
|
+
|
|
939
|
+
```js
|
|
940
|
+
console.log(`ChatGPT is ${!chatgpt.isTyping() ? 'not' : ''} typing`)
|
|
941
|
+
```
|
|
942
|
+
|
|
943
|
+
###### _See also: [`isIdle`](#isidle-async)_
|
|
944
|
+
|
|
932
945
|
### regenerate
|
|
933
946
|
|
|
934
947
|
Regenerates ChatGPT's response.
|
|
@@ -1023,6 +1036,7 @@ Available options:
|
|
|
1023
1036
|
- `voice`: A number representing the index of voices available on the user device.
|
|
1024
1037
|
- `pitch`: A float representing the pitch of the speech. From `0` to `2`.
|
|
1025
1038
|
- `speed`: A float representing the speed of the speech. From `0.1` to `10`.
|
|
1039
|
+
- `onend`: A callback function invoked when speech finishes playing.
|
|
1026
1040
|
|
|
1027
1041
|
Example code:
|
|
1028
1042
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kudoai/chatgpt.js",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Client-side JavaScript library for ChatGPT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "KudoAI & contributors",
|
|
@@ -67,12 +67,15 @@
|
|
|
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/
|
|
72
|
-
"@eslint/
|
|
73
|
-
"@
|
|
70
|
+
"@adamlui/scss-to-css": "^1.10.24",
|
|
71
|
+
"@eslint/css": "^0.2.0",
|
|
72
|
+
"@eslint/json": "^0.10.0",
|
|
73
|
+
"@eslint/markdown": "^6.2.2",
|
|
74
|
+
"@html-eslint/eslint-plugin": "^0.33.1",
|
|
75
|
+
"@html-eslint/parser": "^0.33.0",
|
|
76
|
+
"@stylistic/eslint-plugin-js": "^3.0.1",
|
|
74
77
|
"docsify-cli": "^4.4.4",
|
|
75
|
-
"eslint": "^9.
|
|
78
|
+
"eslint": "^9.19.0",
|
|
76
79
|
"eslint-plugin-import": "^2.31.0",
|
|
77
80
|
"eslint-plugin-regexp": "^2.7.0",
|
|
78
81
|
"eslint-plugin-yml": "^1.16.0",
|
|
@@ -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
|
-
|
|
4
|
+
<source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://assets.chatgptjs.org/images/icons/earth/white/icon32.svg?v=e638eac">
|
|
5
|
+
<img height=14 src="https://assets.chatgptjs.org/images/icons/earth/black/icon32.svg?v=e638eac">
|
|
6
6
|
</picture>
|
|
7
7
|
English |
|
|
8
8
|
<a href="docs/zh-cn/LICENSE.md">简体中文</a> |
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
# 🏛️ MIT License
|
|
24
24
|
|
|
25
|
-
**Copyright © 2023–
|
|
25
|
+
**Copyright © 2023–2025 [KudoAI](https://github.com/KudoAI) & contributors**
|
|
26
26
|
|
|
27
27
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
28
28
|
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
<h6>
|
|
5
5
|
<picture>
|
|
6
|
-
<source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://
|
|
7
|
-
|
|
6
|
+
<source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://assets.chatgptjs.org/images/icons/earth/white/icon32.svg?v=e638eac">
|
|
7
|
+
<img height=14 src="https://assets.chatgptjs.org/images/icons/earth/black/icon32.svg?v=e638eac">
|
|
8
8
|
</picture>
|
|
9
9
|
English |
|
|
10
10
|
<a href="zh-cn#readme">简体中文</a> |
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
</h6>
|
|
23
23
|
</div>
|
|
24
24
|
|
|
25
|
-
# <img height=21 src="https://
|
|
25
|
+
# <img height=21 src="https://assets.chatgptjs.org/images/icons/platforms/chrome/icon32.png?v=e638eac"> chatgpt.js-chrome-starter
|
|
26
26
|
|
|
27
27
|
<h3>A starting point for developing your own Chrome extension using <a href="https://github.com/KudoAI/chatgpt.js">chatgpt.js</a></h3>
|
|
28
28
|
|
|
@@ -81,13 +81,13 @@ These are some of the extensions featured by Google that use chatgpt.js:
|
|
|
81
81
|
|
|
82
82
|
|
|
83
83
|
<a href="https://chatgptinfinity.com" target="_blank" rel="noopener">
|
|
84
|
-
<img width=777 src="https://
|
|
84
|
+
<img width=777 src="https://assets.chatgptinfinity.com/images/tiles/marquee/tile-1400x560.png?v=34b428b">
|
|
85
85
|
</a>
|
|
86
86
|
|
|
87
87
|
<p><br>
|
|
88
88
|
|
|
89
89
|
<a href="https://chatgptwidescreen.com" target="_blank" rel="noopener">
|
|
90
|
-
<img width=777 src="https://
|
|
90
|
+
<img width=777 src="https://assets.chatgptwidescreen.com/images/tiles/marquee/tile-1400x560.png?v=4c5d018">
|
|
91
91
|
</a>
|
|
92
92
|
|
|
93
93
|
</div>
|
|
@@ -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
|
-
|
|
4
|
+
<source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://assets.chatgptjs.org/images/icons/earth/white/icon32.svg?v=e638eac">
|
|
5
|
+
<img height=14 src="https://assets.chatgptjs.org/images/icons/earth/black/icon32.svg?v=e638eac">
|
|
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> |
|
|
@@ -12,6 +12,4 @@
|
|
|
12
12
|
|
|
13
13
|
# 🛡️ Security Policy
|
|
14
14
|
|
|
15
|
-
If you find a vulnerability, please
|
|
16
|
-
|
|
17
|
-
Pull requests are also welcome, but for safety reasons, send an email to <security@kudoai.com> and wait for a response before making it public.
|
|
15
|
+
If you find a vulnerability, please follow the reporting instructions @ https://tidelift.com/security
|
|
@@ -12,21 +12,22 @@ window.modals = {
|
|
|
12
12
|
alert(title = '', msg = '', btns = '', checkbox = '', width = '') { // generic one from chatgpt.alert()
|
|
13
13
|
const alertID = chatgpt.alert(title, msg, btns, checkbox, width),
|
|
14
14
|
alert = document.getElementById(alertID).firstChild
|
|
15
|
-
this.init(alert) // add classes +
|
|
15
|
+
this.init(alert) // add classes + rising particles bg
|
|
16
16
|
return alert
|
|
17
17
|
},
|
|
18
18
|
|
|
19
19
|
open(modalType) {
|
|
20
20
|
const modal = this[modalType]() // show modal
|
|
21
21
|
this.stack.unshift(modalType) // add to stack
|
|
22
|
-
this.init(
|
|
22
|
+
this.init(modal) // add classes + rising particles bg
|
|
23
23
|
this.observeRemoval(modal, modalType) // to maintain stack for proper nav
|
|
24
24
|
},
|
|
25
25
|
|
|
26
26
|
init(modal) {
|
|
27
|
+
if (!modal) return // to support non-div this.open()s
|
|
27
28
|
if (!this.styles) this.stylize() // to init/append stylesheet
|
|
28
|
-
modal.classList.add(this.class) ; modal.parentNode.classList.add(`${this.class}-bg`)
|
|
29
|
-
dom.
|
|
29
|
+
modal.classList.add('no-user-select', this.class) ; modal.parentNode.classList.add(`${this.class}-bg`)
|
|
30
|
+
dom.addRisingParticles(modal)
|
|
30
31
|
},
|
|
31
32
|
|
|
32
33
|
stylize() {
|
|
@@ -35,7 +36,9 @@ window.modals = {
|
|
|
35
36
|
document.head.append(this.styles)
|
|
36
37
|
}
|
|
37
38
|
this.styles.innerText = (
|
|
38
|
-
|
|
39
|
+
`.no-user-select {
|
|
40
|
+
user-select: none ; -webkit-user-select: none ; -moz-user-select: none ; -ms-user-select: none }`
|
|
41
|
+
+ `.${this.class} {` // modals
|
|
39
42
|
+ 'font-family: -apple-system, system-ui, BlinkMacSystemFont, Segoe UI, Roboto,'
|
|
40
43
|
+ 'Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif ;'
|
|
41
44
|
+ 'padding: 20px 25px 24px 25px !important ; font-size: 20px ;'
|
|
@@ -58,9 +61,12 @@ window.modals = {
|
|
|
58
61
|
+ `color: #${ this.imports.env.ui.scheme == 'dark' ? '00cfff' : '1e9ebb' } !important }`
|
|
59
62
|
+ `.${this.class} h2 { font-weight: bold }`
|
|
60
63
|
+ `.${this.class} button {`
|
|
64
|
+
+ '--btn-transition: transform 0.1s ease-in-out, box-shadow 0.1s ease-in-out ;'
|
|
61
65
|
+ 'font-size: 14px ; text-transform: uppercase ;' // shrink/uppercase labels
|
|
62
66
|
+ 'border-radius: 0 !important ;' // square borders
|
|
63
|
-
+ 'transition:
|
|
67
|
+
+ 'transition: var(--btn-transition) ;' // smoothen hover fx
|
|
68
|
+
+ '-webkit-transition: var(--btn-transition) ; -moz-transition: var(--btn-transition) ;'
|
|
69
|
+
+ '-o-transition: var(--btn-transition) ; -ms-transition: var(--btn-transition) ;'
|
|
64
70
|
+ 'cursor: pointer !important ;' // add finger cursor
|
|
65
71
|
+ `border: 1px solid ${ this.imports.env.ui.scheme == 'dark' ? 'white' : 'black' } !important ;`
|
|
66
72
|
+ 'padding: 8px !important ; min-width: 102px }' // resize
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// NOTE: This script relies on the powerful chatgpt.js library @ https://chatgpt.js.org
|
|
2
|
-
// © 2023–
|
|
2
|
+
// © 2023–2025 KudoAI & contributors under the MIT license
|
|
3
3
|
|
|
4
4
|
(async () => {
|
|
5
5
|
|
|
@@ -45,10 +45,18 @@
|
|
|
45
45
|
|
|
46
46
|
// Append styled state word
|
|
47
47
|
if (foundState) {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
const stateStyles = {
|
|
49
|
+
on: {
|
|
50
|
+
light: 'color: #5cef48 ; text-shadow: rgba(255,250,169,0.38) 2px 1px 5px',
|
|
51
|
+
dark: 'color: #5cef48 ; text-shadow: rgb(55, 255, 0) 3px 0 10px'
|
|
52
|
+
},
|
|
53
|
+
off: {
|
|
54
|
+
light: 'color: #ef4848 ; text-shadow: rgba(255,169,225,0.44) 2px 1px 5px',
|
|
55
|
+
dark: 'color: #ef4848 ; text-shadow: rgba(255, 116, 116, 0.87) 3px 0 9px'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const styledStateSpan = document.createElement('span')
|
|
59
|
+
styledStateSpan.style.cssText = stateStyles[foundState.toLowerCase()][env.ui.scheme]
|
|
52
60
|
styledStateSpan.append(foundState) ; notif.append(styledStateSpan)
|
|
53
61
|
}
|
|
54
62
|
}
|
|
@@ -79,11 +87,10 @@
|
|
|
79
87
|
await chatgpt.isLoaded()
|
|
80
88
|
await new Promise(resolve => setTimeout(resolve, 500)); // sleep .5s
|
|
81
89
|
|
|
82
|
-
// Add
|
|
83
|
-
['
|
|
90
|
+
// Add RISING PARTICLES styles for modals
|
|
91
|
+
['gray', 'white'].forEach(color => document.head.append(
|
|
84
92
|
dom.create.elem('link', { rel: 'stylesheet',
|
|
85
|
-
href: `https://assets.aiwebextensions.com/styles/rising-
|
|
86
|
-
color}.min.css?v=0cde30f9ae3ce99ae998141f6e7a36de9b0cc2e7`
|
|
93
|
+
href: `https://assets.aiwebextensions.com/styles/rising-particles/dist/${color}.min.css?v=727feff`
|
|
87
94
|
})))
|
|
88
95
|
|
|
89
96
|
if (config.extensionDisabled) return
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// © 2023–
|
|
1
|
+
// © 2023–2025 KudoAI & contributors under the MIT license.
|
|
2
2
|
// Source: https://github.com/KudoAI/chatgpt.js
|
|
3
3
|
// User guide: https://chatgptjs.org/userguide
|
|
4
4
|
// Latest minified release: https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js/chatgpt.min.js
|
|
@@ -23,7 +23,7 @@ const chatgpt = {
|
|
|
23
23
|
actAs(persona) {
|
|
24
24
|
// Prompts ChatGPT to act as a persona from https://github.com/KudoAI/chat-prompts/blob/main/personas.json
|
|
25
25
|
|
|
26
|
-
const promptsUrl = 'https://
|
|
26
|
+
const promptsUrl = 'https://cdn.jsdelivr.net/gh/KudoAI/chat-prompts/dist/personas.min.json';
|
|
27
27
|
return new Promise((resolve, reject) => {
|
|
28
28
|
const xhr = new XMLHttpRequest();
|
|
29
29
|
xhr.open('GET', promptsUrl, true); xhr.send();
|
|
@@ -73,7 +73,7 @@ const chatgpt = {
|
|
|
73
73
|
|
|
74
74
|
dismiss: {
|
|
75
75
|
click(event) {
|
|
76
|
-
if (event.target == event.currentTarget || event.target.closest('[class
|
|
76
|
+
if (event.target == event.currentTarget || event.target.closest('[class*=-close-btn]'))
|
|
77
77
|
dismissAlert()
|
|
78
78
|
},
|
|
79
79
|
|
|
@@ -131,7 +131,7 @@ const chatgpt = {
|
|
|
131
131
|
modalMessage = document.createElement('p');
|
|
132
132
|
|
|
133
133
|
// Create/append/update modal style (if missing or outdated)
|
|
134
|
-
const thisUpdated =
|
|
134
|
+
const thisUpdated = 1735768363880 // timestamp of last edit for this file's `modalStyle`
|
|
135
135
|
let modalStyle = document.querySelector('#chatgpt-modal-style'); // try to select existing style
|
|
136
136
|
if (!modalStyle || parseInt(modalStyle.getAttribute('last-updated'), 10) < thisUpdated) { // if missing or outdated
|
|
137
137
|
if (!modalStyle) { // outright missing, create/id/attr/append it first
|
|
@@ -140,14 +140,21 @@ const chatgpt = {
|
|
|
140
140
|
document.head.append(modalStyle);
|
|
141
141
|
}
|
|
142
142
|
modalStyle.innerText = ( // update prev/new style contents
|
|
143
|
-
'.
|
|
143
|
+
'.chatgpt-modal {' // vars
|
|
144
|
+
+ '--transition: opacity 0.65s cubic-bezier(.165,.84,.44,1),' // for fade-in
|
|
145
|
+
+ 'transform 0.55s cubic-bezier(.165,.84,.44,1) ;' // for move-in
|
|
146
|
+
+ '--bg-transition: background-color 0.25s ease }' // for bg dim
|
|
147
|
+
|
|
148
|
+
+ '.no-mobile-tap-outline { outline: none ; -webkit-tap-highlight-color: transparent }'
|
|
144
149
|
|
|
145
150
|
// Background styles
|
|
146
151
|
+ '.chatgpt-modal {'
|
|
147
152
|
+ 'pointer-events: auto ;' // override any disabling from site modals (like guest login spam)
|
|
148
153
|
+ 'position: fixed ; top: 0 ; left: 0 ; width: 100% ; height: 100% ;' // expand to full view-port
|
|
149
|
-
+ '
|
|
150
|
-
+ '
|
|
154
|
+
+ 'display: flex ; justify-content: center ; align-items: center ; z-index: 9999 ;' // align
|
|
155
|
+
+ 'transition: var(--bg-transition) ;' // for bg dim
|
|
156
|
+
+ '-webkit-transition: var(--bg-transition) ; -moz-transition: var(--bg-transition) ;'
|
|
157
|
+
+ '-o-transition: var(--bg-transition) ; -ms-transition: var(--bg-transition) }'
|
|
151
158
|
|
|
152
159
|
// Alert styles
|
|
153
160
|
+ '.chatgpt-modal > div {'
|
|
@@ -157,11 +164,13 @@ const chatgpt = {
|
|
|
157
164
|
+ `color: ${ scheme == 'dark' ? 'white' : 'black' };`
|
|
158
165
|
+ `background-color: ${ scheme == 'dark' ? 'black' : 'white' };`
|
|
159
166
|
+ 'transform: translateX(-3px) translateY(7px) ;' // offset to move-in from
|
|
160
|
-
+ '
|
|
161
|
-
|
|
162
|
-
+ '
|
|
163
|
-
|
|
164
|
-
+ '
|
|
167
|
+
+ 'max-width: 75vw ; word-wrap: break-word ; border-radius: 15px ;'
|
|
168
|
+
+ 'padding: 20px ; margin: 12px 23px ; box-shadow: 0 30px 60px rgba(0,0,0,0.12) ;'
|
|
169
|
+
+ 'user-select: none ; -webkit-user-select: none ; -moz-user-select: none ; -o-user-select: none ;'
|
|
170
|
+
+ '-ms-user-select: none ;'
|
|
171
|
+
+ 'transition: var(--transition) ;' // for fade-in + move-in
|
|
172
|
+
+ '-webkit-transition: var(--transition) ; -moz-transition: var(--transition) ;'
|
|
173
|
+
+ '-o-transition: var(--transition) ; -ms-transition: var(--transition) }'
|
|
165
174
|
+ '.chatgpt-modal h2 { margin-bottom: 9px }'
|
|
166
175
|
+ `.chatgpt-modal a { color: ${ scheme == 'dark' ? '#00cfff' : '#1e9ebb' }}`
|
|
167
176
|
+ '.chatgpt-modal a:hover { text-decoration: underline }'
|
|
@@ -283,7 +292,7 @@ const chatgpt = {
|
|
|
283
292
|
if (alertQueue.length === 1) {
|
|
284
293
|
modalContainer.style.display = '';
|
|
285
294
|
setTimeout(() => { // dim bg
|
|
286
|
-
modal.parentNode.style.backgroundColor = `rgba(67,
|
|
295
|
+
modal.parentNode.style.backgroundColor = `rgba(67,70,72,${ scheme == 'dark' ? 0.62 : 0.33 })`
|
|
287
296
|
modal.parentNode.classList.add('animated')
|
|
288
297
|
}, 100) // delay for transition fx
|
|
289
298
|
}
|
|
@@ -296,30 +305,29 @@ const chatgpt = {
|
|
|
296
305
|
|
|
297
306
|
// Define alert dismisser
|
|
298
307
|
const dismissAlert = () => {
|
|
299
|
-
modalContainer.style.backgroundColor = 'transparent'
|
|
300
|
-
modal.style.animation = 'alert-zoom-fade-out 0.
|
|
301
|
-
|
|
308
|
+
modalContainer.style.backgroundColor = 'transparent'
|
|
309
|
+
modal.style.animation = 'alert-zoom-fade-out 0.165s ease-out'
|
|
310
|
+
modal.onanimationend = () => {
|
|
302
311
|
|
|
303
312
|
// Remove alert
|
|
304
|
-
modalContainer.remove()
|
|
305
|
-
alertQueue = JSON.parse(localStorage.alertQueue)
|
|
306
|
-
alertQueue.shift()
|
|
307
|
-
localStorage.alertQueue = JSON.stringify(alertQueue)
|
|
308
|
-
document.removeEventListener('keydown', handlers.dismiss.key)
|
|
313
|
+
modalContainer.remove() // ...from DOM
|
|
314
|
+
alertQueue = JSON.parse(localStorage.alertQueue)
|
|
315
|
+
alertQueue.shift() // + memory
|
|
316
|
+
localStorage.alertQueue = JSON.stringify(alertQueue) // + storage
|
|
317
|
+
document.removeEventListener('keydown', handlers.dismiss.key) // prevent memory leaks
|
|
309
318
|
|
|
310
319
|
// Check for pending alerts in queue
|
|
311
320
|
if (alertQueue.length > 0) {
|
|
312
|
-
const nextAlert = document.getElementById(alertQueue[0])
|
|
321
|
+
const nextAlert = document.getElementById(alertQueue[0])
|
|
313
322
|
setTimeout(() => {
|
|
314
|
-
nextAlert.style.display = ''
|
|
315
|
-
setTimeout(() =>
|
|
316
|
-
}, 500)
|
|
323
|
+
nextAlert.style.display = ''
|
|
324
|
+
setTimeout(() => nextAlert.classList.add('animated'), 100)
|
|
325
|
+
}, 500)
|
|
317
326
|
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
318
329
|
|
|
319
|
-
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
return modalContainer.id; // if assignment used
|
|
330
|
+
return modalContainer.id // if assignment used
|
|
323
331
|
},
|
|
324
332
|
|
|
325
333
|
async askAndGetReply(query) {
|
|
@@ -592,7 +600,7 @@ const chatgpt = {
|
|
|
592
600
|
// Create transcript from active chat
|
|
593
601
|
if (chatToGet == 'active' && /\/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(window.location.href)) {
|
|
594
602
|
const chatDivs = document.querySelectorAll('main > div > div > div > div > div > div[class*=group]');
|
|
595
|
-
if (chatDivs.length
|
|
603
|
+
if (!chatDivs.length) return console.error('Chat is empty!');
|
|
596
604
|
const msgs = []; let isUserMsg = true;
|
|
597
605
|
chatDivs.forEach((div) => {
|
|
598
606
|
const sender = isUserMsg ? 'USER' : 'CHATGPT'; isUserMsg = !isUserMsg;
|
|
@@ -1106,7 +1114,7 @@ const chatgpt = {
|
|
|
1106
1114
|
}
|
|
1107
1115
|
},
|
|
1108
1116
|
|
|
1109
|
-
isDarkMode() { return document.documentElement.
|
|
1117
|
+
isDarkMode() { return document.documentElement.className.includes('dark') },
|
|
1110
1118
|
isFullScreen() { return chatgpt.browser.isFullScreen(); },
|
|
1111
1119
|
|
|
1112
1120
|
async isIdle(timeout = null) {
|
|
@@ -1149,6 +1157,7 @@ const chatgpt = {
|
|
|
1149
1157
|
},
|
|
1150
1158
|
|
|
1151
1159
|
isLightMode() { return document.documentElement.classList.toString().includes('light'); },
|
|
1160
|
+
isTyping() { return !!this.getStopButton() },
|
|
1152
1161
|
|
|
1153
1162
|
logout() { window.location.href = 'https://chat.openai.com/auth/logout'; },
|
|
1154
1163
|
|
|
@@ -1287,7 +1296,7 @@ const chatgpt = {
|
|
|
1287
1296
|
+ (notificationDiv.isRight ? 'Right' : 'Left');
|
|
1288
1297
|
|
|
1289
1298
|
// Create/append/update notification style (if missing or outdated)
|
|
1290
|
-
const thisUpdated =
|
|
1299
|
+
const thisUpdated = 1735767823541 // timestamp of last edit for this file's `notifStyle`
|
|
1291
1300
|
let notifStyle = document.querySelector('#chatgpt-notif-style'); // try to select existing style
|
|
1292
1301
|
if (!notifStyle || parseInt(notifStyle.getAttribute('last-updated'), 10) < thisUpdated) { // if missing or outdated
|
|
1293
1302
|
if (!notifStyle) { // outright missing, create/id/attr/append it first
|
|
@@ -1302,7 +1311,8 @@ const chatgpt = {
|
|
|
1302
1311
|
+ '.no-mobile-tap-outline { outline: none ; -webkit-tap-highlight-color: transparent }'
|
|
1303
1312
|
+ 'background-color: black ; padding: 10px 13px 10px 18px ; border-radius: 11px ; border: 1px solid #f5f5f7 ;' // bubble style
|
|
1304
1313
|
+ 'opacity: 0 ; position: fixed ; z-index: 9999 ; font-size: 1.8rem ; color: white ;' // visibility
|
|
1305
|
-
+ '
|
|
1314
|
+
+ 'user-select: none ; -webkit-user-select: none ; -moz-user-select: none ; -o-user-select: none ;'
|
|
1315
|
+
+ '-ms-user-select: none ;'
|
|
1306
1316
|
+ `transform: translateX(${ !notificationDiv.isRight ? '-' : '' }35px) ;` // init off-screen for transition fx
|
|
1307
1317
|
+ ( shadow ? ( 'box-shadow: -8px 13px 25px 0 ' + ( /\b(?:shadow|on)\b/i.test(shadow) ? 'gray' : shadow )) : '' ) + '}'
|
|
1308
1318
|
+ '.notif-close-btn { cursor: pointer ; float: right ; position: relative ; right: -4px ; margin-left: -3px ;'
|
|
@@ -1814,7 +1824,7 @@ const chatgpt = {
|
|
|
1814
1824
|
|
|
1815
1825
|
|
|
1816
1826
|
// Fix for blank background on dropdown elements
|
|
1817
|
-
if (element == 'dropdown') newElement.style.backgroundColor = 'var(--gray-900, rgb(32,
|
|
1827
|
+
if (element == 'dropdown') newElement.style.backgroundColor = 'var(--gray-900, rgb(32,33,35))';
|
|
1818
1828
|
|
|
1819
1829
|
this.elements.push(newElement);
|
|
1820
1830
|
this.activateObserver();
|
|
@@ -1869,31 +1879,31 @@ const chatgpt = {
|
|
|
1869
1879
|
return chatgpt.getChatData('active', 'msg', 'chatgpt', 'latest');
|
|
1870
1880
|
},
|
|
1871
1881
|
|
|
1872
|
-
speak(msg,
|
|
1873
|
-
//
|
|
1874
|
-
//
|
|
1875
|
-
//
|
|
1876
|
-
//
|
|
1877
|
-
|
|
1878
|
-
const { voice = 2, pitch = 2, speed = 1.1 } = options;
|
|
1882
|
+
speak(msg, { voice = 2, pitch = 2, speed = 1.1, onend } = {} ) { // eslint-disable-line no-unused-vars
|
|
1883
|
+
// Example call: chatgpt.speak(await chatgpt.getLastResponse(), { voice: 1, pitch: 2, speed: 3 })
|
|
1884
|
+
// - voice = index of voices available on user device
|
|
1885
|
+
// - pitch = float for pitch of speech from 0 to 2
|
|
1886
|
+
// - speed = float for rate of speech from 0.1 to 10
|
|
1887
|
+
// - onend = callback function invoked when speech finishes playing
|
|
1879
1888
|
|
|
1880
1889
|
// Validate args
|
|
1881
|
-
if (typeof msg
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
if (
|
|
1885
|
-
return console.error(`Invalid
|
|
1890
|
+
if (typeof msg != 'string') return console.error('Message must be a string!')
|
|
1891
|
+
const validOptionKeys = ['voice', 'pitch', 'speed', 'onend']
|
|
1892
|
+
for (const key in arguments[1]) {
|
|
1893
|
+
if (!validOptionKeys.includes(key))
|
|
1894
|
+
return console.error(`Invalid option '${key}'. Valid keys are: ${validOptionKeys}`)
|
|
1895
|
+
const val = arguments[1][key]
|
|
1896
|
+
if (key != 'onend' && typeof val != 'number' && !/^\d+$/.test(val))
|
|
1897
|
+
return console.error(`Invalid ${key} value '${val}'. Must be a number!`)
|
|
1898
|
+
else if (key == 'onend' && typeof val != 'function')
|
|
1899
|
+
return console.error(`Invalid ${key} value. Must be a function!`)
|
|
1886
1900
|
}
|
|
1887
1901
|
|
|
1888
|
-
try { // to speak msg
|
|
1889
|
-
const
|
|
1890
|
-
|
|
1891
|
-
utterance
|
|
1892
|
-
|
|
1893
|
-
utterance.pitch = pitch;
|
|
1894
|
-
utterance.rate = speed;
|
|
1895
|
-
speechSynthesis.speak(utterance);
|
|
1896
|
-
} catch (err) { console.error( err); }
|
|
1902
|
+
try { // to speak msg
|
|
1903
|
+
const utterance = new SpeechSynthesisUtterance()
|
|
1904
|
+
Object.assign(utterance, { text: msg, ...arguments[1], voice: speechSynthesis.getVoices()[voice] })
|
|
1905
|
+
speechSynthesis.speak(utterance)
|
|
1906
|
+
} catch (err) { console.error(err) }
|
|
1897
1907
|
},
|
|
1898
1908
|
|
|
1899
1909
|
async summarize(text) {
|
|
@@ -2023,8 +2033,9 @@ const cjsFuncSynonyms = [
|
|
|
2023
2033
|
['render', 'parse'],
|
|
2024
2034
|
['reply', 'response'],
|
|
2025
2035
|
['sentiment', 'attitude', 'emotion', 'feeling', 'opinion', 'perception'],
|
|
2026
|
-
['speak', 'say', 'speech', 'talk', 'tts'],
|
|
2036
|
+
['speak', 'play', 'say', 'speech', 'talk', 'tts'],
|
|
2027
2037
|
['summarize', 'tldr'],
|
|
2038
|
+
['typing', 'generating'],
|
|
2028
2039
|
['unminify', 'beautify', 'prettify', 'prettyPrint']
|
|
2029
2040
|
];
|
|
2030
2041
|
const camelCaser = (words) => {
|