@kudoai/chatgpt.js 3.6.2 → 3.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/chatgpt.js +113 -101
- package/dist/chatgpt.min.js +63 -15
- package/docs/README.md +7 -7
- package/docs/USERGUIDE.md +3 -3
- package/package.json +2 -2
- package/starters/chrome/extension/lib/chatgpt.js +113 -101
- package/starters/chrome/extension/manifest.json +1 -1
- package/starters/greasemonkey/chatgpt.js-greasemonkey-starter.user.js +2 -2
package/README.md
CHANGED
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
<img src="https://img.shields.io/github/stars/KudoAI/chatgpt.js?label=Stars&color=af68ff&logo=github&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
50
50
|
<a href="https://github.com/KudoAI/chatgpt.js/blob/main/LICENSE.md">
|
|
51
51
|
<img src="https://img.shields.io/badge/License-MIT-green.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
52
|
-
<a href="https://github.com/KudoAI/chatgpt.js/tree/v3.6.
|
|
53
|
-
<img src="https://img.shields.io/github/size/KudoAI/chatgpt.js/dist/chatgpt.min.js?branch=v3.6.
|
|
52
|
+
<a href="https://github.com/KudoAI/chatgpt.js/tree/v3.6.3/dist/chatgpt.min.js">
|
|
53
|
+
<img src="https://img.shields.io/github/size/KudoAI/chatgpt.js/dist/chatgpt.min.js?branch=v3.6.3&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
|
|
54
54
|
<a href="https://www.codefactor.io/repository/github/kudoai/chatgpt.js">
|
|
55
55
|
<img src="https://img.shields.io/codefactor/grade/github/kudoai/chatgpt.js?label=Code+Quality&logo=codefactor&logoColor=white&labelColor=464646&color=1acc6c&style=for-the-badge"></a>
|
|
56
56
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=kudoai_chatgpt.js">
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
|
|
95
95
|
```js
|
|
96
96
|
(async () => {
|
|
97
|
-
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.
|
|
97
|
+
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.3/dist/chatgpt.min.js');
|
|
98
98
|
// Your code here...
|
|
99
99
|
})();
|
|
100
100
|
```
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
|
|
104
104
|
```js
|
|
105
105
|
var xhr = new XMLHttpRequest();
|
|
106
|
-
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.
|
|
106
|
+
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.3/dist/chatgpt.min.js');
|
|
107
107
|
xhr.onload = function () {
|
|
108
108
|
if (xhr.status === 200) {
|
|
109
109
|
var chatgptJS = document.createElement('script');
|
|
@@ -126,7 +126,7 @@ function yourCode() {
|
|
|
126
126
|
|
|
127
127
|
```js
|
|
128
128
|
...
|
|
129
|
-
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.
|
|
129
|
+
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.3/dist/chatgpt.min.js
|
|
130
130
|
// ==/UserScript==
|
|
131
131
|
|
|
132
132
|
// Your code here...
|
|
@@ -196,7 +196,7 @@ chatgpt.get('reply', 'last');
|
|
|
196
196
|
|
|
197
197
|
Each call equally fetches the last response. If you think it works, it probably will... so just type it!
|
|
198
198
|
|
|
199
|
-
If it didn't, check out the extended [userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.6.
|
|
199
|
+
If it didn't, check out the extended [userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.6.3/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!
|
|
200
200
|
|
|
201
201
|
<img height=8px width="100%" src="https://assets.chatgptjs.org/images/separators/gradient-aqua.png?v=e638eac">
|
|
202
202
|
|
|
@@ -427,7 +427,7 @@ This library exists thanks to code, translations, issues & ideas from the follow
|
|
|
427
427
|
<div align="center">
|
|
428
428
|
|
|
429
429
|
**[Releases](https://github.com/KudoAI/chatgpt.js/releases)** /
|
|
430
|
-
[Userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.6.
|
|
430
|
+
[Userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.6.3/docs/USERGUIDE.md) /
|
|
431
431
|
[Discuss](https://github.com/KudoAI/chatgpt.js/discussions) /
|
|
432
432
|
[Back to top ↑](#top)
|
|
433
433
|
|
package/chatgpt.js
CHANGED
|
@@ -133,49 +133,53 @@ const chatgpt = {
|
|
|
133
133
|
modalMessage = document.createElement('p');
|
|
134
134
|
|
|
135
135
|
// Create/append/update modal style (if missing or outdated)
|
|
136
|
-
const thisUpdated =
|
|
137
|
-
let modalStyle = document.querySelector('#chatgpt-modal-style')
|
|
136
|
+
const thisUpdated = 1739338889852 // timestamp of last edit for this file's `modalStyle`
|
|
137
|
+
let modalStyle = document.querySelector('#chatgpt-modal-style') // try to select existing style
|
|
138
138
|
if (!modalStyle || parseInt(modalStyle.getAttribute('last-updated'), 10) < thisUpdated) { // if missing or outdated
|
|
139
139
|
if (!modalStyle) { // outright missing, create/id/attr/append it first
|
|
140
|
-
modalStyle = document.createElement('style'); modalStyle.id = 'chatgpt-modal-style'
|
|
141
|
-
modalStyle.setAttribute('last-updated', thisUpdated.toString())
|
|
142
|
-
document.head.append(modalStyle)
|
|
140
|
+
modalStyle = document.createElement('style') ; modalStyle.id = 'chatgpt-modal-style'
|
|
141
|
+
modalStyle.setAttribute('last-updated', thisUpdated.toString())
|
|
142
|
+
document.head.append(modalStyle)
|
|
143
143
|
}
|
|
144
144
|
modalStyle.innerText = ( // update prev/new style contents
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
`.chatgpt-modal { /* vars */
|
|
146
|
+
--transition: opacity 0.65s cubic-bezier(.165,.84,.44,1), /* for fade-in */
|
|
147
|
+
transform 0.55s cubic-bezier(.165,.84,.44,1) ; /* for move-in */
|
|
148
|
+
--bg-transition: background-color 0.25s ease ; /* for bg dim */
|
|
149
|
+
--btn-transition: transform 0.1s ease-in-out, box-shadow 0.1s ease-in-out ; /* for smooth zoom */
|
|
150
|
+
--btn-shadow: 2px 1px ${ scheme == 'dark' ? '54px #00cfff' : '30px #9cdaff' }}`
|
|
149
151
|
|
|
150
152
|
+ '.no-mobile-tap-outline { outline: none ; -webkit-tap-highlight-color: transparent }'
|
|
151
153
|
|
|
152
154
|
// Background styles
|
|
153
|
-
+
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
+ `.chatgpt-modal {
|
|
156
|
+
pointer-events: auto ; /* override any disabling from site modals (like guest login spam) */
|
|
157
|
+
position: fixed ; top: 0 ; left: 0 ; width: 100% ; height: 100% ; /* expand to full view-port */
|
|
158
|
+
display: flex ; justify-content: center ; align-items: center ; z-index: 9999 ; /* align */
|
|
159
|
+
transition: var(--bg-transition) ; /* for bg dim */
|
|
160
|
+
-webkit-transition: var(--bg-transition) ; -moz-transition: var(--bg-transition) ;
|
|
161
|
+
-o-transition: var(--bg-transition) ; -ms-transition: var(--bg-transition) }`
|
|
160
162
|
|
|
161
163
|
// Alert styles
|
|
162
|
-
+
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
164
|
+
+ `.chatgpt-modal > div {
|
|
165
|
+
position: absolute ; /* to be click-draggable */
|
|
166
|
+
opacity: 0 ; /* to fade-in */
|
|
167
|
+
font-family: -apple-system, system-ui, BlinkMacSystemFont, Segoe UI, Roboto,
|
|
168
|
+
Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif ;
|
|
169
|
+
padding: 20px ; margin: 12px 23px ; font-size: 20px ;
|
|
170
|
+
color: ${ scheme == 'dark' ? 'white' : 'black' };
|
|
171
|
+
background-color: ${ scheme == 'dark' ? 'black' : 'white' };
|
|
172
|
+
border: 1px solid ${ scheme == 'dark' ? 'white' : '#b5b5b5' };
|
|
173
|
+
transform: translateX(-3px) translateY(7px) ; /* offset to move-in from */
|
|
174
|
+
max-width: 75vw ; word-wrap: break-word ; border-radius: 15px ;
|
|
175
|
+
--shadow: 0 30px 60px rgba(0,0,0,0.12) ; box-shadow: var(--shadow) ;
|
|
176
|
+
-webkit-box-shadow: var(--shadow) ; -moz-box-shadow: var(--shadow) ;
|
|
177
|
+
user-select: none ; -webkit-user-select: none ; -moz-user-select: none ;
|
|
178
|
+
-o-user-select: none ; -ms-user-select: none ;
|
|
179
|
+
transition: var(--transition) ; /* for fade-in + move-in */
|
|
180
|
+
-webkit-transition: var(--transition) ; -moz-transition: var(--transition) ;
|
|
181
|
+
-o-transition: var(--transition) ; -ms-transition: var(--transition) }
|
|
182
|
+
.chatgpt-modal h2 { font-weight: bold ; font-size: 24px ; margin-bottom: 9px }
|
|
179
183
|
.chatgpt-modal a { color: ${ scheme == 'dark' ? '#00cfff' : '#1e9ebb' }}
|
|
180
184
|
.chatgpt-modal a:hover { text-decoration: underline }
|
|
181
185
|
.chatgpt-modal.animated > div {
|
|
@@ -185,39 +189,44 @@ const chatgpt = {
|
|
|
185
189
|
100% { opacity: 0 ; transform: scale(1.35) }}`
|
|
186
190
|
|
|
187
191
|
// Button styles
|
|
188
|
-
+
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
box-shadow: var(--
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
192
|
+
+ `.modal-buttons {
|
|
193
|
+
display: flex ; justify-content: flex-end ; margin: 20px -5px -3px 0 ;
|
|
194
|
+
${ isMobile ? 'flex-direction: column-reverse' : '' }}
|
|
195
|
+
.chatgpt-modal button {
|
|
196
|
+
font-size: 14px ; text-transform: uppercase ;
|
|
197
|
+
margin-left: ${ isMobile ? 0 : 10 }px ; padding: ${ isMobile ? 15 : 8 }px 18px ;
|
|
198
|
+
${ isMobile ? 'margin-top: 5px ; margin-bottom: 3px ;' : '' }
|
|
199
|
+
border-radius: 0 ; border: 1px solid ${ scheme == 'dark' ? 'white' : 'black' };
|
|
200
|
+
transition: var(--btn-transition) ;
|
|
201
|
+
-webkit-transition: var(--btn-transition) ; -moz-transition: var(--btn-transition) ;
|
|
202
|
+
-o-transition: var(--btn-transition) ; -ms-transition: var(--btn-transition) }
|
|
203
|
+
.chatgpt-modal button:hover {
|
|
204
|
+
transform: scale(1.055) ; color: black ;
|
|
205
|
+
background-color: #${ scheme == 'dark' ? '00cfff' : '9cdaff' };
|
|
206
|
+
box-shadow: var(--btn-shadow) ;
|
|
207
|
+
-webkit-box-shadow: var(--btn-shadow) ; -moz-box-shadow: var(--btn-shadow) }
|
|
208
|
+
.primary-modal-btn {
|
|
209
|
+
border: 1px solid ${ scheme == 'dark' ? 'white' : 'black' };
|
|
210
|
+
background: ${ scheme == 'dark' ? 'white' : 'black' };
|
|
211
|
+
color: ${ scheme == 'dark' ? 'black' : 'white' }}
|
|
212
|
+
.modal-close-btn {
|
|
213
|
+
cursor: pointer ; width: 29px ; height: 29px ; border-radius: 17px ;
|
|
214
|
+
float: right ; position: relative ; right: -6px ; top: -5px }
|
|
215
|
+
.modal-close-btn svg { margin: 10px } /* center SVG for hover underlay */
|
|
216
|
+
.modal-close-btn:hover { background-color: #f2f2f2${ scheme == 'dark' ? '00' : '' }}`
|
|
208
217
|
|
|
209
218
|
// Checkbox styles
|
|
210
|
-
+ `.chatgpt-modal .checkbox-group { margin
|
|
211
|
-
.chatgpt-modal
|
|
212
|
-
|
|
213
|
-
color: ${ scheme == 'dark' ? '#e1e1e1' : '#1e1e1e' }}
|
|
214
|
-
.chatgpt-modal input[type=checkbox] { transform: scale(0.7) ;
|
|
219
|
+
+ `.chatgpt-modal .checkbox-group { margin: 5px 0 -8px 5px }
|
|
220
|
+
.chatgpt-modal input[type=checkbox] {
|
|
221
|
+
cursor: pointer ; transform: scale(0.7) ; margin-right: 5px ;
|
|
215
222
|
border: 1px solid ${ scheme == 'dark' ? 'white' : 'black' }}
|
|
216
223
|
.chatgpt-modal input[type=checkbox]:checked {
|
|
217
|
-
|
|
218
|
-
|
|
224
|
+
background-color: black ; position: inherit ;
|
|
225
|
+
border: 1px solid ${ scheme == 'dark' ? 'white' : 'black' }}
|
|
219
226
|
.chatgpt-modal input[type=checkbox]:focus {
|
|
220
|
-
outline: none ; box-shadow: none ; -webkit-box-shadow: none ; -moz-box-shadow: none }
|
|
227
|
+
outline: none ; box-shadow: none ; -webkit-box-shadow: none ; -moz-box-shadow: none }
|
|
228
|
+
.chatgpt-modal .checkbox-group label {
|
|
229
|
+
font-size: 14px ; color: ${ scheme == 'dark' ? '#e1e1e1' : '#1e1e1e' }}`
|
|
221
230
|
)
|
|
222
231
|
}
|
|
223
232
|
|
|
@@ -1988,7 +1997,7 @@ for (const btnAction of cjsBtnActions) {
|
|
|
1988
1997
|
};
|
|
1989
1998
|
}
|
|
1990
1999
|
|
|
1991
|
-
// Create
|
|
2000
|
+
// Create ALIAS functions
|
|
1992
2001
|
const cjsFuncAliases = [
|
|
1993
2002
|
['actAs', 'actas', 'act', 'become', 'persona', 'premadePrompt', 'preMadePrompt', 'prePrompt', 'preprompt', 'roleplay', 'rolePlay', 'rp'],
|
|
1994
2003
|
['activateAutoRefresh', 'activateAutoRefresher', 'activateRefresher', 'activateSessionRefresher',
|
|
@@ -2001,14 +2010,13 @@ const cjsFuncAliases = [
|
|
|
2001
2010
|
['exportChat', 'chatExport', 'export'],
|
|
2002
2011
|
['getFooterDiv', 'getFooter'],
|
|
2003
2012
|
['getHeaderDiv', 'getHeader'],
|
|
2004
|
-
['getLastPrompt', 'getLastQuery', '
|
|
2013
|
+
['getLastPrompt', 'getLastQuery', 'getMyLastMessage', 'getMyLastQuery'],
|
|
2005
2014
|
['getContinueButton', 'getContinueGeneratingButton'],
|
|
2006
2015
|
['getScrollToBottomButton', 'getScrollButton'],
|
|
2007
2016
|
['getStopButton', 'getStopGeneratingButton'],
|
|
2008
2017
|
['getTextarea', 'getTextArea', 'getChatbar', 'getChatBar', 'getChatbox', 'getChatBox'],
|
|
2009
2018
|
['isFullScreen', 'isFullscreen', 'isfullscreen'],
|
|
2010
|
-
['
|
|
2011
|
-
['logOut', 'logout', 'logOff', 'logoff', 'signOut', 'signout', 'signOff', 'signoff'],
|
|
2019
|
+
['logout', 'logOut', 'logOff', 'signOff', 'signOut'],
|
|
2012
2020
|
['minify', 'codeMinify', 'minifyCode'],
|
|
2013
2021
|
['new', 'newChat', 'startNewChat'],
|
|
2014
2022
|
['obfuscate', 'codeObfuscate', 'obfuscateCode'],
|
|
@@ -2018,7 +2026,7 @@ const cjsFuncAliases = [
|
|
|
2018
2026
|
['refreshSession', 'sessionRefresh'],
|
|
2019
2027
|
['renderHTML', 'renderHtml', 'renderLinks', 'renderTags'],
|
|
2020
2028
|
['reviewCode', 'codeReview'],
|
|
2021
|
-
['send', 'sendChat', '
|
|
2029
|
+
['send', 'sendChat', 'sendMessage'],
|
|
2022
2030
|
['sendInNewChat', 'sendNewChat'],
|
|
2023
2031
|
['sentiment', 'analyzeSentiment', 'sentimentAnalysis'],
|
|
2024
2032
|
['startNewChat', 'new', 'newChat'],
|
|
@@ -2029,7 +2037,7 @@ const cjsFuncAliases = [
|
|
|
2029
2037
|
['translate', 'translation', 'translator'],
|
|
2030
2038
|
['unminify', 'unminifyCode', 'codeUnminify'],
|
|
2031
2039
|
['writeCode', 'codeWrite']
|
|
2032
|
-
]
|
|
2040
|
+
]
|
|
2033
2041
|
const cjsFuncSynonyms = [
|
|
2034
2042
|
['account', 'acct'],
|
|
2035
2043
|
['activate', 'turnOn'],
|
|
@@ -2045,6 +2053,7 @@ const cjsFuncSynonyms = [
|
|
|
2045
2053
|
['execute', 'interpret', 'interpreter', 'run'],
|
|
2046
2054
|
['firefox', 'ff'],
|
|
2047
2055
|
['generating', 'generation'],
|
|
2056
|
+
['message', 'msg'],
|
|
2048
2057
|
['minify', 'uglify'],
|
|
2049
2058
|
['refactor', 'rewrite'],
|
|
2050
2059
|
['regenerate', 'regen'],
|
|
@@ -2056,41 +2065,44 @@ const cjsFuncSynonyms = [
|
|
|
2056
2065
|
['typing', 'generating'],
|
|
2057
2066
|
['unminify', 'beautify', 'prettify', 'prettyPrint']
|
|
2058
2067
|
];
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
var newFunctionsCreated = false;
|
|
2080
|
-
for (const funcName in chatgpt) {
|
|
2081
|
-
if (typeof chatgpt[funcName] == 'function') {
|
|
2082
|
-
const funcWords = funcName.split(/(?=[A-Zs])/); // split function name into constituent words
|
|
2083
|
-
for (const funcWord of funcWords) {
|
|
2084
|
-
const synonymValues = [].concat(...cjsFuncSynonyms // flatten into single array w/ word's cjsFuncSynonyms
|
|
2068
|
+
(function createCJSaliasFuncs(obj = chatgpt) {
|
|
2069
|
+
for (const prop in obj) {
|
|
2070
|
+
if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue // skip inherited props
|
|
2071
|
+
if (typeof obj[prop] == 'object') createCJSaliasFuncs(obj[prop]) // recurse thru objs to find deeper functions
|
|
2072
|
+
}
|
|
2073
|
+
let aliasFuncCreated
|
|
2074
|
+
do {
|
|
2075
|
+
aliasFuncCreated = false
|
|
2076
|
+
for (const prop in obj) {
|
|
2077
|
+
if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue // skip inherited props
|
|
2078
|
+
if (typeof obj[prop] == 'function') {
|
|
2079
|
+
obj[prop.toLowerCase()] = obj[prop] // create lowercase variant
|
|
2080
|
+
cjsFuncAliases.forEach(aliasArr => { // create alias function per alias to use
|
|
2081
|
+
if (!aliasArr.includes(prop)) return
|
|
2082
|
+
aliasArr.forEach(alias => { if (!obj[alias]) {
|
|
2083
|
+
obj[alias] = obj[alias.toLowerCase()] = obj[prop] ; aliasFuncCreated = true }})
|
|
2084
|
+
})
|
|
2085
|
+
const funcWords = prop.split(/(?=[A-Z])/) // split function name into constituent words
|
|
2086
|
+
funcWords.forEach(funcWord => { // create alias function per function word per synonym
|
|
2087
|
+
const synonymsToUse = cjsFuncSynonyms
|
|
2085
2088
|
.filter(arr => arr.includes(funcWord.toLowerCase())) // filter in relevant synonym sub-arrays
|
|
2086
|
-
.
|
|
2087
|
-
|
|
2088
|
-
const newFuncName =
|
|
2089
|
-
if (!
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
}
|
|
2089
|
+
.flat().filter(synonym => synonym != funcWord.toLowerCase()) // filter out matching word
|
|
2090
|
+
synonymsToUse.forEach(synonym => { // create alias function per synonym to use
|
|
2091
|
+
const newFuncName = toCamelCase(funcWords.map(word => word == funcWord ? synonym : word))
|
|
2092
|
+
if (!obj[newFuncName]) {
|
|
2093
|
+
obj[newFuncName] = obj[newFuncName.toLowerCase()] = obj[prop] ; aliasFuncCreated = true }
|
|
2094
|
+
})
|
|
2095
|
+
})
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
} while (aliasFuncCreated) // loop over new functions to encompass all variations
|
|
2099
|
+
})()
|
|
2100
|
+
|
|
2101
|
+
|
|
2102
|
+
// Define HELPER functions
|
|
2103
|
+
|
|
2104
|
+
function toCamelCase(words) {
|
|
2105
|
+
return words.map((word, idx) => idx == 0 ? word : word.charAt(0).toUpperCase() + word.slice(1)).join('') }
|
|
2094
2106
|
|
|
2095
2107
|
// Prefix console logs w/ '🤖 chatgpt.js >> '
|
|
2096
2108
|
const consolePrefix = '🤖 chatgpt.js >> ', ogError = console.error, ogInfo = console.info;
|
package/dist/chatgpt.min.js
CHANGED
|
@@ -4,29 +4,77 @@
|
|
|
4
4
|
* User guide: https://chatgptjs.org/userguide
|
|
5
5
|
* Latest minified release: https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js/chatgpt.min.js
|
|
6
6
|
*/
|
|
7
|
-
localStorage.alertQueue=JSON.stringify([]),localStorage.notifyProps=JSON.stringify({queue:{topRight:[],bottomRight:[],bottomLeft:[],topLeft:[]}});let chatgpt={openAIaccessToken:{},endpoints:{assets:"https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@
|
|
8
|
-
|
|
7
|
+
localStorage.alertQueue=JSON.stringify([]),localStorage.notifyProps=JSON.stringify({queue:{topRight:[],bottomRight:[],bottomLeft:[],topLeft:[]}});let chatgpt={openAIaccessToken:{},endpoints:{assets:"https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@b701a312e787060cbb089bffa8b59a1770b15de4",openAI:{session:"https://chatgpt.com/api/auth/session",chats:"https://chatgpt.com/backend-api/conversations",chat:"https://chatgpt.com/backend-api/conversation",share_create:"https://chatgpt.com/backend-api/share/create",share:"https://chatgpt.com/backend-api/share",instructions:"https://chatgpt.com/backend-api/user_system_messages"}},actAs(s){return new Promise((r,a)=>{let n=new XMLHttpRequest;n.open("GET","https://cdn.jsdelivr.net/gh/KudoAI/chat-prompts@b701a312e787060cbb089bffa8b59a1770b15de4/dist/personas.min.json",!0),n.send(),n.onload=()=>{if(200!==n.status)return a("🤖 chatgpt.js >> Request failed. Cannot retrieve prompts data.");var e=JSON.parse(n.responseText).personas;if(s){var t=e.find(e=>e.title.toLowerCase()==s.toLowerCase());if(!t)return a(`🤖 chatgpt.js >> Persona '${s}' was not found!`);chatgpt.send(t.prompt,"click"),console.info(`Loading ${s} persona...`),chatgpt.isIdle().then(()=>{console.info("Persona activated!")})}else{console.log("\n%c🤖 chatgpt.js personas\n","font-family: sans-serif ; font-size: xxx-large ; font-weight: bold");for(var o of e)console.log("%c"+o.title,"font-family: monospace ; font-size: larger ;")}return r()}})},activateDarkMode(){document.documentElement.classList.replace("light","dark"),document.documentElement.style.colorScheme="dark",localStorage.setItem("theme","dark")},activateLightMode(){document.documentElement.classList.replace("dark","light"),document.documentElement.style.colorScheme="light",localStorage.setItem("theme","light")},alert(o,r,e,a,t){let n=chatgpt.isDarkMode()?"dark":"light",s=chatgpt.browser.isMobile(),i={dismiss:{click(e){e.target!=e.currentTarget&&!e.target.closest("[class*=-close-btn]")||f()},key(e){if(/^(?: |Space|Enter|Return|Esc)/.test(e.key)&&[32,13,27].includes(e.keyCode))for(var t of m){var t=document.getElementById(t);if(!t||"none"==t.style.display)return;e.key.startsWith("Esc")||27==e.keyCode?f():(t=t.querySelector(".modal-buttons").lastChild)&&(t.click(),e.preventDefault())}}},drag:{mousedown(e){var t;0==e.button&&"pointer"!=getComputedStyle(e.target).cursor&&(chatgpt.draggableElem=e.currentTarget,Object.assign(chatgpt.draggableElem.style,{cursor:"grabbing",transition:"0.1s",willChange:"transform",transform:"scale(1.05)"}),e.preventDefault(),["mousemove","mouseup"].forEach(e=>document.addEventListener(e,i.drag[e])),t=chatgpt.draggableElem.getBoundingClientRect(),i.drag.offsetX=e.clientX-t.left+21,i.drag.offsetY=e.clientY-t.top+12)},mousemove(e){var t;chatgpt.draggableElem&&(t=e.clientX-i.drag.offsetX,e=e.clientY-i.drag.offsetY,Object.assign(chatgpt.draggableElem.style,{left:t+"px",top:e+"px"}))},mouseup(){Object.assign(chatgpt.draggableElem.style,{cursor:"inherit",transition:"inherit",willChange:"auto",transform:"scale(1)"}),["mousemove","mouseup"].forEach(e=>document.removeEventListener(e,i.drag[e])),chatgpt.draggableElem=null}}},c=document.createElement("div"),l=(c.id=Math.floor(1e6*chatgpt.randomFloat())+Date.now(),c.classList.add("chatgpt-modal"),document.createElement("div")),d=document.createElement("h2"),g=document.createElement("p");var u=1739338889852;let h=document.querySelector("#chatgpt-modal-style"),p=((!h||parseInt(h.getAttribute("last-updated"),10)<u)&&(h||((h=document.createElement("style")).id="chatgpt-modal-style",h.setAttribute("last-updated",u.toString()),document.head.append(h)),h.innerText=`.chatgpt-modal { /* vars */
|
|
8
|
+
--transition: opacity 0.65s cubic-bezier(.165,.84,.44,1), /* for fade-in */
|
|
9
|
+
transform 0.55s cubic-bezier(.165,.84,.44,1) ; /* for move-in */
|
|
10
|
+
--bg-transition: background-color 0.25s ease ; /* for bg dim */
|
|
11
|
+
--btn-transition: transform 0.1s ease-in-out, box-shadow 0.1s ease-in-out ; /* for smooth zoom */
|
|
12
|
+
--btn-shadow: 2px 1px ${"dark"==n?"54px #00cfff":"30px #9cdaff"}}`+".no-mobile-tap-outline { outline: none ; -webkit-tap-highlight-color: transparent }"+`.chatgpt-modal {
|
|
13
|
+
pointer-events: auto ; /* override any disabling from site modals (like guest login spam) */
|
|
14
|
+
position: fixed ; top: 0 ; left: 0 ; width: 100% ; height: 100% ; /* expand to full view-port */
|
|
15
|
+
display: flex ; justify-content: center ; align-items: center ; z-index: 9999 ; /* align */
|
|
16
|
+
transition: var(--bg-transition) ; /* for bg dim */
|
|
17
|
+
-webkit-transition: var(--bg-transition) ; -moz-transition: var(--bg-transition) ;
|
|
18
|
+
-o-transition: var(--bg-transition) ; -ms-transition: var(--bg-transition) }`+`.chatgpt-modal > div {
|
|
19
|
+
position: absolute ; /* to be click-draggable */
|
|
20
|
+
opacity: 0 ; /* to fade-in */
|
|
21
|
+
font-family: -apple-system, system-ui, BlinkMacSystemFont, Segoe UI, Roboto,
|
|
22
|
+
Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif ;
|
|
23
|
+
padding: 20px ; margin: 12px 23px ; font-size: 20px ;
|
|
24
|
+
color: ${"dark"==n?"white":"black"};
|
|
25
|
+
background-color: ${"dark"==n?"black":"white"};
|
|
26
|
+
border: 1px solid ${"dark"==n?"white":"#b5b5b5"};
|
|
27
|
+
transform: translateX(-3px) translateY(7px) ; /* offset to move-in from */
|
|
28
|
+
max-width: 75vw ; word-wrap: break-word ; border-radius: 15px ;
|
|
29
|
+
--shadow: 0 30px 60px rgba(0,0,0,0.12) ; box-shadow: var(--shadow) ;
|
|
30
|
+
-webkit-box-shadow: var(--shadow) ; -moz-box-shadow: var(--shadow) ;
|
|
31
|
+
user-select: none ; -webkit-user-select: none ; -moz-user-select: none ;
|
|
32
|
+
-o-user-select: none ; -ms-user-select: none ;
|
|
33
|
+
transition: var(--transition) ; /* for fade-in + move-in */
|
|
34
|
+
-webkit-transition: var(--transition) ; -moz-transition: var(--transition) ;
|
|
35
|
+
-o-transition: var(--transition) ; -ms-transition: var(--transition) }
|
|
36
|
+
.chatgpt-modal h2 { font-weight: bold ; font-size: 24px ; margin-bottom: 9px }
|
|
9
37
|
.chatgpt-modal a { color: ${"dark"==n?"#00cfff":"#1e9ebb"}}
|
|
10
38
|
.chatgpt-modal a:hover { text-decoration: underline }
|
|
11
39
|
.chatgpt-modal.animated > div {
|
|
12
40
|
z-index: 13456 ; opacity: 0.98 ; transform: translateX(0) translateY(0) }
|
|
13
41
|
@keyframes alert-zoom-fade-out {
|
|
14
42
|
0% { opacity: 1 } 50% { opacity: 0.25 ; transform: scale(1.05) }
|
|
15
|
-
100% { opacity: 0 ; transform: scale(1.35) }}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
43
|
+
100% { opacity: 0 ; transform: scale(1.35) }}`+`.modal-buttons {
|
|
44
|
+
display: flex ; justify-content: flex-end ; margin: 20px -5px -3px 0 ;
|
|
45
|
+
${s?"flex-direction: column-reverse":""}}
|
|
46
|
+
.chatgpt-modal button {
|
|
47
|
+
font-size: 14px ; text-transform: uppercase ;
|
|
48
|
+
margin-left: ${s?0:10}px ; padding: ${s?15:8}px 18px ;
|
|
49
|
+
${s?"margin-top: 5px ; margin-bottom: 3px ;":""}
|
|
50
|
+
border-radius: 0 ; border: 1px solid ${"dark"==n?"white":"black"};
|
|
51
|
+
transition: var(--btn-transition) ;
|
|
52
|
+
-webkit-transition: var(--btn-transition) ; -moz-transition: var(--btn-transition) ;
|
|
53
|
+
-o-transition: var(--btn-transition) ; -ms-transition: var(--btn-transition) }
|
|
54
|
+
.chatgpt-modal button:hover {
|
|
55
|
+
transform: scale(1.055) ; color: black ;
|
|
56
|
+
background-color: #${"dark"==n?"00cfff":"9cdaff"};
|
|
57
|
+
box-shadow: var(--btn-shadow) ;
|
|
58
|
+
-webkit-box-shadow: var(--btn-shadow) ; -moz-box-shadow: var(--btn-shadow) }
|
|
59
|
+
.primary-modal-btn {
|
|
60
|
+
border: 1px solid ${"dark"==n?"white":"black"};
|
|
61
|
+
background: ${"dark"==n?"white":"black"};
|
|
62
|
+
color: ${"dark"==n?"black":"white"}}
|
|
63
|
+
.modal-close-btn {
|
|
64
|
+
cursor: pointer ; width: 29px ; height: 29px ; border-radius: 17px ;
|
|
65
|
+
float: right ; position: relative ; right: -6px ; top: -5px }
|
|
66
|
+
.modal-close-btn svg { margin: 10px } /* center SVG for hover underlay */
|
|
67
|
+
.modal-close-btn:hover { background-color: #f2f2f2${"dark"==n?"00":""}}`+`.chatgpt-modal .checkbox-group { margin: 5px 0 -8px 5px }
|
|
68
|
+
.chatgpt-modal input[type=checkbox] {
|
|
69
|
+
cursor: pointer ; transform: scale(0.7) ; margin-right: 5px ;
|
|
24
70
|
border: 1px solid ${"dark"==n?"white":"black"}}
|
|
25
71
|
.chatgpt-modal input[type=checkbox]:checked {
|
|
26
|
-
|
|
27
|
-
|
|
72
|
+
background-color: black ; position: inherit ;
|
|
73
|
+
border: 1px solid ${"dark"==n?"white":"black"}}
|
|
28
74
|
.chatgpt-modal input[type=checkbox]:focus {
|
|
29
|
-
outline: none ; box-shadow: none ; -webkit-box-shadow: none ; -moz-box-shadow: none }`),d.innerText=o||"",g.innerText=r||"",chatgpt.renderHTML(g),document.createElement("div"));p.classList.add("modal-buttons","no-mobile-tap-outline"),e&&(e=Array.isArray(e)?e:[e]).forEach(e=>{var t=document.createElement("button");t.textContent=e.name.replace(/[_-]\w/g,e=>e.slice(1).toUpperCase()).replace(/([A-Z])/g," $1").replace(/^\w/,e=>e.toUpperCase()),t.onclick=()=>{f(),e()},p.insertBefore(t,p.firstChild)});u=document.createElement("button"),u.textContent=e?"Dismiss":"OK",p.insertBefore(u,p.firstChild),p.lastChild.classList.add("primary-modal-btn"),o=document.createElement("div");if(a){o.classList.add("checkbox-group");let e=a,t=document.createElement("input");t.type="checkbox",t.onchange=e;r=document.createElement("label");r.onclick=()=>{t.checked=!t.checked,e()},r.textContent=e.name.charAt(0).toUpperCase()+e.name.slice(1).replace(/([A-Z])/g,(e,t)=>" "+t.toLowerCase()).replace(/\b(\w+)nt\b/gi,"$1n't").trim(),o.append(t),o.append(r)}e=document.createElement("div"),e.title="Close",e.classList.add("modal-close-btn","no-mobile-tap-outline"),a=document.createElementNS("http://www.w3.org/2000/svg","svg"),a.setAttribute("height","10px"),a.setAttribute("viewBox","0 0 14 14"),a.setAttribute("fill","none"),r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("fill",chatgpt.isDarkMode()?"white":"black"),r.setAttribute("d","M13.7071 1.70711C14.0976 1.31658 14.0976 0.683417 13.7071 0.292893C13.3166 -0.0976312 12.6834 -0.0976312 12.2929 0.292893L7 5.58579L1.70711 0.292893C1.31658 -0.0976312 0.683417 -0.0976312 0.292893 0.292893C-0.0976312 0.683417 -0.0976312 1.31658 0.292893 1.70711L5.58579 7L0.292893 12.2929C-0.0976312 12.6834 -0.0976312 13.3166 0.292893 13.7071C0.683417 14.0976 1.31658 14.0976 1.70711 13.7071L7 8.41421L12.2929 13.7071C12.6834 14.0976 13.3166 14.0976 13.7071 13.7071C14.0976 13.3166 14.0976 12.6834 13.7071 12.2929L8.41421 7L13.7071 1.70711Z"),a.append(r),e.append(a),[e,d,g,o,p].forEach(e=>{l.append(e)}),l.style.width=`${t||458}px`,c.append(l),document.body.append(c);let m=JSON.parse(localStorage.alertQueue),f=(m.push(c.id),localStorage.alertQueue=JSON.stringify(m),c.style.display="none",1===m.length&&(c.style.display="",setTimeout(()=>{l.parentNode.style.backgroundColor=`rgba(67,70,72,${"dark"==n?.62:.33})`,l.parentNode.classList.add("animated")},100)),[c,e,a,u].forEach(e=>e.onclick=i.dismiss.click),document.addEventListener("keydown",i.dismiss.key),l.onmousedown=i.drag.mousedown,()=>{c.style.backgroundColor="transparent",l.style.animation="alert-zoom-fade-out 0.165s ease-out",l.onanimationend=()=>{if(c.remove(),(m=JSON.parse(localStorage.alertQueue)).shift(),localStorage.alertQueue=JSON.stringify(m),document.removeEventListener("keydown",i.dismiss.key),0<m.length){let e=document.getElementById(m[0]);setTimeout(()=>{e.style.display="",setTimeout(()=>e.classList.add("animated"),100)},500)}}});return c.id},async askAndGetReply(e){return chatgpt.send(e),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},autoRefresh:{activate(e){if(this.isActive)console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already active!");else{let o=this,r=(this.toggle.refreshFrame(),t=>{var e=Math.max(2,Math.floor(21*chatgpt.randomFloat()-10));o.isActive=setTimeout(()=>{var e=document.querySelector('script[src*="_ssgManifest.js"]');e&&(document.querySelector("#refresh-frame").src=e.src+"?"+Date.now(),console.log("↻ ChatGPT >> ["+o.nowTimeStamp()+"] ChatGPT session refreshed")),r(t)},1e3*(t+e))});r(e?parseInt(e,10):30),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh activated"),navigator.userAgent.includes("Chrome")&&void 0!==document.hidden&&document.addEventListener("visibilitychange",this.toggle.beacons)}},deactivate(){this.isActive?(this.toggle.refreshFrame(),document.removeEventListener("visibilitychange",this.toggle.beacons),clearTimeout(this.isActive),this.isActive=null,console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh de-activated")):console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already inactive!")},nowTimeStamp(){var e=new Date,t=e.getHours()%12||12;let o=e.getMinutes(),r=e.getSeconds();o<10&&(o="0"+o),r<10&&(r="0"+r);e=e.getHours()<12?"AM":"PM";return t+":"+o+":"+r+" "+e},toggle:{beacons(){chatgpt.autoRefresh.beaconID?(clearInterval(chatgpt.autoRefresh.beaconID),chatgpt.autoRefresh.beaconID=null,console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacons de-activated")):(chatgpt.autoRefresh.beaconID=setInterval(()=>{navigator.sendBeacon("https://httpbin.org/post",new Uint8Array),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacon sent")},9e4),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacons activated"))},refreshFrame(){let e=document.querySelector("#refresh-frame");e?e.remove():(e=Object.assign(document.createElement("iframe"),{id:"refresh-frame",style:"display: none"}),document.head.prepend(e))}}},browser:{isLightMode(){return window.matchMedia?.("(prefers-color-scheme: light)")?.matches},isDarkMode(){return window.matchMedia?.("(prefers-color-scheme: dark)")?.matches},isChromium(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Chromium")},isChrome(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Chrome")},isEdge(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Edge")},isBrave(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Brave")},isFirefox(){return navigator.userAgent.includes("Firefox")},isFullScreen(){var e=navigator.userAgent;return e.includes("Chrome")?window.matchMedia("(display-mode: fullscreen)").matches:e.includes("Firefox")?window.fullScreen:/MSIE|rv:/.test(e)?document.msFullscreenElement:document.webkitIsFullScreen},isMobile(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}},async clearChats(){return new Promise((o,r)=>{chatgpt.getAccessToken().then(e=>{let t=new XMLHttpRequest;t.open("PATCH",chatgpt.endpoints.openAI.chats,!0),t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("Authorization","Bearer "+e),t.onload=()=>{if(200!==t.status)return r("🤖 chatgpt.js >> Request failed. Cannot clear chats.");console.info("Chats successfully cleared"),o()},t.send(JSON.stringify({is_visible:!1}))}).catch(e=>r(new Error(e.message)))})},code:{async execute(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Display the output as if you were terminal:\n\n"+e),console.info("Executing code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},extract(e){var t=e.match(/(?<=```.*\n)[\s\S]*?(?=```)/g);return t?t[t.length-1]:e},async isIdle(t=null){let a={childList:!0,subtree:!0},n={msgDiv:"div[data-message-author-role]",replyDiv:"div[data-message-author-role=assistant]"};var e=t?new Promise(e=>setTimeout(()=>e(!1),t)):null,o=(async()=>{await new Promise(o=>{document.querySelector(n.msgDiv)?o():new MutationObserver((e,t)=>{document.querySelector(n.msgDiv)&&(t.disconnect(),o())}).observe(document.body,a)}),await new Promise(o=>{new MutationObserver((e,t)=>{chatgpt.getStopBtn()&&(t.disconnect(),o())}).observe(document.body,{childList:!0,subtree:!0})});let e=document.querySelectorAll(n.replyDiv),r=e[e.length-1];return await new Promise(o=>{new MutationObserver((e,t)=>{r?.querySelector("pre")&&(t.disconnect(),o())}).observe(document.body,a)}),new Promise(o=>{new MutationObserver((e,t)=>{!r?.querySelector("pre")?.nextElementSibling&&chatgpt.getStopBtn()||(t.disconnect(),o(!0))}).observe(document.body,a)})})();return e?Promise.race([o,e]):o},async minify(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Minify the following code:\n\n"+e),console.info("Minifying code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},async obfuscate(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Obfuscate the following code:\n\n"+e),console.info("Obfuscating code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},async refactor(e,t){if(!e)return console.error("Code (1st) argument not supplied. Pass some code!");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send("Refactor the following code for "+(t||"brevity")+":\n\n"+e),console.info("Refactoring code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))},async review(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Review the following code for me:\n\n"+e),console.info("Reviewing code..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")):console.error("Code argument not supplied. Pass some code!")},async unminify(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Unminify the following code.:\n\n"+e),console.info("Unminifying code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},async write(e,t){if(!e)return console.error("Prompt (1st) argument not supplied. Pass a prompt!");if(!t)return console.error("outputLang (2nd) argument not supplied. Pass a language!");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send(e+"\n\nWrite this as code in "+t),console.info("Writing code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))}},continue(){chatgpt.response.continue()},async detectLanguage(e){return e?"string"!=typeof e?console.error("Text argument must be a string!"):(chatgpt.send("Detect the language of the following text:\n\n"+e+"\n\nOnly respond with the name of the language"),console.info("Reviewing text..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")):console.error("Text argument not supplied. Pass some text!")},executeCode(){chatgpt.code.execute()},async exportChat(e,t){e=e?Number.isInteger(e)||/^\d+$/.test(e)?parseInt(e,10):e:"active",t=t.toLowerCase()||"html",console.info("Generating transcript...");let a="",o;if(/te?xt/.test(t)){var r=new Date,n=r.getDate().toString().padStart(2,"0"),s=(r.getMonth()+1).toString().padStart(2,"0"),i=r.getFullYear(),c=r.getHours().toString().padStart(2,"0"),r=r.getMinutes().toString().padStart(2,"0");if(o=`ChatGPT_${n}-${s}-${i}_${c}-${r}.txt`,"active"==e&&/\/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(window.location.href)){n=document.querySelectorAll("main > div > div > div > div > div > div[class*=group]");if(!n.length)return console.error("Chat is empty!");let o=[],r=!0;n.forEach(e=>{var t=r?"USER":"CHATGPT",e=(r=!r,Array.from(e.childNodes).map(e=>e.innerText).join("\n\n").replace("Copy code",""));o.push(t+": "+e)}),a=o.join("\n\n")}else for(var l of await chatgpt.getChatData(e,"msg","both","all"))a=(a+=`USER: ${l.user}
|
|
75
|
+
outline: none ; box-shadow: none ; -webkit-box-shadow: none ; -moz-box-shadow: none }
|
|
76
|
+
.chatgpt-modal .checkbox-group label {
|
|
77
|
+
font-size: 14px ; color: ${"dark"==n?"#e1e1e1":"#1e1e1e"}}`),d.innerText=o||"",g.innerText=r||"",chatgpt.renderHTML(g),document.createElement("div"));p.classList.add("modal-buttons","no-mobile-tap-outline"),e&&(e=Array.isArray(e)?e:[e]).forEach(e=>{var t=document.createElement("button");t.textContent=e.name.replace(/[_-]\w/g,e=>e.slice(1).toUpperCase()).replace(/([A-Z])/g," $1").replace(/^\w/,e=>e.toUpperCase()),t.onclick=()=>{f(),e()},p.insertBefore(t,p.firstChild)});u=document.createElement("button"),u.textContent=e?"Dismiss":"OK",p.insertBefore(u,p.firstChild),p.lastChild.classList.add("primary-modal-btn"),o=document.createElement("div");if(a){o.classList.add("checkbox-group");let e=a,t=document.createElement("input");t.type="checkbox",t.onchange=e;r=document.createElement("label");r.onclick=()=>{t.checked=!t.checked,e()},r.textContent=e.name.charAt(0).toUpperCase()+e.name.slice(1).replace(/([A-Z])/g,(e,t)=>" "+t.toLowerCase()).replace(/\b(\w+)nt\b/gi,"$1n't").trim(),o.append(t),o.append(r)}e=document.createElement("div"),e.title="Close",e.classList.add("modal-close-btn","no-mobile-tap-outline"),a=document.createElementNS("http://www.w3.org/2000/svg","svg"),a.setAttribute("height","10px"),a.setAttribute("viewBox","0 0 14 14"),a.setAttribute("fill","none"),r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),r.setAttribute("fill",chatgpt.isDarkMode()?"white":"black"),r.setAttribute("d","M13.7071 1.70711C14.0976 1.31658 14.0976 0.683417 13.7071 0.292893C13.3166 -0.0976312 12.6834 -0.0976312 12.2929 0.292893L7 5.58579L1.70711 0.292893C1.31658 -0.0976312 0.683417 -0.0976312 0.292893 0.292893C-0.0976312 0.683417 -0.0976312 1.31658 0.292893 1.70711L5.58579 7L0.292893 12.2929C-0.0976312 12.6834 -0.0976312 13.3166 0.292893 13.7071C0.683417 14.0976 1.31658 14.0976 1.70711 13.7071L7 8.41421L12.2929 13.7071C12.6834 14.0976 13.3166 14.0976 13.7071 13.7071C14.0976 13.3166 14.0976 12.6834 13.7071 12.2929L8.41421 7L13.7071 1.70711Z"),a.append(r),e.append(a),[e,d,g,o,p].forEach(e=>{l.append(e)}),l.style.width=`${t||458}px`,c.append(l),document.body.append(c);let m=JSON.parse(localStorage.alertQueue),f=(m.push(c.id),localStorage.alertQueue=JSON.stringify(m),c.style.display="none",1===m.length&&(c.style.display="",setTimeout(()=>{l.parentNode.style.backgroundColor=`rgba(67,70,72,${"dark"==n?.62:.33})`,l.parentNode.classList.add("animated")},100)),[c,e,a,u].forEach(e=>e.onclick=i.dismiss.click),document.addEventListener("keydown",i.dismiss.key),l.onmousedown=i.drag.mousedown,()=>{c.style.backgroundColor="transparent",l.style.animation="alert-zoom-fade-out 0.165s ease-out",l.onanimationend=()=>{if(c.remove(),(m=JSON.parse(localStorage.alertQueue)).shift(),localStorage.alertQueue=JSON.stringify(m),document.removeEventListener("keydown",i.dismiss.key),0<m.length){let e=document.getElementById(m[0]);setTimeout(()=>{e.style.display="",setTimeout(()=>e.classList.add("animated"),100)},500)}}});return c.id},async askAndGetReply(e){return chatgpt.send(e),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},autoRefresh:{activate(e){if(this.isActive)console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already active!");else{let o=this,r=(this.toggle.refreshFrame(),t=>{var e=Math.max(2,Math.floor(21*chatgpt.randomFloat()-10));o.isActive=setTimeout(()=>{var e=document.querySelector('script[src*="_ssgManifest.js"]');e&&(document.querySelector("#refresh-frame").src=e.src+"?"+Date.now(),console.log("↻ ChatGPT >> ["+o.nowTimeStamp()+"] ChatGPT session refreshed")),r(t)},1e3*(t+e))});r(e?parseInt(e,10):30),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh activated"),navigator.userAgent.includes("Chrome")&&void 0!==document.hidden&&document.addEventListener("visibilitychange",this.toggle.beacons)}},deactivate(){this.isActive?(this.toggle.refreshFrame(),document.removeEventListener("visibilitychange",this.toggle.beacons),clearTimeout(this.isActive),this.isActive=null,console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh de-activated")):console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already inactive!")},nowTimeStamp(){var e=new Date,t=e.getHours()%12||12;let o=e.getMinutes(),r=e.getSeconds();o<10&&(o="0"+o),r<10&&(r="0"+r);e=e.getHours()<12?"AM":"PM";return t+":"+o+":"+r+" "+e},toggle:{beacons(){chatgpt.autoRefresh.beaconID?(clearInterval(chatgpt.autoRefresh.beaconID),chatgpt.autoRefresh.beaconID=null,console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacons de-activated")):(chatgpt.autoRefresh.beaconID=setInterval(()=>{navigator.sendBeacon("https://httpbin.org/post",new Uint8Array),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacon sent")},9e4),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacons activated"))},refreshFrame(){let e=document.querySelector("#refresh-frame");e?e.remove():(e=Object.assign(document.createElement("iframe"),{id:"refresh-frame",style:"display: none"}),document.head.prepend(e))}}},browser:{isLightMode(){return window.matchMedia?.("(prefers-color-scheme: light)")?.matches},isDarkMode(){return window.matchMedia?.("(prefers-color-scheme: dark)")?.matches},isChromium(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Chromium")},isChrome(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Chrome")},isEdge(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Edge")},isBrave(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Brave")},isFirefox(){return navigator.userAgent.includes("Firefox")},isFullScreen(){var e=navigator.userAgent;return e.includes("Chrome")?window.matchMedia("(display-mode: fullscreen)").matches:e.includes("Firefox")?window.fullScreen:/MSIE|rv:/.test(e)?document.msFullscreenElement:document.webkitIsFullScreen},isMobile(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}},async clearChats(){return new Promise((o,r)=>{chatgpt.getAccessToken().then(e=>{let t=new XMLHttpRequest;t.open("PATCH",chatgpt.endpoints.openAI.chats,!0),t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("Authorization","Bearer "+e),t.onload=()=>{if(200!==t.status)return r("🤖 chatgpt.js >> Request failed. Cannot clear chats.");console.info("Chats successfully cleared"),o()},t.send(JSON.stringify({is_visible:!1}))}).catch(e=>r(new Error(e.message)))})},code:{async execute(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Display the output as if you were terminal:\n\n"+e),console.info("Executing code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},extract(e){var t=e.match(/(?<=```.*\n)[\s\S]*?(?=```)/g);return t?t[t.length-1]:e},async isIdle(t=null){let a={childList:!0,subtree:!0},n={msgDiv:"div[data-message-author-role]",replyDiv:"div[data-message-author-role=assistant]"};var e=t?new Promise(e=>setTimeout(()=>e(!1),t)):null,o=(async()=>{await new Promise(o=>{document.querySelector(n.msgDiv)?o():new MutationObserver((e,t)=>{document.querySelector(n.msgDiv)&&(t.disconnect(),o())}).observe(document.body,a)}),await new Promise(o=>{new MutationObserver((e,t)=>{chatgpt.getStopBtn()&&(t.disconnect(),o())}).observe(document.body,{childList:!0,subtree:!0})});let e=document.querySelectorAll(n.replyDiv),r=e[e.length-1];return await new Promise(o=>{new MutationObserver((e,t)=>{r?.querySelector("pre")&&(t.disconnect(),o())}).observe(document.body,a)}),new Promise(o=>{new MutationObserver((e,t)=>{!r?.querySelector("pre")?.nextElementSibling&&chatgpt.getStopBtn()||(t.disconnect(),o(!0))}).observe(document.body,a)})})();return e?Promise.race([o,e]):o},async minify(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Minify the following code:\n\n"+e),console.info("Minifying code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},async obfuscate(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Obfuscate the following code:\n\n"+e),console.info("Obfuscating code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},async refactor(e,t){if(!e)return console.error("Code (1st) argument not supplied. Pass some code!");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send("Refactor the following code for "+(t||"brevity")+":\n\n"+e),console.info("Refactoring code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))},async review(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Review the following code for me:\n\n"+e),console.info("Reviewing code..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")):console.error("Code argument not supplied. Pass some code!")},async unminify(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Unminify the following code.:\n\n"+e),console.info("Unminifying code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},async write(e,t){if(!e)return console.error("Prompt (1st) argument not supplied. Pass a prompt!");if(!t)return console.error("outputLang (2nd) argument not supplied. Pass a language!");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send(e+"\n\nWrite this as code in "+t),console.info("Writing code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))}},continue(){chatgpt.response.continue()},async detectLanguage(e){return e?"string"!=typeof e?console.error("Text argument must be a string!"):(chatgpt.send("Detect the language of the following text:\n\n"+e+"\n\nOnly respond with the name of the language"),console.info("Reviewing text..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")):console.error("Text argument not supplied. Pass some text!")},executeCode(){chatgpt.code.execute()},async exportChat(e,t){e=e?Number.isInteger(e)||/^\d+$/.test(e)?parseInt(e,10):e:"active",t=t.toLowerCase()||"html",console.info("Generating transcript...");let a="",o;if(/te?xt/.test(t)){var r=new Date,n=r.getDate().toString().padStart(2,"0"),s=(r.getMonth()+1).toString().padStart(2,"0"),i=r.getFullYear(),c=r.getHours().toString().padStart(2,"0"),r=r.getMinutes().toString().padStart(2,"0");if(o=`ChatGPT_${n}-${s}-${i}_${c}-${r}.txt`,"active"==e&&/\/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(window.location.href)){n=document.querySelectorAll("main > div > div > div > div > div > div[class*=group]");if(!n.length)return console.error("Chat is empty!");let o=[],r=!0;n.forEach(e=>{var t=r?"USER":"CHATGPT",e=(r=!r,Array.from(e.childNodes).map(e=>e.innerText).join("\n\n").replace("Copy code",""));o.push(t+": "+e)}),a=o.join("\n\n")}else for(var l of await chatgpt.getChatData(e,"msg","both","all"))a=(a+=`USER: ${l.user}
|
|
30
78
|
|
|
31
79
|
`)+`CHATGPT: ${l.chatgpt}
|
|
32
80
|
|
|
@@ -34,4 +82,4 @@ localStorage.alertQueue=JSON.stringify([]),localStorage.notifyProps=JSON.stringi
|
|
|
34
82
|
|
|
35
83
|
`+r,new Promise(o=>{chatgpt.getAccessToken().then(async e=>{var t=await this.fetchData();return"user"==a?t.about_user_message+=r:"chatgpt"==a&&(t.about_model_message+=r),await this.sendRequest("POST",e,t),o()})})):console.error(`Invalid target ${a}. Valid targets are [${e}]`)):console.error("Please provide a valid target!")):console.error("Please provide an instruction")},clear(r){var e=["user","chatgpt"];return r?"string"!=typeof r?console.error("Target must be a string"):(r=r.toLowerCase(),e.includes(r)?new Promise(o=>{chatgpt.getAccessToken().then(async e=>{var t=await this.fetchData();return"user"==r?t.about_user_message="":"chatgpt"==r&&(t.about_model_message=""),await this.sendRequest("POST",e,t),o()})}):console.error(`Invalid target ${r}. Valid targets are [${e}]`)):console.error("Please provide a valid target!")},fetchData(){return new Promise(t=>{chatgpt.getAccessToken().then(async e=>t(await this.sendRequest("GET",e)))})},sendRequest(a,e,n){for(let e=0;e<arguments.length-1;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string`);var t=["POST","GET"];return(a=(a||"").trim().toUpperCase())&&t.includes(a)?e?n&&"object"!=typeof n?console.error(`Invalid body data type. Got ${typeof n}, expected object`):new Promise((t,o)=>{let r=new XMLHttpRequest;r.open(a,chatgpt.endpoints.openAI.instructions,!0),r.setRequestHeader("Accept-Language","en-US"),r.setRequestHeader("Authorization","Bearer "+e),"POST"==a&&r.setRequestHeader("Content-Type","application/json"),r.onload=()=>{var e=JSON.parse(r.responseText);return 422===r.status?o("🤖 chatgpt.js >> Character limit exceeded. Custom instructions can have a maximum length of 1500 characters."):403===r.status&&"content_policy"==e.detail.reason?o("🤖 chatgpt.js >> "+e.detail.description):200!==r.status?o("🤖 chatgpt.js >> Request failed. Cannot contact custom instructions endpoint."):(console.info("Custom instructions successfully contacted with method "+a),t(e||{}))},r.send(JSON.stringify(n)||"")}):console.error("Please provide a valid access token!"):console.error("Valid methods are "+t)},turnOff(){return new Promise(o=>{chatgpt.getAccessToken().then(async e=>{var t=await this.fetchData();return t.enabled=!1,await this.sendRequest("POST",e,t),o()})})},turnOn(){return new Promise(o=>{chatgpt.getAccessToken().then(async e=>{var t=await this.fetchData();return t.enabled=!0,await this.sendRequest("POST",e,t),o()})})},toggle(){return new Promise(t=>{this.fetchData().then(async e=>(await(e.enabled?this.turnOff():this.turnOn()),t()))})}},isDarkMode(){return document.documentElement.className.includes("dark")},isFullScreen(){return chatgpt.browser.isFullScreen()},async isIdle(t=null){let e={childList:!0,subtree:!0},r="div[data-message-author-role]";var o=t?new Promise(e=>setTimeout(()=>e(!1),t)):null,a=(async()=>(await new Promise(o=>{document.querySelector(r)?o():new MutationObserver((e,t)=>{document.querySelector(r)&&(t.disconnect(),o())}).observe(document.body,e)}),await new Promise(o=>{new MutationObserver((e,t)=>{chatgpt.getStopBtn()&&(t.disconnect(),o())}).observe(document.body,e)}),new Promise(o=>{new MutationObserver((e,t)=>{chatgpt.getStopBtn()||(t.disconnect(),o(!0))}).observe(document.body,e)})))();return o?Promise.race([a,o]):a},async isLoaded(t=null){var e=t?new Promise(e=>setTimeout(()=>e(!1),t)):null,o=new Promise(o=>{chatgpt.getNewChatBtn()?o(!0):new MutationObserver((e,t)=>{chatgpt.getNewChatBtn()&&(t.disconnect(),o(!0))}).observe(document.documentElement,{childList:!0,subtree:!0})});return e?Promise.race([o,e]):o},isLightMode(){return document.documentElement.classList.toString().includes("light")},isTyping(){return!!this.getStopButton()},logout(){window.location.href="https://chat.openai.com/auth/logout"},menu:{elements:[],addedEvent:!1,append(e,t={}){var o=["button","dropdown"];if(!e||"string"!=typeof e)return console.error("🤖 chatgpt.js >> Please supply a valid string element name!");if(e=e.toLowerCase(),!o.includes(e))return console.error(`🤖 chatgpt.js >> Invalid element! Valid elements are [${o}]`);let r=document.createElement("dropdown"==e?"select":"button"==e?"a":e);if(r.id=Math.floor(1e6*chatgpt.randomFloat())+Date.now(),"button"==e){r.textContent=t?.label&&"string"==typeof t.label?t.label:"chatgpt.js button";o=document.createElement("img");o.src=t?.icon&&"string"==typeof t.icon?t.icon:chatgpt.endpoints.assets+"/starters/chrome/extension/icons/icon128.png",o.width=18,r.insertBefore(o,r.firstChild),r.onclick=t?.onclick&&"function"==typeof t.onclick?t.onclick:function(){}}else if("dropdown"==e){if(t?.items&&Array.isArray(t.items)&&t.items.length||(t.items=[{text:"🤖 chatgpt.js option",value:"chatgpt.js option value"}]),!t.items.every(e=>"object"==typeof e))return console.error("'items' must be an array of objects!");r.style="background-color: #000; width: 100%; border: none;",t.items.forEach(e=>{var t=document.createElement("option");t.textContent=e?.text,t.value=e?.value,r.add(t)})}let a=()=>{var e,t=document.querySelectorAll("a[role=menuitem]");let o;for(e of t)if("Settings"==e.textContent){o=e.classList;break}let r=t[0].parentNode;chatgpt.menu.elements.forEach(e=>{if(e.setAttribute("class",o),!r.contains(e))try{r.insertBefore(e,r.firstChild)}catch(e){console.error(e)}})};this.elements.push(r);o=document.querySelector("nav button[id*=headless]");return this.addedEvent||(o?.addEventListener("click",()=>{setTimeout(a,25)}),this.addedEvent=!0),r.id},close(){try{document.querySelector("nav [id*=menu-button][aria-expanded=true]").click()}catch(e){console.error(e.message)}},open(){try{document.querySelector("nav [id*=menu-button][aria-expanded=false]").click()}catch(e){console.error(e.message)}}},minify(){chatgpt.code.minify()},notify(e,t,o,r){o=o?+o:1.75;let a=document.createElement("div");a.id=Math.floor(1e6*chatgpt.randomFloat())+Date.now(),a.classList.add("chatgpt-notif"),a.innerText=e,document.body.append(a);var e=document.createElement("div"),n=(e.title="Dismiss",e.classList.add("notif-close-btn","no-mobile-tap-outline"),document.createElementNS("http://www.w3.org/2000/svg","svg")),s=(n.setAttribute("height","8px"),n.setAttribute("viewBox","0 0 14 14"),n.setAttribute("fill","none"),n.style.height=n.style.width="8px",document.createElementNS("http://www.w3.org/2000/svg","path")),s=(s.setAttribute("fill-rule","evenodd"),s.setAttribute("clip-rule","evenodd"),s.setAttribute("fill","white"),s.setAttribute("d","M13.7071 1.70711C14.0976 1.31658 14.0976 0.683417 13.7071 0.292893C13.3166 -0.0976312 12.6834 -0.0976312 12.2929 0.292893L7 5.58579L1.70711 0.292893C1.31658 -0.0976312 0.683417 -0.0976312 0.292893 0.292893C-0.0976312 0.683417 -0.0976312 1.31658 0.292893 1.70711L5.58579 7L0.292893 12.2929C-0.0976312 12.6834 -0.0976312 13.3166 0.292893 13.7071C0.683417 14.0976 1.31658 14.0976 1.70711 13.7071L7 8.41421L12.2929 13.7071C12.6834 14.0976 13.3166 14.0976 13.7071 13.7071C14.0976 13.3166 14.0976 12.6834 13.7071 12.2929L8.41421 7L13.7071 1.70711Z"),n.append(s),e.append(n),a.append(e),a.isTop=!t||!/low|bottom/i.test(t),a.isRight=!t||!/left/i.test(t),a.quadrant=(a.isTop?"top":"bottom")+(a.isRight?"Right":"Left"),1735767823541);let i=document.querySelector("#chatgpt-notif-style"),c=((!i||parseInt(i.getAttribute("last-updated"),10)<s)&&(i||((i=document.createElement("style")).id="chatgpt-notif-style",i.setAttribute("last-updated",s.toString()),document.head.append(i)),i.innerText='.chatgpt-notif {font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC","Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif ;.no-mobile-tap-outline { outline: none ; -webkit-tap-highlight-color: transparent }background-color: black ; padding: 10px 13px 10px 18px ;border-radius: 11px ; border: 1px solid #f5f5f7 ;opacity: 0 ; position: fixed ; z-index: 9999 ; font-size: 1.8rem ; color: white ;user-select: none ; -webkit-user-select: none ; -moz-user-select: none ; -o-user-select: none ;-ms-user-select: none ;'+`transform: translateX(${a.isRight?"":"-"}35px) ;`+(r?`--shadow: -8px 13px 25px 0 ${/\b(?:shadow|on)\b/i.test(r)?"gray":r};
|
|
36
84
|
box-shadow: var(--shadow) ; -webkit-box-shadow: var(--shadow) ; -moz-box-shadow: var(--shadow)`:"")+"}"+`.notif-close-btn {
|
|
37
|
-
cursor: pointer ; float: right ; position: relative ; right: -4px ; margin-left: -3px ;`+"display: grid }@keyframes notif-zoom-fade-out { 0% { opacity: 1 ; transform: scale(1) }15% { opacity: 0.35 ; transform: rotateX(-27deg) scale(1.05) }45% { opacity: 0.05 ; transform: rotateX(-81deg) }100% { opacity: 0 ; transform: rotateX(-180deg) scale(1.15) }}"),JSON.parse(localStorage.notifyProps));c.queue[a.quadrant].push(a.id),localStorage.notifyProps=JSON.stringify(c),a.style.top=a.isTop?23..toString()+"px":"",a.style.bottom=a.isTop?"":23..toString()+"px",a.style.right=a.isRight?27..toString()+"px":"",a.style.left=a.isRight?"":27..toString()+"px";e=c.queue[a.quadrant];if(1<e.length)try{for(var l of e.slice(0,-1)){var d=document.getElementById(l),g=d.style.top?"top":"bottom",u=+/\d+/.exec(d.style[g])[0]+5+d.getBoundingClientRect().height;d.style[g]=u+"px"}}catch(e){}setTimeout(()=>{a.style.opacity=chatgpt.isDarkMode()?.8:.67,a.style.transform="translateX(0)",a.style.transition="transform 0.15s ease, opacity 0.15s ease"},10);t=()=>{a.style.animation="notif-zoom-fade-out 0.35s ease-out",clearTimeout(h)};let h=setTimeout(t,1e3*(o<.35?0:o-.35));return n.onclick=t,a.onanimationend=()=>{a.remove(),(c=JSON.parse(localStorage.notifyProps)).queue[a.quadrant].shift(),localStorage.notifyProps=JSON.stringify(c)},a},obfuscate(){chatgpt.code.obfuscate()},printAllFunctions(){let o={cmdPrompt:["#ff00ff","#00ff00"],objName:["#0611e9","#f9ee16"],methodName:["#005aff","#ffa500"],entryType:["#467e06","#b981f9"],srcMethod:["#ff0000","#00ffff"]};Object.keys(o).forEach(e=>{o[e][1]=o[e][1]||"#"+(16777215^Number("0x1"+o[e][0].replace(/^#/,""))).toString(16).substring(1).toUpperCase()});var e=[];for(let t in this)if("function"==typeof this[t]){var r=!Object.keys(this).find(e=>Object.keys(this[e]).includes(this[t].name));e.push([r?"chatgpt":"other",t])}else if("object"==typeof this[t])for(var a in this[t])"function"==typeof this[t][a]&&e.push([t,a]);e.sort((e,t)=>e[0].localeCompare(t[0])||e[1].localeCompare(t[1]));var n=window.matchMedia("(prefers-color-scheme: dark)").matches,s="font-family: monospace ; font-size: larger ; ";console.log("\n%c🤖 chatgpt.js methods\n","font-family: sans-serif ; font-size: xxx-large ; font-weight: bold");for(let t of e){var i=/chatgpt|other/.test(t[0]),c="chatgpt"==t[0]?this[t[1]].name:"other"!==t[0]?t[0]+"."+t[1]:Object.keys(this).find(e=>Object.keys(this[e]).includes(this[t[1]].name))+"."+this[t[1]].name,l="AsyncFunction"==this[t[1]]?.constructor.name;console.log("%c>> %c"+(i?"":t[0]+".%c")+t[1]+" - https://chatgptjs.org/userguide/"+/(?:.*\.)?(.*)/.exec(c)[1].toLowerCase()+(l?"-async":"")+"\n%c[%c"+("chatgpt"==t[0]&&t[1]==this[t[1]].name||!i?"Function":"Alias of")+"%c: %c"+c+"%c]",s+"font-weight: bold ; color:"+o.cmdPrompt[+n],s+"font-weight: bold ;color:"+o[i?"methodName":"objName"][+n],s+"font-weight: "+(i?"initial":"bold")+";color:"+(i?"initial":o.methodName[+n]),s+"font-weight: "+(i?"bold":"initial")+";color:"+(i?o.entryType[+n]:"initial"),s+"font-weight: "+(i?"initial":"bold")+";color:"+(i?"initial":o.entryType[+n]),s+(i?"font-style: italic":"font-weight: initial")+";color:"+(i?o.srcMethod[+n]:"initial"),s+(i?"font-weight: initial":"font-style: italic")+";color:"+(i?"initial":o.srcMethod[+n]),i?"":s+"color: initial ; font-weight: initial")}},randomFloat(){return(window.crypto||window.msCrypto)?.getRandomValues(new Uint32Array(1))[0]/4294967295||Math.random()},refactor(){chatgpt.code.refactor()},regenerate(){chatgpt.response.regenerate()},renderHTML(s){var i,e=/<([a-z\d]+)\b([^>]*)>([\s\S]*?)<\/\1>/g,c=/(\S+)=['"]?((?:.(?!['"]?\s+\S+=|[>']))+.)['"]?/g,t=s.childNodes;chatgpt.renderHTML.preWrapSet||(s.style.whiteSpace="pre-wrap",chatgpt.renderHTML.preWrapSet=!0,setTimeout(()=>{chatgpt.renderHTML.preWrapSet=!1},100));for(i of t)if(i.nodeType==Node.TEXT_NODE){var l=i.nodeValue,d=Array.from(l.matchAll(e));if(0<d.length){let e=d[0],[t,o,r,a]=e.slice(0,4),n=document.createElement(o);n.textContent=a;Array.from(r.matchAll(c)).forEach(e=>{var t=e[1],e=e[2].replace(/['"]/g,"");n.setAttribute(t,e)});var d=chatgpt.renderHTML(n),g=document.createTextNode(l.substring(0,e.index)),l=document.createTextNode(l.substring(e.index+t.length));s.replaceChild(g,i),s.insertBefore(d,g.nextSibling),s.insertBefore(l,d.nextSibling)}}else i.nodeType==Node.ELEMENT_NODE&&chatgpt.renderHTML(i);return s},async resend(){chatgpt.send(await chatgpt.getChatData("latest","msg","user","latest"))},response:{continue(){try{chatgpt.getContinueBtn().click()}catch(e){console.error(e.message)}},get(){return(window.location.href.startsWith("https://chatgpt.com/c/")?this.getFromDOM:this.getFromAPI).apply(null,arguments)},getFromAPI(e,t){return e=e||"latest",t=t||"latest",chatgpt.getChatData(e,"msg","chatgpt",t)},getFromDOM(e){var t=document.querySelectorAll("div[data-message-author-role=assistant]"),o=e.toString().toLowerCase();let r="";return t.length?r=(r=(/last|final/.test(o)?t[t.length-1]:t[(Number.isInteger(e)?e:/^\d+/.test(o)?/^\d+/.exec(o)[0]:(/^(?:1|one|fir)(?:st)?$/.test(o)?1:/^(?:2|tw(?:o|en|el(?:ve|f))|seco)(?:nd|t[yi])?(?:e?th)?$/.test(o)?2:/^(?:3|th(?:ree|ir?))(?:rd|teen|t[yi])?(?:e?th)?$/.test(o)?3:/^(?:4|fou?r)(?:teen|t[yi])?(?:e?th)?$/.test(o)?4:/^(?:5|fi(?:ve|f))(?:teen|t[yi])?(?:e?th)?$/.test(o)?5:/^(?:6|six)(?:teen|t[yi])?(?:e?th)?$/.test(o)?6:/^(?:7|seven)(?:teen|t[yi])?(?:e?th)?$/.test(o)?7:/^(?:8|eight?)(?:teen|t[yi])?(?:e?th)?$/.test(o)?8:/^(?:9|nine?)(?:teen|t[yi])?(?:e?th)?$/.test(o)?9:/^(?:10|ten)(?:th)?$/.test(o)?10:1)*(/(?:ty|ieth)$/.test(o)?10:1)+(/teen(?:th)?$/.test(o)?10:0))-1]).textContent).replace(/^ChatGPT(?:ChatGPT)?/,""):console.error("No conversation found!")},getLast(){return chatgpt.getChatData("active","msg","chatgpt","latest")},regenerate(){try{chatgpt.getRegenerateBtn().click()}catch(e){console.error(e.message)}},stopGenerating(){try{chatgpt.getStopBtn().click()}catch(e){console.error(e.message)}}},reviewCode(){chatgpt.code.review()},scrollToBottom(){try{chatgpt.getScrollBtn().click()}catch(e){console.error(e.message)}},send(e,o=""){for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string!`);let r=chatgpt.getChatBox();if(!r)return console.error("Chatbar element not found!");var t=document.createElement("p");t.textContent=e,r.replaceChild(t,r.querySelector("p")),r.dispatchEvent(new Event("input",{bubbles:!0})),setTimeout(function e(){var t=chatgpt.getSendButton();t?.hasAttribute("disabled")?setTimeout(e,222):"click"==o.toLowerCase()||chatgpt.browser.isMobile()?t.click():r.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter",bubbles:!0}))},222)},sendInNewChat(e){if("string"!=typeof e)return console.error("Message must be a string!");try{chatgpt.getNewChatBtn().click()}catch(e){return console.error(e.message)}setTimeout(()=>{chatgpt.send(e)},500)},settings:{scheme:{isDark(){return document.documentElement.classList.contains("dark")},isLight(){return document.documentElement.classList.contains("light")},set(e){var t=["dark","light","system"];if(!e)return console.error("Please specify a scheme value!");if(!t.includes(e))return console.error(`Invalid scheme value. Valid values are [${t}]`);let o=e;"system"==e&&(o=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),localStorage.setItem("theme",e),console.info(`Scheme set to ${e.toUpperCase()}.`),document.documentElement.classList.contains(o)||this.toggle()},toggle(){var[e,t]=this.isDark()?["dark","light"]:["light","dark"];document.documentElement.classList.replace(e,t),document.documentElement.style.colorScheme=t,localStorage.setItem("theme",t)}}},async sentiment(e,t){for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send("What is the sentiment of the following text"+(t?` towards the entity ${t},`:"")+" from strongly negative to strongly positive?\n\n"+e),console.info("Analyzing sentiment..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},setScheme(e){chatgpt.settings.scheme.set(e)},shareChat(s,i="clipboard"){var e=["alert","notify","notification","clipboard","copy"];if(!e.includes(i))return console.error("Invalid method '"+i+"' passed. Valid methods are ["+e+"].");return new Promise(o=>{chatgpt.getAccessToken().then(t=>{var a;a=t,new Promise((t,o)=>{let r=new XMLHttpRequest;chatgpt.getChatData(s).then(e=>{r.open("GET",chatgpt.endpoints.openAI.chat+"/"+e.id,!0),r.setRequestHeader("Content-Type","application/json"),r.setRequestHeader("Authorization","Bearer "+a),r.onload=()=>200!==r.status?o("🤖 chatgpt.js >> Request failed. Cannot retrieve chat node."):t(JSON.parse(r.responseText).current_node),r.send()})}).then(e=>{var a,n;a=t,n=e,new Promise((t,o)=>{let r=new XMLHttpRequest;chatgpt.getChatData(s).then(e=>{r.open("POST",chatgpt.endpoints.openAI.share_create,!0),r.setRequestHeader("Content-Type","application/json"),r.setRequestHeader("Authorization","Bearer "+a),r.onload=()=>200!==r.status?o("🤖 chatgpt.js >> Request failed. Cannot initialize share chat."):t(JSON.parse(r.responseText)),r.send(JSON.stringify({current_node_id:n,conversation_id:e.id,is_anonymous:!0}))})}).then(e=>{var r,a;r=t,a=e,new Promise((e,t)=>{let o=new XMLHttpRequest;o.open("PATCH",chatgpt.endpoints.openAI.share+"/"+a.share_id,!0),o.setRequestHeader("Content-Type","application/json"),o.setRequestHeader("Authorization","Bearer "+r),o.onload=()=>200!==o.status?t("🤖 chatgpt.js >> Request failed. Cannot share chat."):(console.info(`Chat shared at '${a.share_url}'`),e()),o.send(JSON.stringify({share_id:a.share_id,highlighted_message_id:a.highlighted_message_id,title:a.title,is_public:!0,is_visible:a.is_visible,is_anonymous:a.is_anonymous}))}).then(()=>{["copy","clipboard"].includes(i)?navigator.clipboard.writeText(e.share_url):chatgpt.alert("🚀 Share link created!",'"'+e.title+'" is available at: <a target="blank" rel="noopener" href="'+e.share_url+'" >'+e.share_url+"</a>",[function(){window.open(e.share_url,"_blank","noopener")},function(){navigator.clipboard.writeText(e.share_url)}]),o(e.share_url)})})})})})},showFooter(){chatgpt.footer.show()},showHeader(){chatgpt.header.show()},sidebar:{elements:[],observer:{},activateObserver(){if(this.observer instanceof MutationObserver)try{this.observer.disconnect()}catch(e){}if(!this.elements.length)return console.error("🤖 chatgpt.js >> No elements to append!");let t;for(var e of document.querySelectorAll("nav a"))if(/.*chat/.exec(e.text)[0]){t=e.classList,e.parentNode.style.margin="2px 0";break}this.elements.forEach(e=>{e.setAttribute("class",t),e.style.maxHeight=e.style.minHeight="44px",e.style.margin="2px 0"});let o=document.querySelector("nav");if(!o)return console.error("Sidebar element not found!");this.observer=new MutationObserver(e=>{e.forEach(e=>{("childList"==e.type&&e.addedNodes.length||"attributes"==e.type&&"data-chatgptjs"==e.attributeName)&&this.elements.forEach(e=>{if(!o.contains(e))try{o.insertBefore(e,o.querySelector("a").parentNode)}catch(e){console.error(e)}})})}),this.observer.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0})},append(e,t={}){var o=["button","dropdown"];if(!e||"string"!=typeof e)return console.error("🤖 chatgpt.js >> Please supply a valid string element name!");if(e=e.toLowerCase(),!o.includes(e))return console.error(`🤖 chatgpt.js >> Invalid element! Valid elements are [${o}]`);let r=document.createElement("dropdown"==e?"select":e);if(r.id=Math.floor(1e6*chatgpt.randomFloat())+Date.now(),"button"==e){r.textContent=t?.label&&"string"==typeof t.label?t.label:"chatgpt.js button";o=document.createElement("img");o.src=t?.icon&&"string"==typeof t.icon?t.icon:chatgpt.endpoints.assets+"/starters/chrome/extension/icons/icon128.png",o.width=18,r.insertBefore(o,r.firstChild),r.onclick=t?.onclick&&"function"==typeof t.onclick?t.onclick:function(){}}else if("dropdown"==e){if(t?.items&&Array.isArray(t.items)&&t.items.length||(t.items=[{text:"🤖 chatgpt.js option",value:"chatgpt.js option value"}]),!t.items.every(e=>"object"==typeof e))return console.error("'items' must be an array of objects!");t.items.forEach(e=>{var t=document.createElement("option");t.textContent=e?.text,t.value=e?.value,r.add(t)})}return"dropdown"==e&&(r.style.backgroundColor="var(--gray-900, rgb(32,33,35))"),this.elements.push(r),this.activateObserver(),document.body.setAttribute("data-chatgptjs","observer-trigger"),r.id},exists(){return!!chatgpt.getNewChatLink()},hide(){this.isOn()?this.toggle():console.info("Sidebar already hidden!")},show(){this.isOff()?this.toggle():console.info("Sidebar already shown!")},isOff(){return!this.isOn()},isOn(){var e=chatgpt.sidebar.exists()?document.querySelector("[class*=sidebar]"):null;return e?chatgpt.browser.isMobile()?"hidden"==document.documentElement.style.overflow:"hidden"!=e.style.visibility&&"0px"!=e.style.width:(console.error("Sidebar element not found!"),!1)},toggle(){var e=document.querySelector("button[data-testid*=sidebar-button]");e||console.error("Sidebar toggle not found!"),e.click()},async isLoaded(t=5e3){await chatgpt.isLoaded();var e=new Promise(e=>setTimeout(()=>e(!1),t)),o=new Promise(o=>{chatgpt.getNewChatLink()?o(!0):new MutationObserver((e,t)=>{chatgpt.getNewChatLink()&&(t.disconnect(),o(!0))}).observe(document.documentElement,{childList:!0,subtree:!0})});return Promise.race([o,e])}},startNewChat(){try{chatgpt.getNewChatBtn().click()}catch(e){console.error(e.message)}},stop(){chatgpt.response.stopGenerating()},async suggest(e,t){if(!e)return console.error("ideaType (1st argument) not supplied(e.g. 'gifts', 'names', 'recipes', etc.)");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send("Suggest some names. "+(t||"")),console.info(`Creating ${e}...`),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},speak(e,{voice:t=2,pitch:o=2,speed:r=1.1,onend:a}={}){if("string"!=typeof e)return console.error("Message must be a string!");var n,s=["voice","pitch","speed","onend"];for(n in arguments[1]){if(!s.includes(n))return console.error(`Invalid option '${n}'. Valid keys are: `+s);var i=arguments[1][n];if("onend"!=n&&"number"!=typeof i&&!/^\d+$/.test(i))return console.error(`Invalid ${n} value '${i}'. Must be a number!`);if("onend"==n&&"function"!=typeof i)return console.error(`Invalid ${n} value. Must be a function!`)}try{var c=new SpeechSynthesisUtterance,l=speechSynthesis.getVoices();Object.assign(c,{text:e,voice:l[t],pitch:o,speed:r,onend:a}),speechSynthesis.speak(c)}catch(e){console.error(e)}},async summarize(e){return e?"string"!=typeof e?console.error("Text argument must be a string!"):(chatgpt.send("Summarize the following text:\n\n"+e),console.info("Summarizing text..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")):console.error("Text (1st) argument not supplied. Pass some text!")},toggleScheme(){chatgpt.settings.scheme.toggle()},async translate(e,t){if(!e)return console.error("Text (1st) argument not supplied. Pass some text!");if(!t)return console.error("outputLang (2nd) argument not supplied. Pass a language!");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string!`);return chatgpt.send("Translate the following text to "+t+". Only reply with the translation.\n\n"+e),console.info("Translating text..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},unminify(){chatgpt.code.unminify()},uuidv4(){try{return crypto.randomUUID()}catch(e){let o=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{var t=(o+window.crypto.getRandomValues(new Uint32Array(1))[0]/(Math.pow(2,32)-1)*16)%16|0;return o=Math.floor(o/16),("x"==e?t:3&t|8).toString(16)})}},writeCode(){chatgpt.code.write()}},cjsBtnActions=(chatgpt.scheme={...chatgpt.settings.scheme},["click","get"]),cjsTargetTypes=["button","link","div","response"];for(let t of cjsBtnActions)chatgpt[t+"Button"]=function(o){var e=/^[.#]/.test(o)?document.querySelector(o):/send/i.test(o)?document.querySelector("form button[class*=bottom]"):/scroll/i.test(o)?document.querySelector("button[class*=cursor]"):(()=>{for(var e of document.querySelectorAll("button"))if(e.textContent.toLowerCase().includes(o.toLowerCase()))return e;for(var t of document.querySelectorAll("nav a"))if(t.textContent.toLowerCase().includes(o.toLowerCase()))return t})();if("click"!=t)return e;e.click()};let cjsFuncAliases=[["actAs","actas","act","become","persona","premadePrompt","preMadePrompt","prePrompt","preprompt","roleplay","rolePlay","rp"],["activateAutoRefresh","activateAutoRefresher","activateRefresher","activateSessionRefresher","autoRefresh","autoRefresher","autoRefreshSession","refresher","sessionRefresher"],["continue","continueChat","continueGenerating","continueResponse"],["deactivateAutoRefresh","deactivateAutoRefresher","deactivateRefresher","deactivateSessionRefresher"],["detectLanguage","getLanguage"],["executeCode","codeExecute"],["exists","isAvailable","isExistent","isPresent"],["exportChat","chatExport","export"],["getFooterDiv","getFooter"],["getHeaderDiv","getHeader"],["getLastPrompt","getLastQuery","getMyLastMsg","getMyLastQuery"],["getContinueButton","getContinueGeneratingButton"],["getScrollToBottomButton","getScrollButton"],["getStopButton","getStopGeneratingButton"],["getTextarea","getTextArea","getChatbar","getChatBar","getChatbox","getChatBox"],["isFullScreen","isFullscreen","isfullscreen"],["isLoaded","isloaded"],["logOut","logout","logOff","logoff","signOut","signout","signOff","signoff"],["minify","codeMinify","minifyCode"],["new","newChat","startNewChat"],["obfuscate","codeObfuscate","obfuscateCode"],["printAllFunctions","showAllFunctions"],["refactor","codeRefactor","refactorCode"],["refreshReply","regenerate","regenerateReply"],["refreshSession","sessionRefresh"],["renderHTML","renderHtml","renderLinks","renderTags"],["reviewCode","codeReview"],["send","sendChat","sendMsg"],["sendInNewChat","sendNewChat"],["sentiment","analyzeSentiment","sentimentAnalysis"],["startNewChat","new","newChat"],["stop","stopChat","stopGenerating","stopResponse"],["suggest","suggestion","recommend"],["toggleAutoRefresh","toggleAutoRefresher","toggleRefresher","toggleSessionRefresher"],["toggleScheme","toggleMode"],["translate","translation","translator"],["unminify","unminifyCode","codeUnminify"],["writeCode","codeWrite"]],cjsFuncSynonyms=[["account","acct"],["activate","turnOn"],["analyze","check","evaluate","review"],["ask","send","submit"],["button","btn"],["continue","resume"],["chats","history"],["chat","conversation","convo"],["clear","delete","remove"],["data","details"],["deactivate","deActivate","turnOff"],["execute","interpret","interpreter","run"],["firefox","ff"],["generating","generation"],["minify","uglify"],["refactor","rewrite"],["regenerate","regen"],["render","parse"],["reply","response"],["sentiment","attitude","emotion","feeling","opinion","perception"],["speak","play","say","speech","talk","tts"],["summarize","tldr"],["typing","generating"],["unminify","beautify","prettify","prettyPrint"]],camelCaser=e=>e.map((e,t)=>0===t||"s"==e?e:e.charAt(0).toUpperCase()+e.slice(1)).join("");for(let r in chatgpt){for(let o of cjsFuncAliases)if(o.includes(r))if(o.some(e=>e.includes("."))){let t=o.find(e=>e.includes(".")).split(".")[1];for(let e of o)/^(\w+)/.exec(e)[1]!==r&&(chatgpt[e]=chatgpt[r][t])}else for(let e of o)e!==r&&(chatgpt[e]=chatgpt[r]);do{var newFunctionsCreated=!1;for(let a in chatgpt)if("function"==typeof chatgpt[a]){let r=a.split(/(?=[A-Zs])/);for(let o of r){let e=[].concat(...cjsFuncSynonyms.filter(e=>e.includes(o.toLowerCase())).map(e=>e.filter(e=>e!==o.toLowerCase())));for(let t of e){let e=camelCaser(r.map(e=>e==o?t:e));chatgpt[e]||(chatgpt[e]=chatgpt[a],newFunctionsCreated=!0)}}}}while(newFunctionsCreated)}let consolePrefix="🤖 chatgpt.js >> ",ogError=console.error,ogInfo=console.info;console.error=(...e)=>{e[0].startsWith(consolePrefix)?ogError(...e):ogError(consolePrefix+e[0],...e.slice(1))},console.info=e=>{e.startsWith(consolePrefix)?ogInfo(e):ogInfo(consolePrefix+e)};try{window.chatgpt=chatgpt}catch(e){}try{module.exports=chatgpt}catch(e){}
|
|
85
|
+
cursor: pointer ; float: right ; position: relative ; right: -4px ; margin-left: -3px ;`+"display: grid }@keyframes notif-zoom-fade-out { 0% { opacity: 1 ; transform: scale(1) }15% { opacity: 0.35 ; transform: rotateX(-27deg) scale(1.05) }45% { opacity: 0.05 ; transform: rotateX(-81deg) }100% { opacity: 0 ; transform: rotateX(-180deg) scale(1.15) }}"),JSON.parse(localStorage.notifyProps));c.queue[a.quadrant].push(a.id),localStorage.notifyProps=JSON.stringify(c),a.style.top=a.isTop?23..toString()+"px":"",a.style.bottom=a.isTop?"":23..toString()+"px",a.style.right=a.isRight?27..toString()+"px":"",a.style.left=a.isRight?"":27..toString()+"px";e=c.queue[a.quadrant];if(1<e.length)try{for(var l of e.slice(0,-1)){var d=document.getElementById(l),g=d.style.top?"top":"bottom",u=+/\d+/.exec(d.style[g])[0]+5+d.getBoundingClientRect().height;d.style[g]=u+"px"}}catch(e){}setTimeout(()=>{a.style.opacity=chatgpt.isDarkMode()?.8:.67,a.style.transform="translateX(0)",a.style.transition="transform 0.15s ease, opacity 0.15s ease"},10);t=()=>{a.style.animation="notif-zoom-fade-out 0.35s ease-out",clearTimeout(h)};let h=setTimeout(t,1e3*(o<.35?0:o-.35));return n.onclick=t,a.onanimationend=()=>{a.remove(),(c=JSON.parse(localStorage.notifyProps)).queue[a.quadrant].shift(),localStorage.notifyProps=JSON.stringify(c)},a},obfuscate(){chatgpt.code.obfuscate()},printAllFunctions(){let o={cmdPrompt:["#ff00ff","#00ff00"],objName:["#0611e9","#f9ee16"],methodName:["#005aff","#ffa500"],entryType:["#467e06","#b981f9"],srcMethod:["#ff0000","#00ffff"]};Object.keys(o).forEach(e=>{o[e][1]=o[e][1]||"#"+(16777215^Number("0x1"+o[e][0].replace(/^#/,""))).toString(16).substring(1).toUpperCase()});var e=[];for(let t in this)if("function"==typeof this[t]){var r=!Object.keys(this).find(e=>Object.keys(this[e]).includes(this[t].name));e.push([r?"chatgpt":"other",t])}else if("object"==typeof this[t])for(var a in this[t])"function"==typeof this[t][a]&&e.push([t,a]);e.sort((e,t)=>e[0].localeCompare(t[0])||e[1].localeCompare(t[1]));var n=window.matchMedia("(prefers-color-scheme: dark)").matches,s="font-family: monospace ; font-size: larger ; ";console.log("\n%c🤖 chatgpt.js methods\n","font-family: sans-serif ; font-size: xxx-large ; font-weight: bold");for(let t of e){var i=/chatgpt|other/.test(t[0]),c="chatgpt"==t[0]?this[t[1]].name:"other"!==t[0]?t[0]+"."+t[1]:Object.keys(this).find(e=>Object.keys(this[e]).includes(this[t[1]].name))+"."+this[t[1]].name,l="AsyncFunction"==this[t[1]]?.constructor.name;console.log("%c>> %c"+(i?"":t[0]+".%c")+t[1]+" - https://chatgptjs.org/userguide/"+/(?:.*\.)?(.*)/.exec(c)[1].toLowerCase()+(l?"-async":"")+"\n%c[%c"+("chatgpt"==t[0]&&t[1]==this[t[1]].name||!i?"Function":"Alias of")+"%c: %c"+c+"%c]",s+"font-weight: bold ; color:"+o.cmdPrompt[+n],s+"font-weight: bold ;color:"+o[i?"methodName":"objName"][+n],s+"font-weight: "+(i?"initial":"bold")+";color:"+(i?"initial":o.methodName[+n]),s+"font-weight: "+(i?"bold":"initial")+";color:"+(i?o.entryType[+n]:"initial"),s+"font-weight: "+(i?"initial":"bold")+";color:"+(i?"initial":o.entryType[+n]),s+(i?"font-style: italic":"font-weight: initial")+";color:"+(i?o.srcMethod[+n]:"initial"),s+(i?"font-weight: initial":"font-style: italic")+";color:"+(i?"initial":o.srcMethod[+n]),i?"":s+"color: initial ; font-weight: initial")}},randomFloat(){return(window.crypto||window.msCrypto)?.getRandomValues(new Uint32Array(1))[0]/4294967295||Math.random()},refactor(){chatgpt.code.refactor()},regenerate(){chatgpt.response.regenerate()},renderHTML(s){var i,e=/<([a-z\d]+)\b([^>]*)>([\s\S]*?)<\/\1>/g,c=/(\S+)=['"]?((?:.(?!['"]?\s+\S+=|[>']))+.)['"]?/g,t=s.childNodes;chatgpt.renderHTML.preWrapSet||(s.style.whiteSpace="pre-wrap",chatgpt.renderHTML.preWrapSet=!0,setTimeout(()=>{chatgpt.renderHTML.preWrapSet=!1},100));for(i of t)if(i.nodeType==Node.TEXT_NODE){var l=i.nodeValue,d=Array.from(l.matchAll(e));if(0<d.length){let e=d[0],[t,o,r,a]=e.slice(0,4),n=document.createElement(o);n.textContent=a;Array.from(r.matchAll(c)).forEach(e=>{var t=e[1],e=e[2].replace(/['"]/g,"");n.setAttribute(t,e)});var d=chatgpt.renderHTML(n),g=document.createTextNode(l.substring(0,e.index)),l=document.createTextNode(l.substring(e.index+t.length));s.replaceChild(g,i),s.insertBefore(d,g.nextSibling),s.insertBefore(l,d.nextSibling)}}else i.nodeType==Node.ELEMENT_NODE&&chatgpt.renderHTML(i);return s},async resend(){chatgpt.send(await chatgpt.getChatData("latest","msg","user","latest"))},response:{continue(){try{chatgpt.getContinueBtn().click()}catch(e){console.error(e.message)}},get(){return(window.location.href.startsWith("https://chatgpt.com/c/")?this.getFromDOM:this.getFromAPI).apply(null,arguments)},getFromAPI(e,t){return e=e||"latest",t=t||"latest",chatgpt.getChatData(e,"msg","chatgpt",t)},getFromDOM(e){var t=document.querySelectorAll("div[data-message-author-role=assistant]"),o=e.toString().toLowerCase();let r="";return t.length?r=(r=(/last|final/.test(o)?t[t.length-1]:t[(Number.isInteger(e)?e:/^\d+/.test(o)?/^\d+/.exec(o)[0]:(/^(?:1|one|fir)(?:st)?$/.test(o)?1:/^(?:2|tw(?:o|en|el(?:ve|f))|seco)(?:nd|t[yi])?(?:e?th)?$/.test(o)?2:/^(?:3|th(?:ree|ir?))(?:rd|teen|t[yi])?(?:e?th)?$/.test(o)?3:/^(?:4|fou?r)(?:teen|t[yi])?(?:e?th)?$/.test(o)?4:/^(?:5|fi(?:ve|f))(?:teen|t[yi])?(?:e?th)?$/.test(o)?5:/^(?:6|six)(?:teen|t[yi])?(?:e?th)?$/.test(o)?6:/^(?:7|seven)(?:teen|t[yi])?(?:e?th)?$/.test(o)?7:/^(?:8|eight?)(?:teen|t[yi])?(?:e?th)?$/.test(o)?8:/^(?:9|nine?)(?:teen|t[yi])?(?:e?th)?$/.test(o)?9:/^(?:10|ten)(?:th)?$/.test(o)?10:1)*(/(?:ty|ieth)$/.test(o)?10:1)+(/teen(?:th)?$/.test(o)?10:0))-1]).textContent).replace(/^ChatGPT(?:ChatGPT)?/,""):console.error("No conversation found!")},getLast(){return chatgpt.getChatData("active","msg","chatgpt","latest")},regenerate(){try{chatgpt.getRegenerateBtn().click()}catch(e){console.error(e.message)}},stopGenerating(){try{chatgpt.getStopBtn().click()}catch(e){console.error(e.message)}}},reviewCode(){chatgpt.code.review()},scrollToBottom(){try{chatgpt.getScrollBtn().click()}catch(e){console.error(e.message)}},send(e,o=""){for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string!`);let r=chatgpt.getChatBox();if(!r)return console.error("Chatbar element not found!");var t=document.createElement("p");t.textContent=e,r.replaceChild(t,r.querySelector("p")),r.dispatchEvent(new Event("input",{bubbles:!0})),setTimeout(function e(){var t=chatgpt.getSendButton();t?.hasAttribute("disabled")?setTimeout(e,222):"click"==o.toLowerCase()||chatgpt.browser.isMobile()?t.click():r.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter",bubbles:!0}))},222)},sendInNewChat(e){if("string"!=typeof e)return console.error("Message must be a string!");try{chatgpt.getNewChatBtn().click()}catch(e){return console.error(e.message)}setTimeout(()=>{chatgpt.send(e)},500)},settings:{scheme:{isDark(){return document.documentElement.classList.contains("dark")},isLight(){return document.documentElement.classList.contains("light")},set(e){var t=["dark","light","system"];if(!e)return console.error("Please specify a scheme value!");if(!t.includes(e))return console.error(`Invalid scheme value. Valid values are [${t}]`);let o=e;"system"==e&&(o=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),localStorage.setItem("theme",e),console.info(`Scheme set to ${e.toUpperCase()}.`),document.documentElement.classList.contains(o)||this.toggle()},toggle(){var[e,t]=this.isDark()?["dark","light"]:["light","dark"];document.documentElement.classList.replace(e,t),document.documentElement.style.colorScheme=t,localStorage.setItem("theme",t)}}},async sentiment(e,t){for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send("What is the sentiment of the following text"+(t?` towards the entity ${t},`:"")+" from strongly negative to strongly positive?\n\n"+e),console.info("Analyzing sentiment..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},setScheme(e){chatgpt.settings.scheme.set(e)},shareChat(s,i="clipboard"){var e=["alert","notify","notification","clipboard","copy"];if(!e.includes(i))return console.error("Invalid method '"+i+"' passed. Valid methods are ["+e+"].");return new Promise(o=>{chatgpt.getAccessToken().then(t=>{var a;a=t,new Promise((t,o)=>{let r=new XMLHttpRequest;chatgpt.getChatData(s).then(e=>{r.open("GET",chatgpt.endpoints.openAI.chat+"/"+e.id,!0),r.setRequestHeader("Content-Type","application/json"),r.setRequestHeader("Authorization","Bearer "+a),r.onload=()=>200!==r.status?o("🤖 chatgpt.js >> Request failed. Cannot retrieve chat node."):t(JSON.parse(r.responseText).current_node),r.send()})}).then(e=>{var a,n;a=t,n=e,new Promise((t,o)=>{let r=new XMLHttpRequest;chatgpt.getChatData(s).then(e=>{r.open("POST",chatgpt.endpoints.openAI.share_create,!0),r.setRequestHeader("Content-Type","application/json"),r.setRequestHeader("Authorization","Bearer "+a),r.onload=()=>200!==r.status?o("🤖 chatgpt.js >> Request failed. Cannot initialize share chat."):t(JSON.parse(r.responseText)),r.send(JSON.stringify({current_node_id:n,conversation_id:e.id,is_anonymous:!0}))})}).then(e=>{var r,a;r=t,a=e,new Promise((e,t)=>{let o=new XMLHttpRequest;o.open("PATCH",chatgpt.endpoints.openAI.share+"/"+a.share_id,!0),o.setRequestHeader("Content-Type","application/json"),o.setRequestHeader("Authorization","Bearer "+r),o.onload=()=>200!==o.status?t("🤖 chatgpt.js >> Request failed. Cannot share chat."):(console.info(`Chat shared at '${a.share_url}'`),e()),o.send(JSON.stringify({share_id:a.share_id,highlighted_message_id:a.highlighted_message_id,title:a.title,is_public:!0,is_visible:a.is_visible,is_anonymous:a.is_anonymous}))}).then(()=>{["copy","clipboard"].includes(i)?navigator.clipboard.writeText(e.share_url):chatgpt.alert("🚀 Share link created!",'"'+e.title+'" is available at: <a target="blank" rel="noopener" href="'+e.share_url+'" >'+e.share_url+"</a>",[function(){window.open(e.share_url,"_blank","noopener")},function(){navigator.clipboard.writeText(e.share_url)}]),o(e.share_url)})})})})})},showFooter(){chatgpt.footer.show()},showHeader(){chatgpt.header.show()},sidebar:{elements:[],observer:{},activateObserver(){if(this.observer instanceof MutationObserver)try{this.observer.disconnect()}catch(e){}if(!this.elements.length)return console.error("🤖 chatgpt.js >> No elements to append!");let t;for(var e of document.querySelectorAll("nav a"))if(/.*chat/.exec(e.text)[0]){t=e.classList,e.parentNode.style.margin="2px 0";break}this.elements.forEach(e=>{e.setAttribute("class",t),e.style.maxHeight=e.style.minHeight="44px",e.style.margin="2px 0"});let o=document.querySelector("nav");if(!o)return console.error("Sidebar element not found!");this.observer=new MutationObserver(e=>{e.forEach(e=>{("childList"==e.type&&e.addedNodes.length||"attributes"==e.type&&"data-chatgptjs"==e.attributeName)&&this.elements.forEach(e=>{if(!o.contains(e))try{o.insertBefore(e,o.querySelector("a").parentNode)}catch(e){console.error(e)}})})}),this.observer.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0})},append(e,t={}){var o=["button","dropdown"];if(!e||"string"!=typeof e)return console.error("🤖 chatgpt.js >> Please supply a valid string element name!");if(e=e.toLowerCase(),!o.includes(e))return console.error(`🤖 chatgpt.js >> Invalid element! Valid elements are [${o}]`);let r=document.createElement("dropdown"==e?"select":e);if(r.id=Math.floor(1e6*chatgpt.randomFloat())+Date.now(),"button"==e){r.textContent=t?.label&&"string"==typeof t.label?t.label:"chatgpt.js button";o=document.createElement("img");o.src=t?.icon&&"string"==typeof t.icon?t.icon:chatgpt.endpoints.assets+"/starters/chrome/extension/icons/icon128.png",o.width=18,r.insertBefore(o,r.firstChild),r.onclick=t?.onclick&&"function"==typeof t.onclick?t.onclick:function(){}}else if("dropdown"==e){if(t?.items&&Array.isArray(t.items)&&t.items.length||(t.items=[{text:"🤖 chatgpt.js option",value:"chatgpt.js option value"}]),!t.items.every(e=>"object"==typeof e))return console.error("'items' must be an array of objects!");t.items.forEach(e=>{var t=document.createElement("option");t.textContent=e?.text,t.value=e?.value,r.add(t)})}return"dropdown"==e&&(r.style.backgroundColor="var(--gray-900, rgb(32,33,35))"),this.elements.push(r),this.activateObserver(),document.body.setAttribute("data-chatgptjs","observer-trigger"),r.id},exists(){return!!chatgpt.getNewChatLink()},hide(){this.isOn()?this.toggle():console.info("Sidebar already hidden!")},show(){this.isOff()?this.toggle():console.info("Sidebar already shown!")},isOff(){return!this.isOn()},isOn(){var e=chatgpt.sidebar.exists()?document.querySelector("[class*=sidebar]"):null;return e?chatgpt.browser.isMobile()?"hidden"==document.documentElement.style.overflow:"hidden"!=e.style.visibility&&"0px"!=e.style.width:(console.error("Sidebar element not found!"),!1)},toggle(){var e=document.querySelector("button[data-testid*=sidebar-button]");e||console.error("Sidebar toggle not found!"),e.click()},async isLoaded(t=5e3){await chatgpt.isLoaded();var e=new Promise(e=>setTimeout(()=>e(!1),t)),o=new Promise(o=>{chatgpt.getNewChatLink()?o(!0):new MutationObserver((e,t)=>{chatgpt.getNewChatLink()&&(t.disconnect(),o(!0))}).observe(document.documentElement,{childList:!0,subtree:!0})});return Promise.race([o,e])}},startNewChat(){try{chatgpt.getNewChatBtn().click()}catch(e){console.error(e.message)}},stop(){chatgpt.response.stopGenerating()},async suggest(e,t){if(!e)return console.error("ideaType (1st argument) not supplied(e.g. 'gifts', 'names', 'recipes', etc.)");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send("Suggest some names. "+(t||"")),console.info(`Creating ${e}...`),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},speak(e,{voice:t=2,pitch:o=2,speed:r=1.1,onend:a}={}){if("string"!=typeof e)return console.error("Message must be a string!");var n,s=["voice","pitch","speed","onend"];for(n in arguments[1]){if(!s.includes(n))return console.error(`Invalid option '${n}'. Valid keys are: `+s);var i=arguments[1][n];if("onend"!=n&&"number"!=typeof i&&!/^\d+$/.test(i))return console.error(`Invalid ${n} value '${i}'. Must be a number!`);if("onend"==n&&"function"!=typeof i)return console.error(`Invalid ${n} value. Must be a function!`)}try{var c=new SpeechSynthesisUtterance,l=speechSynthesis.getVoices();Object.assign(c,{text:e,voice:l[t],pitch:o,speed:r,onend:a}),speechSynthesis.speak(c)}catch(e){console.error(e)}},async summarize(e){return e?"string"!=typeof e?console.error("Text argument must be a string!"):(chatgpt.send("Summarize the following text:\n\n"+e),console.info("Summarizing text..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")):console.error("Text (1st) argument not supplied. Pass some text!")},toggleScheme(){chatgpt.settings.scheme.toggle()},async translate(e,t){if(!e)return console.error("Text (1st) argument not supplied. Pass some text!");if(!t)return console.error("outputLang (2nd) argument not supplied. Pass a language!");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string!`);return chatgpt.send("Translate the following text to "+t+". Only reply with the translation.\n\n"+e),console.info("Translating text..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},unminify(){chatgpt.code.unminify()},uuidv4(){try{return crypto.randomUUID()}catch(e){let o=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{var t=(o+window.crypto.getRandomValues(new Uint32Array(1))[0]/(Math.pow(2,32)-1)*16)%16|0;return o=Math.floor(o/16),("x"==e?t:3&t|8).toString(16)})}},writeCode(){chatgpt.code.write()}},cjsBtnActions=(chatgpt.scheme={...chatgpt.settings.scheme},["click","get"]),cjsTargetTypes=["button","link","div","response"];for(let t of cjsBtnActions)chatgpt[t+"Button"]=function(o){var e=/^[.#]/.test(o)?document.querySelector(o):/send/i.test(o)?document.querySelector("form button[class*=bottom]"):/scroll/i.test(o)?document.querySelector("button[class*=cursor]"):(()=>{for(var e of document.querySelectorAll("button"))if(e.textContent.toLowerCase().includes(o.toLowerCase()))return e;for(var t of document.querySelectorAll("nav a"))if(t.textContent.toLowerCase().includes(o.toLowerCase()))return t})();if("click"!=t)return e;e.click()};let cjsFuncAliases=[["actAs","actas","act","become","persona","premadePrompt","preMadePrompt","prePrompt","preprompt","roleplay","rolePlay","rp"],["activateAutoRefresh","activateAutoRefresher","activateRefresher","activateSessionRefresher","autoRefresh","autoRefresher","autoRefreshSession","refresher","sessionRefresher"],["continue","continueChat","continueGenerating","continueResponse"],["deactivateAutoRefresh","deactivateAutoRefresher","deactivateRefresher","deactivateSessionRefresher"],["detectLanguage","getLanguage"],["executeCode","codeExecute"],["exists","isAvailable","isExistent","isPresent"],["exportChat","chatExport","export"],["getFooterDiv","getFooter"],["getHeaderDiv","getHeader"],["getLastPrompt","getLastQuery","getMyLastMessage","getMyLastQuery"],["getContinueButton","getContinueGeneratingButton"],["getScrollToBottomButton","getScrollButton"],["getStopButton","getStopGeneratingButton"],["getTextarea","getTextArea","getChatbar","getChatBar","getChatbox","getChatBox"],["isFullScreen","isFullscreen","isfullscreen"],["logout","logOut","logOff","signOff","signOut"],["minify","codeMinify","minifyCode"],["new","newChat","startNewChat"],["obfuscate","codeObfuscate","obfuscateCode"],["printAllFunctions","showAllFunctions"],["refactor","codeRefactor","refactorCode"],["refreshReply","regenerate","regenerateReply"],["refreshSession","sessionRefresh"],["renderHTML","renderHtml","renderLinks","renderTags"],["reviewCode","codeReview"],["send","sendChat","sendMessage"],["sendInNewChat","sendNewChat"],["sentiment","analyzeSentiment","sentimentAnalysis"],["startNewChat","new","newChat"],["stop","stopChat","stopGenerating","stopResponse"],["suggest","suggestion","recommend"],["toggleAutoRefresh","toggleAutoRefresher","toggleRefresher","toggleSessionRefresher"],["toggleScheme","toggleMode"],["translate","translation","translator"],["unminify","unminifyCode","codeUnminify"],["writeCode","codeWrite"]],cjsFuncSynonyms=[["account","acct"],["activate","turnOn"],["analyze","check","evaluate","review"],["ask","send","submit"],["button","btn"],["continue","resume"],["chats","history"],["chat","conversation","convo"],["clear","delete","remove"],["data","details"],["deactivate","deActivate","turnOff"],["execute","interpret","interpreter","run"],["firefox","ff"],["generating","generation"],["message","msg"],["minify","uglify"],["refactor","rewrite"],["regenerate","regen"],["render","parse"],["reply","response"],["sentiment","attitude","emotion","feeling","opinion","perception"],["speak","play","say","speech","talk","tts"],["summarize","tldr"],["typing","generating"],["unminify","beautify","prettify","prettyPrint"]];function toCamelCase(e){return e.map((e,t)=>0==t?e:e.charAt(0).toUpperCase()+e.slice(1)).join("")}!function e(n=chatgpt){for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&"object"==typeof n[t]&&e(n[t]);let s;do{s=!1;for(let a in n)if(Object.prototype.hasOwnProperty.call(n,a)&&"function"==typeof n[a]){n[a.toLowerCase()]=n[a],cjsFuncAliases.forEach(e=>{e.includes(a)&&e.forEach(e=>{n[e]||(n[e]=n[e.toLowerCase()]=n[a],s=!0)})});let r=a.split(/(?=[A-Z])/);r.forEach(o=>{cjsFuncSynonyms.filter(e=>e.includes(o.toLowerCase())).flat().filter(e=>e!=o.toLowerCase()).forEach(t=>{var e=toCamelCase(r.map(e=>e==o?t:e));n[e]||(n[e]=n[e.toLowerCase()]=n[a],s=!0)})})}}while(s)}();let consolePrefix="🤖 chatgpt.js >> ",ogError=console.error,ogInfo=console.info;console.error=(...e)=>{e[0].startsWith(consolePrefix)?ogError(...e):ogError(consolePrefix+e[0],...e.slice(1))},console.info=e=>{e.startsWith(consolePrefix)?ogInfo(e):ogInfo(consolePrefix+e)};try{window.chatgpt=chatgpt}catch(e){}try{module.exports=chatgpt}catch(e){}
|
package/docs/README.md
CHANGED
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
<img src="https://img.shields.io/github/stars/KudoAI/chatgpt.js?label=Stars&color=af68ff&logo=github&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
50
50
|
<a href="https://github.com/KudoAI/chatgpt.js/blob/main/LICENSE.md">
|
|
51
51
|
<img src="https://img.shields.io/badge/License-MIT-green.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
52
|
-
<a href="https://github.com/KudoAI/chatgpt.js/tree/v3.6.
|
|
53
|
-
<img src="https://img.shields.io/github/size/KudoAI/chatgpt.js/dist/chatgpt.min.js?branch=v3.6.
|
|
52
|
+
<a href="https://github.com/KudoAI/chatgpt.js/tree/v3.6.3/dist/chatgpt.min.js">
|
|
53
|
+
<img src="https://img.shields.io/github/size/KudoAI/chatgpt.js/dist/chatgpt.min.js?branch=v3.6.3&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
|
|
54
54
|
<a href="https://www.codefactor.io/repository/github/kudoai/chatgpt.js">
|
|
55
55
|
<img src="https://img.shields.io/codefactor/grade/github/kudoai/chatgpt.js?label=Code+Quality&logo=codefactor&logoColor=white&labelColor=464646&color=1acc6c&style=for-the-badge"></a>
|
|
56
56
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=kudoai_chatgpt.js">
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
|
|
95
95
|
```js
|
|
96
96
|
(async () => {
|
|
97
|
-
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.
|
|
97
|
+
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.3/dist/chatgpt.min.js');
|
|
98
98
|
// Your code here...
|
|
99
99
|
})();
|
|
100
100
|
```
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
|
|
104
104
|
```js
|
|
105
105
|
var xhr = new XMLHttpRequest();
|
|
106
|
-
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.
|
|
106
|
+
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.3/dist/chatgpt.min.js');
|
|
107
107
|
xhr.onload = function () {
|
|
108
108
|
if (xhr.status === 200) {
|
|
109
109
|
var chatgptJS = document.createElement('script');
|
|
@@ -126,7 +126,7 @@ function yourCode() {
|
|
|
126
126
|
|
|
127
127
|
```js
|
|
128
128
|
...
|
|
129
|
-
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.
|
|
129
|
+
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.3/dist/chatgpt.min.js
|
|
130
130
|
// ==/UserScript==
|
|
131
131
|
|
|
132
132
|
// Your code here...
|
|
@@ -196,7 +196,7 @@ chatgpt.get('reply', 'last');
|
|
|
196
196
|
|
|
197
197
|
Each call equally fetches the last response. If you think it works, it probably will... so just type it!
|
|
198
198
|
|
|
199
|
-
If it didn't, check out the extended [userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.6.
|
|
199
|
+
If it didn't, check out the extended [userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.6.3/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!
|
|
200
200
|
|
|
201
201
|
<img height=8px width="100%" src="https://assets.chatgptjs.org/images/separators/gradient-aqua.png?v=e638eac">
|
|
202
202
|
|
|
@@ -434,7 +434,7 @@ This library exists thanks to code, translations, issues & ideas from the follow
|
|
|
434
434
|
<div align="center">
|
|
435
435
|
|
|
436
436
|
**[Releases](https://github.com/KudoAI/chatgpt.js/releases)** /
|
|
437
|
-
[Userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.6.
|
|
437
|
+
[Userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.6.3/docs/USERGUIDE.md) /
|
|
438
438
|
[Discuss](https://github.com/KudoAI/chatgpt.js/discussions) /
|
|
439
439
|
[Back to top ↑](#top)
|
|
440
440
|
|
package/docs/USERGUIDE.md
CHANGED
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
|
|
161
161
|
```js
|
|
162
162
|
(async () => {
|
|
163
|
-
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.
|
|
163
|
+
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.3/dist/chatgpt.min.js');
|
|
164
164
|
// Your code here...
|
|
165
165
|
})();
|
|
166
166
|
```
|
|
@@ -169,7 +169,7 @@
|
|
|
169
169
|
|
|
170
170
|
```js
|
|
171
171
|
var xhr = new XMLHttpRequest();
|
|
172
|
-
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.
|
|
172
|
+
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.3/dist/chatgpt.min.js');
|
|
173
173
|
xhr.onload = function () {
|
|
174
174
|
if (xhr.status === 200) {
|
|
175
175
|
var chatgptJS = document.createElement('script');
|
|
@@ -191,7 +191,7 @@ function yourCode() {
|
|
|
191
191
|
|
|
192
192
|
```js
|
|
193
193
|
...
|
|
194
|
-
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.
|
|
194
|
+
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.3/dist/chatgpt.min.js
|
|
195
195
|
// ==/UserScript==
|
|
196
196
|
|
|
197
197
|
// Your code here...
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kudoai/chatgpt.js",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.3",
|
|
4
4
|
"description": "Client-side JavaScript library for ChatGPT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "KudoAI & contributors",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@html-eslint/parser": "^0.34.0",
|
|
76
76
|
"@stylistic/eslint-plugin-js": "^3.1.0",
|
|
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
81
|
"eslint-plugin-yml": "^1.16.0",
|
|
@@ -133,49 +133,53 @@ const chatgpt = {
|
|
|
133
133
|
modalMessage = document.createElement('p');
|
|
134
134
|
|
|
135
135
|
// Create/append/update modal style (if missing or outdated)
|
|
136
|
-
const thisUpdated =
|
|
137
|
-
let modalStyle = document.querySelector('#chatgpt-modal-style')
|
|
136
|
+
const thisUpdated = 1739338889852 // timestamp of last edit for this file's `modalStyle`
|
|
137
|
+
let modalStyle = document.querySelector('#chatgpt-modal-style') // try to select existing style
|
|
138
138
|
if (!modalStyle || parseInt(modalStyle.getAttribute('last-updated'), 10) < thisUpdated) { // if missing or outdated
|
|
139
139
|
if (!modalStyle) { // outright missing, create/id/attr/append it first
|
|
140
|
-
modalStyle = document.createElement('style'); modalStyle.id = 'chatgpt-modal-style'
|
|
141
|
-
modalStyle.setAttribute('last-updated', thisUpdated.toString())
|
|
142
|
-
document.head.append(modalStyle)
|
|
140
|
+
modalStyle = document.createElement('style') ; modalStyle.id = 'chatgpt-modal-style'
|
|
141
|
+
modalStyle.setAttribute('last-updated', thisUpdated.toString())
|
|
142
|
+
document.head.append(modalStyle)
|
|
143
143
|
}
|
|
144
144
|
modalStyle.innerText = ( // update prev/new style contents
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
`.chatgpt-modal { /* vars */
|
|
146
|
+
--transition: opacity 0.65s cubic-bezier(.165,.84,.44,1), /* for fade-in */
|
|
147
|
+
transform 0.55s cubic-bezier(.165,.84,.44,1) ; /* for move-in */
|
|
148
|
+
--bg-transition: background-color 0.25s ease ; /* for bg dim */
|
|
149
|
+
--btn-transition: transform 0.1s ease-in-out, box-shadow 0.1s ease-in-out ; /* for smooth zoom */
|
|
150
|
+
--btn-shadow: 2px 1px ${ scheme == 'dark' ? '54px #00cfff' : '30px #9cdaff' }}`
|
|
149
151
|
|
|
150
152
|
+ '.no-mobile-tap-outline { outline: none ; -webkit-tap-highlight-color: transparent }'
|
|
151
153
|
|
|
152
154
|
// Background styles
|
|
153
|
-
+
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
+ `.chatgpt-modal {
|
|
156
|
+
pointer-events: auto ; /* override any disabling from site modals (like guest login spam) */
|
|
157
|
+
position: fixed ; top: 0 ; left: 0 ; width: 100% ; height: 100% ; /* expand to full view-port */
|
|
158
|
+
display: flex ; justify-content: center ; align-items: center ; z-index: 9999 ; /* align */
|
|
159
|
+
transition: var(--bg-transition) ; /* for bg dim */
|
|
160
|
+
-webkit-transition: var(--bg-transition) ; -moz-transition: var(--bg-transition) ;
|
|
161
|
+
-o-transition: var(--bg-transition) ; -ms-transition: var(--bg-transition) }`
|
|
160
162
|
|
|
161
163
|
// Alert styles
|
|
162
|
-
+
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
164
|
+
+ `.chatgpt-modal > div {
|
|
165
|
+
position: absolute ; /* to be click-draggable */
|
|
166
|
+
opacity: 0 ; /* to fade-in */
|
|
167
|
+
font-family: -apple-system, system-ui, BlinkMacSystemFont, Segoe UI, Roboto,
|
|
168
|
+
Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif ;
|
|
169
|
+
padding: 20px ; margin: 12px 23px ; font-size: 20px ;
|
|
170
|
+
color: ${ scheme == 'dark' ? 'white' : 'black' };
|
|
171
|
+
background-color: ${ scheme == 'dark' ? 'black' : 'white' };
|
|
172
|
+
border: 1px solid ${ scheme == 'dark' ? 'white' : '#b5b5b5' };
|
|
173
|
+
transform: translateX(-3px) translateY(7px) ; /* offset to move-in from */
|
|
174
|
+
max-width: 75vw ; word-wrap: break-word ; border-radius: 15px ;
|
|
175
|
+
--shadow: 0 30px 60px rgba(0,0,0,0.12) ; box-shadow: var(--shadow) ;
|
|
176
|
+
-webkit-box-shadow: var(--shadow) ; -moz-box-shadow: var(--shadow) ;
|
|
177
|
+
user-select: none ; -webkit-user-select: none ; -moz-user-select: none ;
|
|
178
|
+
-o-user-select: none ; -ms-user-select: none ;
|
|
179
|
+
transition: var(--transition) ; /* for fade-in + move-in */
|
|
180
|
+
-webkit-transition: var(--transition) ; -moz-transition: var(--transition) ;
|
|
181
|
+
-o-transition: var(--transition) ; -ms-transition: var(--transition) }
|
|
182
|
+
.chatgpt-modal h2 { font-weight: bold ; font-size: 24px ; margin-bottom: 9px }
|
|
179
183
|
.chatgpt-modal a { color: ${ scheme == 'dark' ? '#00cfff' : '#1e9ebb' }}
|
|
180
184
|
.chatgpt-modal a:hover { text-decoration: underline }
|
|
181
185
|
.chatgpt-modal.animated > div {
|
|
@@ -185,39 +189,44 @@ const chatgpt = {
|
|
|
185
189
|
100% { opacity: 0 ; transform: scale(1.35) }}`
|
|
186
190
|
|
|
187
191
|
// Button styles
|
|
188
|
-
+
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
box-shadow: var(--
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
192
|
+
+ `.modal-buttons {
|
|
193
|
+
display: flex ; justify-content: flex-end ; margin: 20px -5px -3px 0 ;
|
|
194
|
+
${ isMobile ? 'flex-direction: column-reverse' : '' }}
|
|
195
|
+
.chatgpt-modal button {
|
|
196
|
+
font-size: 14px ; text-transform: uppercase ;
|
|
197
|
+
margin-left: ${ isMobile ? 0 : 10 }px ; padding: ${ isMobile ? 15 : 8 }px 18px ;
|
|
198
|
+
${ isMobile ? 'margin-top: 5px ; margin-bottom: 3px ;' : '' }
|
|
199
|
+
border-radius: 0 ; border: 1px solid ${ scheme == 'dark' ? 'white' : 'black' };
|
|
200
|
+
transition: var(--btn-transition) ;
|
|
201
|
+
-webkit-transition: var(--btn-transition) ; -moz-transition: var(--btn-transition) ;
|
|
202
|
+
-o-transition: var(--btn-transition) ; -ms-transition: var(--btn-transition) }
|
|
203
|
+
.chatgpt-modal button:hover {
|
|
204
|
+
transform: scale(1.055) ; color: black ;
|
|
205
|
+
background-color: #${ scheme == 'dark' ? '00cfff' : '9cdaff' };
|
|
206
|
+
box-shadow: var(--btn-shadow) ;
|
|
207
|
+
-webkit-box-shadow: var(--btn-shadow) ; -moz-box-shadow: var(--btn-shadow) }
|
|
208
|
+
.primary-modal-btn {
|
|
209
|
+
border: 1px solid ${ scheme == 'dark' ? 'white' : 'black' };
|
|
210
|
+
background: ${ scheme == 'dark' ? 'white' : 'black' };
|
|
211
|
+
color: ${ scheme == 'dark' ? 'black' : 'white' }}
|
|
212
|
+
.modal-close-btn {
|
|
213
|
+
cursor: pointer ; width: 29px ; height: 29px ; border-radius: 17px ;
|
|
214
|
+
float: right ; position: relative ; right: -6px ; top: -5px }
|
|
215
|
+
.modal-close-btn svg { margin: 10px } /* center SVG for hover underlay */
|
|
216
|
+
.modal-close-btn:hover { background-color: #f2f2f2${ scheme == 'dark' ? '00' : '' }}`
|
|
208
217
|
|
|
209
218
|
// Checkbox styles
|
|
210
|
-
+ `.chatgpt-modal .checkbox-group { margin
|
|
211
|
-
.chatgpt-modal
|
|
212
|
-
|
|
213
|
-
color: ${ scheme == 'dark' ? '#e1e1e1' : '#1e1e1e' }}
|
|
214
|
-
.chatgpt-modal input[type=checkbox] { transform: scale(0.7) ;
|
|
219
|
+
+ `.chatgpt-modal .checkbox-group { margin: 5px 0 -8px 5px }
|
|
220
|
+
.chatgpt-modal input[type=checkbox] {
|
|
221
|
+
cursor: pointer ; transform: scale(0.7) ; margin-right: 5px ;
|
|
215
222
|
border: 1px solid ${ scheme == 'dark' ? 'white' : 'black' }}
|
|
216
223
|
.chatgpt-modal input[type=checkbox]:checked {
|
|
217
|
-
|
|
218
|
-
|
|
224
|
+
background-color: black ; position: inherit ;
|
|
225
|
+
border: 1px solid ${ scheme == 'dark' ? 'white' : 'black' }}
|
|
219
226
|
.chatgpt-modal input[type=checkbox]:focus {
|
|
220
|
-
outline: none ; box-shadow: none ; -webkit-box-shadow: none ; -moz-box-shadow: none }
|
|
227
|
+
outline: none ; box-shadow: none ; -webkit-box-shadow: none ; -moz-box-shadow: none }
|
|
228
|
+
.chatgpt-modal .checkbox-group label {
|
|
229
|
+
font-size: 14px ; color: ${ scheme == 'dark' ? '#e1e1e1' : '#1e1e1e' }}`
|
|
221
230
|
)
|
|
222
231
|
}
|
|
223
232
|
|
|
@@ -1988,7 +1997,7 @@ for (const btnAction of cjsBtnActions) {
|
|
|
1988
1997
|
};
|
|
1989
1998
|
}
|
|
1990
1999
|
|
|
1991
|
-
// Create
|
|
2000
|
+
// Create ALIAS functions
|
|
1992
2001
|
const cjsFuncAliases = [
|
|
1993
2002
|
['actAs', 'actas', 'act', 'become', 'persona', 'premadePrompt', 'preMadePrompt', 'prePrompt', 'preprompt', 'roleplay', 'rolePlay', 'rp'],
|
|
1994
2003
|
['activateAutoRefresh', 'activateAutoRefresher', 'activateRefresher', 'activateSessionRefresher',
|
|
@@ -2001,14 +2010,13 @@ const cjsFuncAliases = [
|
|
|
2001
2010
|
['exportChat', 'chatExport', 'export'],
|
|
2002
2011
|
['getFooterDiv', 'getFooter'],
|
|
2003
2012
|
['getHeaderDiv', 'getHeader'],
|
|
2004
|
-
['getLastPrompt', 'getLastQuery', '
|
|
2013
|
+
['getLastPrompt', 'getLastQuery', 'getMyLastMessage', 'getMyLastQuery'],
|
|
2005
2014
|
['getContinueButton', 'getContinueGeneratingButton'],
|
|
2006
2015
|
['getScrollToBottomButton', 'getScrollButton'],
|
|
2007
2016
|
['getStopButton', 'getStopGeneratingButton'],
|
|
2008
2017
|
['getTextarea', 'getTextArea', 'getChatbar', 'getChatBar', 'getChatbox', 'getChatBox'],
|
|
2009
2018
|
['isFullScreen', 'isFullscreen', 'isfullscreen'],
|
|
2010
|
-
['
|
|
2011
|
-
['logOut', 'logout', 'logOff', 'logoff', 'signOut', 'signout', 'signOff', 'signoff'],
|
|
2019
|
+
['logout', 'logOut', 'logOff', 'signOff', 'signOut'],
|
|
2012
2020
|
['minify', 'codeMinify', 'minifyCode'],
|
|
2013
2021
|
['new', 'newChat', 'startNewChat'],
|
|
2014
2022
|
['obfuscate', 'codeObfuscate', 'obfuscateCode'],
|
|
@@ -2018,7 +2026,7 @@ const cjsFuncAliases = [
|
|
|
2018
2026
|
['refreshSession', 'sessionRefresh'],
|
|
2019
2027
|
['renderHTML', 'renderHtml', 'renderLinks', 'renderTags'],
|
|
2020
2028
|
['reviewCode', 'codeReview'],
|
|
2021
|
-
['send', 'sendChat', '
|
|
2029
|
+
['send', 'sendChat', 'sendMessage'],
|
|
2022
2030
|
['sendInNewChat', 'sendNewChat'],
|
|
2023
2031
|
['sentiment', 'analyzeSentiment', 'sentimentAnalysis'],
|
|
2024
2032
|
['startNewChat', 'new', 'newChat'],
|
|
@@ -2029,7 +2037,7 @@ const cjsFuncAliases = [
|
|
|
2029
2037
|
['translate', 'translation', 'translator'],
|
|
2030
2038
|
['unminify', 'unminifyCode', 'codeUnminify'],
|
|
2031
2039
|
['writeCode', 'codeWrite']
|
|
2032
|
-
]
|
|
2040
|
+
]
|
|
2033
2041
|
const cjsFuncSynonyms = [
|
|
2034
2042
|
['account', 'acct'],
|
|
2035
2043
|
['activate', 'turnOn'],
|
|
@@ -2045,6 +2053,7 @@ const cjsFuncSynonyms = [
|
|
|
2045
2053
|
['execute', 'interpret', 'interpreter', 'run'],
|
|
2046
2054
|
['firefox', 'ff'],
|
|
2047
2055
|
['generating', 'generation'],
|
|
2056
|
+
['message', 'msg'],
|
|
2048
2057
|
['minify', 'uglify'],
|
|
2049
2058
|
['refactor', 'rewrite'],
|
|
2050
2059
|
['regenerate', 'regen'],
|
|
@@ -2056,41 +2065,44 @@ const cjsFuncSynonyms = [
|
|
|
2056
2065
|
['typing', 'generating'],
|
|
2057
2066
|
['unminify', 'beautify', 'prettify', 'prettyPrint']
|
|
2058
2067
|
];
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
var newFunctionsCreated = false;
|
|
2080
|
-
for (const funcName in chatgpt) {
|
|
2081
|
-
if (typeof chatgpt[funcName] == 'function') {
|
|
2082
|
-
const funcWords = funcName.split(/(?=[A-Zs])/); // split function name into constituent words
|
|
2083
|
-
for (const funcWord of funcWords) {
|
|
2084
|
-
const synonymValues = [].concat(...cjsFuncSynonyms // flatten into single array w/ word's cjsFuncSynonyms
|
|
2068
|
+
(function createCJSaliasFuncs(obj = chatgpt) {
|
|
2069
|
+
for (const prop in obj) {
|
|
2070
|
+
if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue // skip inherited props
|
|
2071
|
+
if (typeof obj[prop] == 'object') createCJSaliasFuncs(obj[prop]) // recurse thru objs to find deeper functions
|
|
2072
|
+
}
|
|
2073
|
+
let aliasFuncCreated
|
|
2074
|
+
do {
|
|
2075
|
+
aliasFuncCreated = false
|
|
2076
|
+
for (const prop in obj) {
|
|
2077
|
+
if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue // skip inherited props
|
|
2078
|
+
if (typeof obj[prop] == 'function') {
|
|
2079
|
+
obj[prop.toLowerCase()] = obj[prop] // create lowercase variant
|
|
2080
|
+
cjsFuncAliases.forEach(aliasArr => { // create alias function per alias to use
|
|
2081
|
+
if (!aliasArr.includes(prop)) return
|
|
2082
|
+
aliasArr.forEach(alias => { if (!obj[alias]) {
|
|
2083
|
+
obj[alias] = obj[alias.toLowerCase()] = obj[prop] ; aliasFuncCreated = true }})
|
|
2084
|
+
})
|
|
2085
|
+
const funcWords = prop.split(/(?=[A-Z])/) // split function name into constituent words
|
|
2086
|
+
funcWords.forEach(funcWord => { // create alias function per function word per synonym
|
|
2087
|
+
const synonymsToUse = cjsFuncSynonyms
|
|
2085
2088
|
.filter(arr => arr.includes(funcWord.toLowerCase())) // filter in relevant synonym sub-arrays
|
|
2086
|
-
.
|
|
2087
|
-
|
|
2088
|
-
const newFuncName =
|
|
2089
|
-
if (!
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
}
|
|
2089
|
+
.flat().filter(synonym => synonym != funcWord.toLowerCase()) // filter out matching word
|
|
2090
|
+
synonymsToUse.forEach(synonym => { // create alias function per synonym to use
|
|
2091
|
+
const newFuncName = toCamelCase(funcWords.map(word => word == funcWord ? synonym : word))
|
|
2092
|
+
if (!obj[newFuncName]) {
|
|
2093
|
+
obj[newFuncName] = obj[newFuncName.toLowerCase()] = obj[prop] ; aliasFuncCreated = true }
|
|
2094
|
+
})
|
|
2095
|
+
})
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
} while (aliasFuncCreated) // loop over new functions to encompass all variations
|
|
2099
|
+
})()
|
|
2100
|
+
|
|
2101
|
+
|
|
2102
|
+
// Define HELPER functions
|
|
2103
|
+
|
|
2104
|
+
function toCamelCase(words) {
|
|
2105
|
+
return words.map((word, idx) => idx == 0 ? word : word.charAt(0).toUpperCase() + word.slice(1)).join('') }
|
|
2094
2106
|
|
|
2095
2107
|
// Prefix console logs w/ '🤖 chatgpt.js >> '
|
|
2096
2108
|
const consolePrefix = '🤖 chatgpt.js >> ', ogError = console.error, ogInfo = console.info;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "ChatGPT Extension",
|
|
4
4
|
"short_name": "ChatGPT 🧩",
|
|
5
5
|
"description": "A Chromium extension template to start using chatgpt.js like a boss!",
|
|
6
|
-
"version": "2025.2.
|
|
6
|
+
"version": "2025.2.12",
|
|
7
7
|
"author": "KudoAI",
|
|
8
8
|
"homepage_url": "https://github.com/KudoAI/chatgpt.js-chrome-starter",
|
|
9
9
|
"icons": {
|
|
@@ -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 2025.2.
|
|
6
|
+
// @version 2025.2.12
|
|
7
7
|
// @license MIT
|
|
8
8
|
// @icon https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@1fc50da/starters/greasemonkey/assets/images/icons/robot/icon48.png
|
|
9
9
|
// @icon64 https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@1fc50da/starters/greasemonkey/assets/images/icons/robot/icon64.png
|
|
10
10
|
// @match *://chatgpt.com/*
|
|
11
|
-
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.
|
|
11
|
+
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.6.3/dist/chatgpt.min.js
|
|
12
12
|
// @grant GM_getValue
|
|
13
13
|
// @grant GM_setValue
|
|
14
14
|
// @noframes
|