@kudoai/chatgpt.js 2.7.0 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -38
- package/chatgpt.js +44 -48
- package/dist/chatgpt.min.js +3 -3
- package/docs/README.md +38 -38
- package/docs/USERGUIDE.md +3 -3
- package/package.json +3 -3
- package/starters/chrome/extension/lib/chatgpt.js +44 -48
- package/starters/chrome/extension/manifest.json +2 -2
- package/starters/greasemonkey/chatgpt.js-greasemonkey-starter.user.js +2 -2
package/README.md
CHANGED
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
[](https://github.com/KudoAI/chatgpt.js/stargazers)
|
|
46
46
|
[](https://github.com/KudoAI/chatgpt.js/blob/main/LICENSE.md)
|
|
47
47
|
[](https://github.com/KudoAI/chatgpt.js/commits/main)
|
|
48
|
-
[](https://github.com/KudoAI/chatgpt.js/tree/v2.8.0/dist/chatgpt.min.js)
|
|
49
49
|
[](https://www.codefactor.io/repository/github/kudoai/chatgpt.js)
|
|
50
50
|
[](https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=kudoai_chatgpt.js)
|
|
51
51
|
[](https://github.com/sindresorhus/awesome-chatgpt#javascript)
|
|
52
52
|
[](https://www.producthunt.com/posts/chatgpt-js)
|
|
53
|
-

|
|
54
54
|
|
|
55
55
|
</div>
|
|
56
56
|
|
|
57
|
-
<img height=8px width="100%" src="https://
|
|
57
|
+
<img height=8px width="100%" src="https://media.chatgptjs.org/images/separators/gradient-aqua.png?78210a7">
|
|
58
58
|
|
|
59
59
|
<div id="intro">
|
|
60
60
|
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
- Easy-to-use
|
|
70
70
|
- Lightweight (yet optimally performant)
|
|
71
71
|
|
|
72
|
-
<img height=8px width="100%" src="https://
|
|
72
|
+
<img height=8px width="100%" src="https://media.chatgptjs.org/images/separators/gradient-aqua.png?78210a7">
|
|
73
73
|
|
|
74
74
|
<div id="importing">
|
|
75
75
|
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
|
|
84
84
|
```js
|
|
85
85
|
(async () => {
|
|
86
|
-
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.
|
|
86
|
+
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.8.0/dist/chatgpt.min.js');
|
|
87
87
|
// Your code here...
|
|
88
88
|
})();
|
|
89
89
|
```
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
|
|
93
93
|
```js
|
|
94
94
|
var xhr = new XMLHttpRequest();
|
|
95
|
-
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.
|
|
95
|
+
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.8.0/dist/chatgpt.min.js');
|
|
96
96
|
xhr.onload = function () {
|
|
97
97
|
if (xhr.status === 200) {
|
|
98
98
|
var chatgptJS = document.createElement('script');
|
|
@@ -114,7 +114,7 @@ function yourCode() {
|
|
|
114
114
|
|
|
115
115
|
```js
|
|
116
116
|
...
|
|
117
|
-
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.
|
|
117
|
+
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.8.0/dist/chatgpt.min.js
|
|
118
118
|
// ==/UserScript==
|
|
119
119
|
|
|
120
120
|
// Your code here...
|
|
@@ -150,7 +150,7 @@ export { chatgpt }
|
|
|
150
150
|
})();
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
-
<img height=8px width="100%" src="https://
|
|
153
|
+
<img height=8px width="100%" src="https://media.chatgptjs.org/images/separators/gradient-aqua.png?78210a7">
|
|
154
154
|
|
|
155
155
|
<div id="npm">
|
|
156
156
|
|
|
@@ -168,7 +168,7 @@ After installation, navigate to `node_modules/@kudoai/chatgpt.js` to find the li
|
|
|
168
168
|
|
|
169
169
|
</div>
|
|
170
170
|
|
|
171
|
-
<img height=8px width="100%" src="https://
|
|
171
|
+
<img height=8px width="100%" src="https://media.chatgptjs.org/images/separators/gradient-aqua.png?78210a7">
|
|
172
172
|
|
|
173
173
|
<div id="usage">
|
|
174
174
|
|
|
@@ -189,9 +189,9 @@ chatgpt.get('reply', 'last');
|
|
|
189
189
|
|
|
190
190
|
Each call equally fetches the last response. If you think it works, it probably will... so just type it!
|
|
191
191
|
|
|
192
|
-
If it didn't, check out the extended [userguide](https://github.com/KudoAI/chatgpt.js/blob/v2.
|
|
192
|
+
If it didn't, check out the extended [userguide](https://github.com/KudoAI/chatgpt.js/blob/v2.8.0/docs/USERGUIDE.md), or simply submit an [issue](https://github.com/KudoAI/chatgpt.js/issues) or [PR](https://github.com/KudoAI/chatgpt.js/pulls) and it will be integrated, ezpz!
|
|
193
193
|
|
|
194
|
-
<img height=8px width="100%" src="https://
|
|
194
|
+
<img height=8px width="100%" src="https://media.chatgptjs.org/images/separators/gradient-aqua.png?78210a7">
|
|
195
195
|
|
|
196
196
|
<div id="showcase">
|
|
197
197
|
|
|
@@ -203,47 +203,47 @@ https://github.com/KudoAI/chatgpt.js/assets/10906554/f53c740f-d5e0-49b6-ae02-3b3
|
|
|
203
203
|
|
|
204
204
|
#
|
|
205
205
|
|
|
206
|
-
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://i.imgur.com/RduASbD.png"><img width=16 src="https://raw.githubusercontent.com/adamlui/chatgpt-addons/main/media/icons/openai-favicon64.png"></picture> [Autoclear ChatGPT History](https://autoclearchatgpt.com)
|
|
206
|
+
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://i.imgur.com/RduASbD.png"><img width=16 src="https://raw.githubusercontent.com/adamlui/chatgpt-addons/main/media/icons/openai-favicon64.png"></picture> [Autoclear ChatGPT History](https://autoclearchatgpt.com) <a href="https://github.com/awesome-scripts/awesome-userscripts#chatgpt" target="_blank" rel="noopener"><img src="https://awesome.re/mentioned-badge.svg" style="margin:0 0 -2px 5px"></a>
|
|
207
207
|
|
|
208
208
|
> Auto-clear your ChatGPT query history for maximum privacy.
|
|
209
|
-
<br>[Install](https://
|
|
210
|
-
[Readme](https://
|
|
211
|
-
[Discuss](https://autoclearchatgpt.com/
|
|
209
|
+
<br>[Install](https://docs.autoclearchatgpt.com/#-installation) /
|
|
210
|
+
[Readme](https://docs.autoclearchatgpt.com/#readme) /
|
|
211
|
+
[Discuss](https://github.autoclearchatgpt.com/discussions)
|
|
212
212
|
|
|
213
|
-
### <img src="https://media.bravegpt.com/images/icons/bravegpt/icon48.png" width=18> [BraveGPT](https://bravegpt.com)
|
|
213
|
+
### <img src="https://media.bravegpt.com/images/icons/bravegpt/icon48.png" width=18> [BraveGPT](https://bravegpt.com) <a href="https://www.producthunt.com/posts/bravegpt?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-bravegpt" target="_blank" rel="noopener"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=385630&theme=light" style="width: 112px; height: 24px; margin:0 0 -4px 5px;" width="112" height="24" /></a>
|
|
214
214
|
|
|
215
215
|
> Display ChatGPT answers in Brave Search sidebar (powered by GPT-4!)
|
|
216
|
-
<br>[Install](https://
|
|
217
|
-
[Readme](https://
|
|
216
|
+
<br>[Install](https://docs.bravegpt.com/#-installation) /
|
|
217
|
+
[Readme](https://docs.bravegpt.com/#readme) /
|
|
218
218
|
[Discuss](https://github.bravegpt.com/discussions)
|
|
219
219
|
|
|
220
|
-
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://i.imgur.com/RduASbD.png"><img width=16 src="https://raw.githubusercontent.com/adamlui/chatgpt-userscripts/main/media/icons/openai-favicon64.png"></picture> [ChatGPT Auto-Continue ⏩](https://chatgptautocontinue.com)
|
|
220
|
+
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://i.imgur.com/RduASbD.png"><img width=16 src="https://raw.githubusercontent.com/adamlui/chatgpt-userscripts/main/media/icons/openai-favicon64.png"></picture> [ChatGPT Auto-Continue ⏩](https://chatgptautocontinue.com) <a href="https://github.com/awesome-scripts/awesome-userscripts#chatgpt" target="_blank" rel="noopener"><img src="https://awesome.re/mentioned-badge.svg" style="margin:0 0 -3px 3px"></a>
|
|
221
221
|
|
|
222
222
|
> Automatically continue generating multiple ChatGPT responses.
|
|
223
|
-
<br>[Install](https://
|
|
224
|
-
[Readme](https://
|
|
225
|
-
[Discuss](https://chatgptautocontinue.com/
|
|
223
|
+
<br>[Install](https://docs.chatgptautocontinue.com/#-installation) /
|
|
224
|
+
[Readme](https://docs.chatgptautocontinue.com/#readme) /
|
|
225
|
+
[Discuss](https://github.chatgptautocontinue.com/discussions)
|
|
226
226
|
|
|
227
|
-
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://i.imgur.com/RduASbD.png"><img width=16 src="https://raw.githubusercontent.com/adamlui/chatgpt-addons/main/media/icons/openai-favicon64.png"></picture> [ChatGPT Auto Refresh ↻](https://chatgptautorefresh.com)
|
|
227
|
+
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://i.imgur.com/RduASbD.png"><img width=16 src="https://raw.githubusercontent.com/adamlui/chatgpt-addons/main/media/icons/openai-favicon64.png"></picture> [ChatGPT Auto Refresh ↻](https://chatgptautorefresh.com) <a href="https://github.com/awesome-scripts/awesome-userscripts#chatgpt" target="_blank" rel="noopener"><img src="https://awesome.re/mentioned-badge.svg" style="margin:0 0 -2px 5px"></a>
|
|
228
228
|
|
|
229
229
|
> Keeps ChatGPT sessions fresh to eliminate network errors + Cloudflare checks.
|
|
230
|
-
<br>[Install](https://
|
|
231
|
-
[Readme](https://
|
|
232
|
-
[Discuss](https://chatgptautorefresh.com/
|
|
230
|
+
<br>[Install](https://docs.chatgptautorefresh.com/#-installation) /
|
|
231
|
+
[Readme](https://docs.chatgptautorefresh.com/#readme) /
|
|
232
|
+
[Discuss](https://github.chatgptautorefresh.com/discussions)
|
|
233
233
|
|
|
234
|
-
### <img src="https://media.ddgpt.com/images/icons/duckduckgpt/icon48.png" width=17> [DuckDuckGPT](https://duckduckgpt.com)
|
|
234
|
+
### <img src="https://media.ddgpt.com/images/icons/duckduckgpt/icon48.png" width=17> [DuckDuckGPT](https://duckduckgpt.com) <a href="https://www.producthunt.com/posts/duckduckgpt?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-duckduckgpt" target="_blank" rel="noopener"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=379261&theme=light" style="width: 112px; height: 24px; margin:0 0 -4px 5px;" width="112" height="24" /></a>
|
|
235
235
|
|
|
236
236
|
> Display ChatGPT answers in DuckDuckGo sidebar (powered by GPT-4!)
|
|
237
|
-
<br>[Install](https://
|
|
238
|
-
[Readme](https://
|
|
239
|
-
[Discuss](https://github.
|
|
237
|
+
<br>[Install](https://docs.ddgpt.com/#-installation) /
|
|
238
|
+
[Readme](https://docs.ddgpt.com/#readme) /
|
|
239
|
+
[Discuss](https://github.ddgpt.com/discussions)
|
|
240
240
|
|
|
241
|
-
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://media.googlegpt.io/images/icons/googlegpt/white/icon32.png"><img width=17 src="https://media.googlegpt.io/images/icons/googlegpt/black/icon32.png"></picture> [GoogleGPT](https://googlegpt.
|
|
241
|
+
### <picture><source media="(prefers-color-scheme: dark)" srcset="https://media.googlegpt.io/images/icons/googlegpt/white/icon32.png"><img width=17 src="https://media.googlegpt.io/images/icons/googlegpt/black/icon32.png"></picture> [GoogleGPT](https://googlegpt.io) <a href="https://github.com/awesome-scripts/awesome-userscripts#chatgpt" target="_blank" rel="noopener"><img src="https://media.googlegpt.io/images/badges/awesome/badge.svg" style="margin:0 0 -2px 5px"></a>
|
|
242
242
|
|
|
243
243
|
> Display ChatGPT answers in Google Search sidebar (powered by GPT-4!)
|
|
244
244
|
<br>[Install](https://greasyfork.org/scripts/478597-googlegpt) /
|
|
245
|
-
[Readme](https://
|
|
246
|
-
[Discuss](https://github.
|
|
245
|
+
[Readme](https://docs.googlegpt.io/#readme) /
|
|
246
|
+
[Discuss](https://github.googlegpt.io/discussions)
|
|
247
247
|
|
|
248
248
|
<p><br>
|
|
249
249
|
|
|
@@ -263,7 +263,7 @@ https://github.com/KudoAI/chatgpt.js/assets/10906554/f53c740f-d5e0-49b6-ae02-3b3
|
|
|
263
263
|
If you've made something w/ chatgpt.js you want to share, email <a href="mailto:showcase@chatgptjs.org">showcase@chatgptjs.org</a> or just open a <a href="https://github.com/KudoAI/chatgpt.js/pulls" target="_blank" rel="noopener">pull request</a>!
|
|
264
264
|
</p>
|
|
265
265
|
|
|
266
|
-
<img height=8px width="100%" src="https://
|
|
266
|
+
<img height=8px width="100%" src="https://media.chatgptjs.org/images/separators/gradient-aqua.png?78210a7">
|
|
267
267
|
|
|
268
268
|
<div id="contributors">
|
|
269
269
|
|
|
@@ -303,12 +303,12 @@ This library exists thanks to code, translations, issues & ideas from the follow
|
|
|
303
303
|
[](https://github.com/micz)
|
|
304
304
|
[](https://github.com/dependabot)
|
|
305
305
|
<a href="https://chatgpt.com"><picture><source media="(prefers-color-scheme: dark)" srcset="https://images.weserv.nl/?url=https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@main/media/images/icons/platforms/chatgpt/black-on-white/icon189.png?h=50&w=50&mask=circle&maxage=7d"><img src="https://images.weserv.nl/?url=https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@main/media/images/icons/platforms/chatgpt/white-on-black/icon189.png?h=50&w=50&mask=circle&maxage=7d" title="ChatGPT"></picture></a>
|
|
306
|
-
<a href="https://
|
|
306
|
+
<a href="https://poe.com"><picture><source media="(prefers-color-scheme: dark)" srcset="https://images.weserv.nl/?url=https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@main/media/images/icons/platforms/poe/w-purple-blue-stripes/black-on-white/icon175.png?h=50&w=50&mask=circle&maxage=7d"><img src="https://images.weserv.nl/?url=https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@main/media/images/icons/platforms/poe/w-purple-blue-stripes/white-on-black/icon175.png?h=50&w=50&mask=circle&maxage=7d" title="Poe"></picture></a>
|
|
307
307
|
[](https://github.com/ImgBotApp)
|
|
308
308
|
|
|
309
309
|
</div><br>
|
|
310
310
|
|
|
311
|
-
<img height=8px width="100%" src="https://
|
|
311
|
+
<img height=8px width="100%" src="https://media.chatgptjs.org/images/separators/gradient-aqua.png?78210a7">
|
|
312
312
|
|
|
313
313
|
<div id="partners">
|
|
314
314
|
|
|
@@ -329,12 +329,12 @@ This library exists thanks to code, translations, issues & ideas from the follow
|
|
|
329
329
|
|
|
330
330
|
<br>
|
|
331
331
|
|
|
332
|
-
<img height=8px width="100%" src="https://
|
|
332
|
+
<img height=8px width="100%" src="https://media.chatgptjs.org/images/separators/gradient-aqua.png?78210a7">
|
|
333
333
|
|
|
334
334
|
<div align="center">
|
|
335
335
|
|
|
336
336
|
**[Releases](https://github.com/KudoAI/chatgpt.js/releases)** /
|
|
337
|
-
[Userguide](https://github.com/KudoAI/chatgpt.js/blob/v2.
|
|
337
|
+
[Userguide](https://github.com/KudoAI/chatgpt.js/blob/v2.8.0/docs/USERGUIDE.md) /
|
|
338
338
|
[Discuss](https://github.com/KudoAI/chatgpt.js/discussions) /
|
|
339
339
|
<a href="#--------------------------------------------------------------------------------english---------简体中文---------繁體中文---------日本---------한국인---------हिंदी---------नेपाली---------deutsch---------español---------français---------italiano---------nederlands---------português---------việt----">Back to top ↑</a>
|
|
340
340
|
|
package/chatgpt.js
CHANGED
|
@@ -389,7 +389,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
389
389
|
try { await chatgpt.getChatData(); } catch { return; } // check if chat history exists
|
|
390
390
|
chatgpt.menu.open(); setTimeout(() => { // open settings
|
|
391
391
|
const settingsBtn = document.querySelector(
|
|
392
|
-
'a[role="menuitem"] svg path[d*="
|
|
392
|
+
'a[role="menuitem"] svg path[d*="M12.003 10.5a1.5"]')?.parentNode.parentNode;
|
|
393
393
|
if (settingsBtn) settingsBtn.click();
|
|
394
394
|
setTimeout(() => { // clear chats
|
|
395
395
|
const settingsBtns = document.querySelectorAll('[id*=radix] button'),
|
|
@@ -842,12 +842,10 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
842
842
|
});});};
|
|
843
843
|
|
|
844
844
|
// Return chat data
|
|
845
|
-
return new Promise(resolve =>
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
else getChatMsgs(token).then(messages => { return resolve(messages); }); // otherwise get specific msg's
|
|
850
|
-
});});
|
|
845
|
+
return new Promise(resolve => chatgpt.getAccessToken().then(token => {
|
|
846
|
+
return resolve(detailsToGet.includes('msg') ? getChatMsgs(token)
|
|
847
|
+
: getChatDetails(token, detailsToGet));
|
|
848
|
+
}));
|
|
851
849
|
},
|
|
852
850
|
|
|
853
851
|
getChatInput: function() { return chatgpt.getChatBox().value; },
|
|
@@ -863,11 +861,13 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
863
861
|
getLastPrompt: function() { return chatgpt.getChatData('active', 'msg', 'user', 'latest'); },
|
|
864
862
|
getLastResponse: function() { return chatgpt.getChatData('active', 'msg', 'chatgpt', 'latest'); },
|
|
865
863
|
|
|
866
|
-
|
|
867
|
-
for (const
|
|
868
|
-
if (
|
|
869
|
-
return
|
|
870
|
-
}
|
|
864
|
+
getNewChatButton: function() {
|
|
865
|
+
for (const navBtnSVG of document.querySelectorAll('nav button svg'))
|
|
866
|
+
if (navBtnSVG.querySelector('path[d*="M15.673 3.913a3.121"]')) // new chat icon found
|
|
867
|
+
return navBtnSVG.parentNode;
|
|
868
|
+
},
|
|
869
|
+
|
|
870
|
+
getNewChatLink: function() { return document.querySelector('nav a[href="/"]'); },
|
|
871
871
|
|
|
872
872
|
getRegenerateButton: function() {
|
|
873
873
|
for (const mainSVG of document.querySelectorAll('main svg')) {
|
|
@@ -881,15 +881,17 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
881
881
|
// responseToGet = index of response to get (defaults to latest if '' unpassed)
|
|
882
882
|
// regenResponseToGet = index of regenerated response to get (defaults to latest if '' unpassed)
|
|
883
883
|
|
|
884
|
-
|
|
885
|
-
return chatgpt.getResponseFromDOM.apply(null, arguments);
|
|
886
|
-
else return chatgpt.getResponseFromAPI.apply(null, arguments);
|
|
884
|
+
return chatgpt.response.get(...arguments);
|
|
887
885
|
},
|
|
888
886
|
|
|
889
887
|
getResponseFromAPI: function(chatToGet, responseToGet) { return chatgpt.response.getFromAPI(chatToGet, responseToGet); },
|
|
890
888
|
getResponseFromDOM: function(pos) { return chatgpt.response.getFromDOM(pos); },
|
|
891
889
|
getScrollToBottomButton: function() { return document.querySelector('button[class*="cursor"][class*="bottom"]'); },
|
|
892
|
-
|
|
890
|
+
|
|
891
|
+
getSendButton: function() {
|
|
892
|
+
return document.querySelector('[data-testid="send-button"]') // pre-GPT-4o
|
|
893
|
+
|| document.querySelector('path[d*="M15.192 8.906a1.143"]')?.parentNode.parentNode; // post-GPT-4o
|
|
894
|
+
},
|
|
893
895
|
|
|
894
896
|
getStopGeneratingButton: function() {
|
|
895
897
|
for (const svg of document.querySelectorAll('form button svg')) {
|
|
@@ -907,11 +909,10 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
907
909
|
history: {
|
|
908
910
|
isLoaded: function() {
|
|
909
911
|
return new Promise(resolve => {
|
|
910
|
-
|
|
912
|
+
(function checkChatHistory() {
|
|
911
913
|
if (document.querySelector('nav')) resolve(true);
|
|
912
914
|
else setTimeout(checkChatHistory, 100);
|
|
913
|
-
};
|
|
914
|
-
checkChatHistory();
|
|
915
|
+
})();
|
|
915
916
|
});}
|
|
916
917
|
},
|
|
917
918
|
|
|
@@ -1054,10 +1055,11 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
1054
1055
|
|
|
1055
1056
|
isLoaded: function() {
|
|
1056
1057
|
return new Promise(resolve => {
|
|
1057
|
-
|
|
1058
|
-
if (
|
|
1059
|
-
|
|
1060
|
-
|
|
1058
|
+
(function checkIsLoaded() {
|
|
1059
|
+
if (chatgpt.getNewChatButton()) resolve(true);
|
|
1060
|
+
else setTimeout(checkIsLoaded, 100);
|
|
1061
|
+
})();
|
|
1062
|
+
});},
|
|
1061
1063
|
|
|
1062
1064
|
isLightMode: function() { return document.documentElement.classList.toString().includes('light'); },
|
|
1063
1065
|
isMobileDevice: function() { return chatgpt.browser.isMobile(); },
|
|
@@ -1154,16 +1156,14 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
1154
1156
|
|
|
1155
1157
|
close: function() {
|
|
1156
1158
|
const menuBtn = document.querySelector('nav [id*="menu-button"][aria-expanded="true"]');
|
|
1157
|
-
if (menuBtn)
|
|
1158
|
-
|
|
1159
|
-
else { console.error('Menu already hidden!'); throw new Error(); }
|
|
1159
|
+
if (menuBtn) try { menuBtn.click(); } catch (err) { return console.error(err.message); }
|
|
1160
|
+
else { console.info('Menu already hidden!'); }
|
|
1160
1161
|
},
|
|
1161
1162
|
|
|
1162
1163
|
open: function() {
|
|
1163
1164
|
const menuBtn = document.querySelector('nav [id*="menu-button"][aria-expanded="false"]');
|
|
1164
|
-
if (menuBtn)
|
|
1165
|
-
|
|
1166
|
-
else { console.error('Menu already hidden!'); throw new Error(); }
|
|
1165
|
+
if (menuBtn) try { menuBtn.click(); } catch (err) { return console.error(err.message); }
|
|
1166
|
+
else { console.info('Menu already open!'); }
|
|
1167
1167
|
}
|
|
1168
1168
|
},
|
|
1169
1169
|
|
|
@@ -1350,7 +1350,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
1350
1350
|
randomFloat: function() {
|
|
1351
1351
|
// * Generates a random, cryptographically secure value between 0 (inclusive) & 1 (exclusive)
|
|
1352
1352
|
const crypto = window.crypto || window.msCrypto;
|
|
1353
|
-
return crypto
|
|
1353
|
+
return crypto?.getRandomValues(new Uint32Array(1))[0] / 0xFFFFFFFF || Math.random();
|
|
1354
1354
|
},
|
|
1355
1355
|
|
|
1356
1356
|
refactor: function() { chatgpt.code.refactor(); },
|
|
@@ -1416,7 +1416,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
1416
1416
|
// responseToGet = index of response to get (defaults to latest if '' unpassed)
|
|
1417
1417
|
// regenResponseToGet = index of regenerated response to get (defaults to latest if '' unpassed)
|
|
1418
1418
|
|
|
1419
|
-
if (window.location.href.startsWith('https://
|
|
1419
|
+
if (window.location.href.startsWith('https://chatgpt.com/c/'))
|
|
1420
1420
|
return this.getFromDOM.apply(null, arguments);
|
|
1421
1421
|
else return this.getFromAPI.apply(null, arguments);
|
|
1422
1422
|
},
|
|
@@ -1461,7 +1461,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
1461
1461
|
);
|
|
1462
1462
|
response = responseDivs[nthOfResponse - 1].textContent;
|
|
1463
1463
|
}
|
|
1464
|
-
response = response.replace(/^
|
|
1464
|
+
response = response.replace(/^ChatGPT(?:ChatGPT)?/, ''); // strip sender name
|
|
1465
1465
|
}
|
|
1466
1466
|
return response;
|
|
1467
1467
|
},
|
|
@@ -1641,10 +1641,6 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
1641
1641
|
elements: [], observer: {},
|
|
1642
1642
|
|
|
1643
1643
|
activateObserver: function() {
|
|
1644
|
-
const chatHistoryNav = document.querySelector('nav'),
|
|
1645
|
-
firstButton = chatHistoryNav.querySelector('a');
|
|
1646
|
-
if (chatgpt.history.isOff()) // Hide enable history spam div
|
|
1647
|
-
try { firstButton.parentNode.nextElementSibling.style.display = 'none'; } catch (err) {}
|
|
1648
1644
|
|
|
1649
1645
|
// Stop the previous observer to preserve resources
|
|
1650
1646
|
if (this.observer instanceof MutationObserver)
|
|
@@ -1755,28 +1751,26 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
1755
1751
|
show: function() { this.isOff() ? this.toggle() : console.info('Sidebar already shown!'); },
|
|
1756
1752
|
isOff: function() { return !this.isOn(); },
|
|
1757
1753
|
isOn: function() {
|
|
1754
|
+
const sidebar = document.querySelector('#__next > div > div');
|
|
1758
1755
|
return chatgpt.browser.isMobile() ?
|
|
1759
1756
|
document.documentElement.style.overflow == 'hidden'
|
|
1760
|
-
:
|
|
1757
|
+
: sidebar.style.visibility != 'hidden' && sidebar.style.width != '0px';
|
|
1761
1758
|
},
|
|
1762
1759
|
|
|
1763
1760
|
toggle: function() {
|
|
1764
1761
|
const isMobileDevice = chatgpt.browser.isMobile(),
|
|
1765
|
-
|
|
1762
|
+
isGPT4oUI = !!document.documentElement.className.includes(' '),
|
|
1763
|
+
navBtnSelector = isMobileDevice ? '#__next button' : isGPT4oUI ? 'nav button' : 'main button',
|
|
1766
1764
|
isToggleBtn = isMobileDevice ? () => true // since 1st one is toggle
|
|
1767
|
-
: btn =>
|
|
1768
|
-
|
|
1765
|
+
: isGPT4oUI ? btn => btn.querySelectorAll('svg path[d*="M8.857 3h6.286c1.084"]').length > 0
|
|
1766
|
+
: /* post-GPT-4o desktop */ btn => [...btn.querySelectorAll('*')]
|
|
1767
|
+
.some(child => child.style.transform.includes('translateY'));
|
|
1769
1768
|
for (const btn of document.querySelectorAll(navBtnSelector))
|
|
1770
1769
|
if (isToggleBtn(btn)) { btn.click(); return; }
|
|
1771
1770
|
}
|
|
1772
1771
|
},
|
|
1773
1772
|
|
|
1774
|
-
startNewChat: function() {
|
|
1775
|
-
for (const navLink of document.querySelectorAll('nav a')) {
|
|
1776
|
-
if (/(new|clear) chat/i.test(navLink.text)) {
|
|
1777
|
-
navLink.click(); return;
|
|
1778
|
-
}}},
|
|
1779
|
-
|
|
1773
|
+
startNewChat: function() { try { this.getNewChatButton().click(); } catch (err) { console.error(err.message); }},
|
|
1780
1774
|
stop: function() { this.response.stopGenerating(); },
|
|
1781
1775
|
|
|
1782
1776
|
suggest: async function(ideaType, details) {
|
|
@@ -1877,7 +1871,7 @@ for (const buttonAction of buttonActions) {
|
|
|
1877
1871
|
}
|
|
1878
1872
|
|
|
1879
1873
|
// Create alias functions
|
|
1880
|
-
const
|
|
1874
|
+
const funcAliases = [
|
|
1881
1875
|
['actAs', 'actas', 'act', 'become', 'persona', 'premadePrompt', 'preMadePrompt', 'prePrompt', 'preprompt', 'roleplay', 'rolePlay', 'rp'],
|
|
1882
1876
|
['activateAutoRefresh', 'activateAutoRefresher', 'activateRefresher', 'activateSessionRefresher',
|
|
1883
1877
|
'autoRefresh', 'autoRefresher', 'autoRefreshSession', 'refresher', 'sessionRefresher'],
|
|
@@ -1888,6 +1882,7 @@ const functionAliases = [
|
|
|
1888
1882
|
['getFooterDiv', 'getFooter'],
|
|
1889
1883
|
['getHeaderDiv', 'getHeader'],
|
|
1890
1884
|
['getLastPrompt', 'getLastQuery', 'getMyLastMsg', 'getMyLastQuery'],
|
|
1885
|
+
['getScrollToBottomButton', 'getScrollButton'],
|
|
1891
1886
|
['getTextarea', 'getTextArea', 'getChatbox', 'getChatBox'],
|
|
1892
1887
|
['isFullScreen', 'isFullscreen'],
|
|
1893
1888
|
['logOut', 'logout', 'logOff', 'logoff', 'signOut', 'signout', 'signOff', 'signoff'],
|
|
@@ -1903,6 +1898,7 @@ const functionAliases = [
|
|
|
1903
1898
|
['send', 'sendChat', 'sendMsg'],
|
|
1904
1899
|
['sendInNewChat', 'sendNewChat'],
|
|
1905
1900
|
['sentiment', 'analyzeSentiment', 'sentimentAnalysis'],
|
|
1901
|
+
['startNewChat', 'new', 'newChat'],
|
|
1906
1902
|
['stop', 'stopGenerating'],
|
|
1907
1903
|
['suggest', 'suggestion', 'recommend'],
|
|
1908
1904
|
['toggleAutoRefresh', 'toggleAutoRefresher', 'toggleRefresher', 'toggleSessionRefresher'],
|
|
@@ -1937,7 +1933,7 @@ const camelCaser = (words) => {
|
|
|
1937
1933
|
for (const prop in chatgpt) {
|
|
1938
1934
|
|
|
1939
1935
|
// Create new function for each alias
|
|
1940
|
-
for (const subAliases of
|
|
1936
|
+
for (const subAliases of funcAliases) {
|
|
1941
1937
|
if (subAliases.includes(prop)) {
|
|
1942
1938
|
if (subAliases.some(element => element.includes('.'))) {
|
|
1943
1939
|
const nestedFunction = subAliases.find(element => element.includes('.')).split('.')[1];
|