@kudoai/chatgpt.js 2.8.0 → 2.9.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 +8 -7
- package/chatgpt.js +65 -59
- package/dist/chatgpt.min.js +3 -3
- package/docs/README.md +8 -7
- package/docs/USERGUIDE.md +43 -4
- package/package.json +1 -1
- package/starters/chrome/extension/lib/chatgpt.js +65 -59
- package/starters/chrome/extension/manifest.json +1 -1
- package/starters/greasemonkey/chatgpt.js-greasemonkey-starter.user.js +4 -3
package/README.md
CHANGED
|
@@ -45,12 +45,12 @@
|
|
|
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.9.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
|
|
|
@@ -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.9.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.9.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.9.0/dist/chatgpt.min.js
|
|
118
118
|
// ==/UserScript==
|
|
119
119
|
|
|
120
120
|
// Your code here...
|
|
@@ -189,7 +189,7 @@ 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.9.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
194
|
<img height=8px width="100%" src="https://media.chatgptjs.org/images/separators/gradient-aqua.png?78210a7">
|
|
195
195
|
|
|
@@ -301,6 +301,7 @@ This library exists thanks to code, translations, issues & ideas from the follow
|
|
|
301
301
|
[](https://github.com/thedayofcondor)
|
|
302
302
|
[](https://github.com/Luwa-Tech)
|
|
303
303
|
[](https://github.com/micz)
|
|
304
|
+
[](https://github.com/imranaalam)
|
|
304
305
|
[](https://github.com/dependabot)
|
|
305
306
|
<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
307
|
<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>
|
|
@@ -334,7 +335,7 @@ This library exists thanks to code, translations, issues & ideas from the follow
|
|
|
334
335
|
<div align="center">
|
|
335
336
|
|
|
336
337
|
**[Releases](https://github.com/KudoAI/chatgpt.js/releases)** /
|
|
337
|
-
[Userguide](https://github.com/KudoAI/chatgpt.js/blob/v2.
|
|
338
|
+
[Userguide](https://github.com/KudoAI/chatgpt.js/blob/v2.9.0/docs/USERGUIDE.md) /
|
|
338
339
|
[Discuss](https://github.com/KudoAI/chatgpt.js/discussions) /
|
|
339
340
|
<a href="#--------------------------------------------------------------------------------english---------简体中文---------繁體中文---------日本---------한국인---------हिंदी---------नेपाली---------deutsch---------español---------français---------italiano---------nederlands---------português---------việt----">Back to top ↑</a>
|
|
340
341
|
|
package/chatgpt.js
CHANGED
|
@@ -8,11 +8,11 @@ const endpoints = {
|
|
|
8
8
|
assets: 'https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js',
|
|
9
9
|
openAI: {
|
|
10
10
|
session: 'https://chatgpt.com/api/auth/session',
|
|
11
|
-
chats: 'https://
|
|
12
|
-
chat: 'https://
|
|
13
|
-
share_create: 'https://
|
|
14
|
-
share: 'https://
|
|
15
|
-
instructions: 'https://
|
|
11
|
+
chats: 'https://chatgpt.com/backend-api/conversations',
|
|
12
|
+
chat: 'https://chatgpt.com/backend-api/conversation',
|
|
13
|
+
share_create: 'https://chatgpt.com/backend-api/share/create',
|
|
14
|
+
share: 'https://chatgpt.com/backend-api/share',
|
|
15
|
+
instructions: 'https://chatgpt.com/backend-api/user_system_messages'
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
|
|
@@ -383,21 +383,25 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
383
383
|
const validMethods = ['api', 'dom'];
|
|
384
384
|
method = (method || 'dom').trim().toLowerCase(); // set to 'dom' by default
|
|
385
385
|
if (method && !validMethods.includes(method))
|
|
386
|
-
return console.
|
|
386
|
+
return console.error(`Method argument must be one of: [${validMethods}]`);
|
|
387
387
|
|
|
388
388
|
if (method == 'dom') {
|
|
389
|
-
|
|
390
|
-
|
|
389
|
+
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
390
|
+
try {
|
|
391
|
+
chatgpt.menu.open(); await delay(10);
|
|
391
392
|
const settingsBtn = document.querySelector(
|
|
392
|
-
'a[role="menuitem"] svg path[d*="M12.003 10.5a1.5"]')
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
393
|
+
'a[role="menuitem"] svg path[d*="M12.003 10.5a1.5"]').parentNode.parentNode;
|
|
394
|
+
settingsBtn.click(); await delay(333);
|
|
395
|
+
const settingsBtns = document.querySelectorAll('[id*=radix] button'),
|
|
396
|
+
deleteBtn = settingsBtns[settingsBtns.length - 1];
|
|
397
|
+
deleteBtn.click(); await delay(10);
|
|
398
|
+
document.querySelector('button[class*="danger"').click(); // confirm clear
|
|
399
|
+
return console.info('Chats successfully cleared.');
|
|
400
|
+
} catch (err) {
|
|
401
|
+
console.error(err.message);
|
|
402
|
+
if (arguments.length == 0) {
|
|
403
|
+
console.info('Using backend API method instead.'); this.clearChats('api'); }
|
|
404
|
+
}
|
|
401
405
|
|
|
402
406
|
} else { // API method
|
|
403
407
|
// NOTE: DOM is not updated to reflect new empty chat list (until session refresh)
|
|
@@ -413,7 +417,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
413
417
|
console.info('Chats successfully cleared'); resolve();
|
|
414
418
|
};
|
|
415
419
|
xhr.send(JSON.stringify({ is_visible: false }));
|
|
416
|
-
}).catch(reject);
|
|
420
|
+
}).catch(err => reject(new Error(err.message)));
|
|
417
421
|
});
|
|
418
422
|
}
|
|
419
423
|
},
|
|
@@ -493,6 +497,8 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
493
497
|
}
|
|
494
498
|
},
|
|
495
499
|
|
|
500
|
+
continue: function() { this.response.continue(); },
|
|
501
|
+
|
|
496
502
|
detectLanguage: async function(text) {
|
|
497
503
|
if (!text) return console.error('Text argument not supplied. Pass some text!');
|
|
498
504
|
if (typeof text !== 'string') return console.error('Text argument must be a string!');
|
|
@@ -851,9 +857,9 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
851
857
|
getChatInput: function() { return chatgpt.getChatBox().value; },
|
|
852
858
|
|
|
853
859
|
getContinueGeneratingButton: function() {
|
|
854
|
-
for (const
|
|
855
|
-
if (
|
|
856
|
-
return
|
|
860
|
+
for (const formBtnSVG of document.querySelectorAll('form button svg')) {
|
|
861
|
+
if (formBtnSVG.querySelector('path[d*="M4.472 2.5a1"]'))
|
|
862
|
+
return formBtnSVG.parentNode.parentNode;
|
|
857
863
|
}},
|
|
858
864
|
|
|
859
865
|
getFooterDiv: function() { return document.querySelector('main form').parentNode.parentNode.nextElementSibling; },
|
|
@@ -895,7 +901,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
895
901
|
|
|
896
902
|
getStopGeneratingButton: function() {
|
|
897
903
|
for (const svg of document.querySelectorAll('form button svg')) {
|
|
898
|
-
if (svg.querySelector('path[d*="2 0 0 1 2"]'))
|
|
904
|
+
if (svg.querySelector('path[d*="2 0 0 1 2"], rect'))
|
|
899
905
|
return svg.parentNode;
|
|
900
906
|
}},
|
|
901
907
|
|
|
@@ -1048,10 +1054,11 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
1048
1054
|
|
|
1049
1055
|
isIdle: function() {
|
|
1050
1056
|
return new Promise(resolve => {
|
|
1051
|
-
|
|
1052
|
-
if (chatgpt.getRegenerateButton())
|
|
1053
|
-
|
|
1054
|
-
|
|
1057
|
+
(function checkIsIdle() {
|
|
1058
|
+
if (chatgpt.getRegenerateButton()) resolve(true);
|
|
1059
|
+
else setTimeout(checkIsIdle, 100);
|
|
1060
|
+
})();
|
|
1061
|
+
});},
|
|
1055
1062
|
|
|
1056
1063
|
isLoaded: function() {
|
|
1057
1064
|
return new Promise(resolve => {
|
|
@@ -1155,15 +1162,13 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
1155
1162
|
},
|
|
1156
1163
|
|
|
1157
1164
|
close: function() {
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
else { console.info('Menu already hidden!'); }
|
|
1165
|
+
try { document.querySelector('nav [id*="menu-button"][aria-expanded="true"]').click(); }
|
|
1166
|
+
catch (err) { console.error(err.message); }
|
|
1161
1167
|
},
|
|
1162
1168
|
|
|
1163
1169
|
open: function() {
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
else { console.info('Menu already open!'); }
|
|
1170
|
+
try { document.querySelector('nav [id*="menu-button"][aria-expanded="false"]').click(); }
|
|
1171
|
+
catch (err) { console.error(err.message); }
|
|
1167
1172
|
}
|
|
1168
1173
|
},
|
|
1169
1174
|
|
|
@@ -1410,6 +1415,8 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
1410
1415
|
resend: async function() { chatgpt.send(await chatgpt.getChatData('latest', 'msg', 'user', 'latest')); },
|
|
1411
1416
|
|
|
1412
1417
|
response: {
|
|
1418
|
+
continue: function() { try { chatgpt.getContinueBtn().click(); } catch (err) { console.error(err.message); }},
|
|
1419
|
+
|
|
1413
1420
|
get: function() {
|
|
1414
1421
|
// * Returns response via DOM by index arg if OpenAI chat page is active, otherwise uses API w/ following args:
|
|
1415
1422
|
// chatToGet = index|title|id of chat to get (defaults to latest if '' unpassed)
|
|
@@ -1467,41 +1474,26 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
1467
1474
|
},
|
|
1468
1475
|
|
|
1469
1476
|
getLast: function() { return chatgpt.getChatData('active', 'msg', 'chatgpt', 'latest'); },
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
const regenBtn = chatgpt.getRegenerateButton();
|
|
1473
|
-
if (regenBtn) regenBtn.click();
|
|
1474
|
-
else console.error('Regenerate button not found!');
|
|
1475
|
-
},
|
|
1476
|
-
|
|
1477
|
-
stopGenerating: function() {
|
|
1478
|
-
for (const svg of document.querySelectorAll('form button svg')) {
|
|
1479
|
-
if (svg.querySelector('path[d*="2 0 0 1 2"]')) {
|
|
1480
|
-
svg.parentNode.click(); return;
|
|
1481
|
-
}}}
|
|
1477
|
+
regenerate: function() { try { chatgpt.getRegenerateBtn().click(); } catch (err) { console.error(err.message); }},
|
|
1478
|
+
stopGenerating: function() { try { chatgpt.getStopBtn().click(); } catch (err) { console.error(err.message); }}
|
|
1482
1479
|
},
|
|
1483
1480
|
|
|
1484
1481
|
reviewCode: function() { chatgpt.code.review(); },
|
|
1485
|
-
|
|
1486
|
-
scrollToBottom: function() {
|
|
1487
|
-
const scrollBtn = chatgpt.getScrollToBottomButton();
|
|
1488
|
-
if (scrollBtn) scrollBtn.click();
|
|
1489
|
-
else console.error('Scroll button not found!');
|
|
1490
|
-
},
|
|
1482
|
+
scrollToBottom: function() { try { chatgpt.getScrollBtn().click(); } catch (err) { console.error(err.message); }},
|
|
1491
1483
|
|
|
1492
1484
|
send: function(msg, method='') {
|
|
1493
1485
|
for (let i = 0; i < arguments.length; i++) if (typeof arguments[i] !== 'string')
|
|
1494
1486
|
return console.error(`Argument ${ i + 1 } must be a string!`);
|
|
1495
1487
|
const textArea = document.querySelector('form textarea'),
|
|
1496
|
-
|
|
1488
|
+
sendBtn = this.getSendButton();
|
|
1497
1489
|
textArea.value = msg;
|
|
1498
1490
|
textArea.dispatchEvent(new Event('input', { bubbles: true })); // enable send button
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1491
|
+
|
|
1492
|
+
setTimeout(function delaySend() {
|
|
1493
|
+
if (!sendBtn?.hasAttribute('disabled')) { // send msg
|
|
1494
|
+
method.toLowerCase() == 'click' || chatgpt.browser.isMobile() ? sendBtn.click()
|
|
1502
1495
|
: textArea.dispatchEvent(new KeyboardEvent('keydown', { keyCode: 13, bubbles: true }));
|
|
1503
|
-
|
|
1504
|
-
}
|
|
1496
|
+
} else setTimeout(delaySend, 25);
|
|
1505
1497
|
}, 25);
|
|
1506
1498
|
},
|
|
1507
1499
|
|
|
@@ -1767,10 +1759,18 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
1767
1759
|
.some(child => child.style.transform.includes('translateY'));
|
|
1768
1760
|
for (const btn of document.querySelectorAll(navBtnSelector))
|
|
1769
1761
|
if (isToggleBtn(btn)) { btn.click(); return; }
|
|
1770
|
-
}
|
|
1762
|
+
},
|
|
1763
|
+
|
|
1764
|
+
isloaded: function() {
|
|
1765
|
+
return new Promise(resolve => {
|
|
1766
|
+
(function checkIsLoaded() {
|
|
1767
|
+
if (document.querySelector('nav a[href="/"]')) resolve(true);
|
|
1768
|
+
else setTimeout(checkIsLoaded, 100);
|
|
1769
|
+
})();
|
|
1770
|
+
});}
|
|
1771
1771
|
},
|
|
1772
1772
|
|
|
1773
|
-
startNewChat: function() { try { this.
|
|
1773
|
+
startNewChat: function() { try { this.getNewChatBtn().click(); } catch (err) { console.error(err.message); }},
|
|
1774
1774
|
stop: function() { this.response.stopGenerating(); },
|
|
1775
1775
|
|
|
1776
1776
|
suggest: async function(ideaType, details) {
|
|
@@ -1875,6 +1875,7 @@ const funcAliases = [
|
|
|
1875
1875
|
['actAs', 'actas', 'act', 'become', 'persona', 'premadePrompt', 'preMadePrompt', 'prePrompt', 'preprompt', 'roleplay', 'rolePlay', 'rp'],
|
|
1876
1876
|
['activateAutoRefresh', 'activateAutoRefresher', 'activateRefresher', 'activateSessionRefresher',
|
|
1877
1877
|
'autoRefresh', 'autoRefresher', 'autoRefreshSession', 'refresher', 'sessionRefresher'],
|
|
1878
|
+
['continue', 'continueChat', 'continueGenerating', 'continueResponse'],
|
|
1878
1879
|
['deactivateAutoRefresh', 'deactivateAutoRefresher', 'deactivateRefresher', 'deactivateSessionRefresher'],
|
|
1879
1880
|
['detectLanguage', 'getLanguage'],
|
|
1880
1881
|
['executeCode', 'codeExecute'],
|
|
@@ -1882,7 +1883,9 @@ const funcAliases = [
|
|
|
1882
1883
|
['getFooterDiv', 'getFooter'],
|
|
1883
1884
|
['getHeaderDiv', 'getHeader'],
|
|
1884
1885
|
['getLastPrompt', 'getLastQuery', 'getMyLastMsg', 'getMyLastQuery'],
|
|
1886
|
+
['getContinueGeneratingButton', 'getContinueButton'],
|
|
1885
1887
|
['getScrollToBottomButton', 'getScrollButton'],
|
|
1888
|
+
['getStopGeneratingButton', 'getStopButton'],
|
|
1886
1889
|
['getTextarea', 'getTextArea', 'getChatbox', 'getChatBox'],
|
|
1887
1890
|
['isFullScreen', 'isFullscreen'],
|
|
1888
1891
|
['logOut', 'logout', 'logOff', 'logoff', 'signOut', 'signout', 'signOff', 'signoff'],
|
|
@@ -1899,7 +1902,7 @@ const funcAliases = [
|
|
|
1899
1902
|
['sendInNewChat', 'sendNewChat'],
|
|
1900
1903
|
['sentiment', 'analyzeSentiment', 'sentimentAnalysis'],
|
|
1901
1904
|
['startNewChat', 'new', 'newChat'],
|
|
1902
|
-
['stop', 'stopGenerating'],
|
|
1905
|
+
['stop', 'stopChat', 'stopGenerating', 'stopResponse'],
|
|
1903
1906
|
['suggest', 'suggestion', 'recommend'],
|
|
1904
1907
|
['toggleAutoRefresh', 'toggleAutoRefresher', 'toggleRefresher', 'toggleSessionRefresher'],
|
|
1905
1908
|
['toggleScheme', 'toggleMode'],
|
|
@@ -1913,7 +1916,10 @@ const synonyms = [
|
|
|
1913
1916
|
['analyze', 'check', 'evaluate', 'review'],
|
|
1914
1917
|
['ask', 'send', 'submit'],
|
|
1915
1918
|
['button', 'btn'],
|
|
1919
|
+
['continue', 'resume'],
|
|
1920
|
+
['chats', 'history'],
|
|
1916
1921
|
['chat', 'conversation', 'convo'],
|
|
1922
|
+
['clear', 'delete', 'remove'],
|
|
1917
1923
|
['data', 'details'],
|
|
1918
1924
|
['deactivate', 'deActivate', 'turnOff'],
|
|
1919
1925
|
['execute', 'interpret', 'interpreter', 'run'],
|
package/dist/chatgpt.min.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
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
|
-
const endpoints={assets:"https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@d5720270587aa3238cf3e92fb6c1ec0e86346d73",openAI:{session:"https://chatgpt.com/api/auth/session",chats:"https://chat.openai.com/backend-api/conversations",chat:"https://chat.openai.com/backend-api/conversation",share_create:"https://chat.openai.com/backend-api/share/create",share:"https://chat.openai.com/backend-api/share",instructions:"https://chat.openai.com/backend-api/user_system_messages"}},chatgpt=(localStorage.alertQueue=JSON.stringify([]),localStorage.notifyProps=JSON.stringify({queue:{topRight:[],bottomRight:[],bottomLeft:[],topLeft:[]}}),{openAIaccessToken:{},actAs:function(s){return new Promise((o,r)=>{const a=new XMLHttpRequest;a.open("GET","https://raw.githubusercontent.com/KudoAI/chat-prompts/main/dist/personas.min.json",!0),a.send(),a.onload=()=>{if(200!==a.status)return r("🤖 chatgpt.js >> Request failed. Cannot retrieve prompts data.");var e=JSON.parse(a.responseText).personas;if(s){var t=e.find(e=>e.title.toLowerCase()==s.toLowerCase());if(!t)return r(`🤖 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(const n of e)console.log("%c"+n.title,"font-family: monospace ; font-size: larger ;")}return o()}})},activateDarkMode:function(){document.documentElement.classList.replace("light","dark"),document.documentElement.style.colorScheme="dark",localStorage.setItem("theme","dark")},activateLightMode:function(){document.documentElement.classList.replace("dark","light"),document.documentElement.style.colorScheme="light",localStorage.setItem("theme","light")},alert:function(e,t,n,o,r){const a=chatgpt.isDarkMode()?"dark":"light",s=chatgpt.browser.isMobile(),i=document.createElement("div"),c=(i.id=Math.floor(1e6*chatgpt.randomFloat())+Date.now(),i.classList.add("chatgpt-modal"),document.createElement("div")),l=document.createElement("h2"),u=document.createElement("p");var d=20231203;let g=document.querySelector("#chatgpt-modal-style");(!g||parseInt(g.getAttribute("last-updated"),10)<d)&&(g||((g=document.createElement("style")).id="chatgpt-modal-style",g.setAttribute("last-updated",d.toString()),document.head.append(g)),g.innerText=".chatgpt-modal {position: fixed ; top: 0 ; left: 0 ; width: 100% ; height: 100% ;background-color: rgba(67, 70, 72, 0) ;transition: background-color 0.05s ease ;display: flex ; justify-content: center ; align-items: center ; z-index: 9999 }.chatgpt-modal > div {opacity: 0 ; transform: translateX(-2px) translateY(5px) ; max-width: 75vw ; word-wrap: break-word ;transition: opacity 0.1s cubic-bezier(.165,.84,.44,1), transform 0.2s cubic-bezier(.165,.84,.44,1) ;"+`background-color: ${"dark"==a?"black":"white"} ;`+("dark"!=a?"border: 1px solid rgba(0, 0, 0, 0.3) ;":"")+"padding: 20px ; margin: 12px 23px ; border-radius: 15px ; box-shadow: 0 30px 60px rgba(0, 0, 0, .12) ; -webkit-user-select: none ; -moz-user-select: none ; -ms-user-select: none ; user-select: none ; }.chatgpt-modal h2 { margin-bottom: 9px }"+`.chatgpt-modal a { color: ${"dark"==a?"#00cfff":"#1e9ebb"}}`+".chatgpt-modal.animated > div { opacity: 1 ; transform: translateX(0) translateY(0) }@keyframes alert-zoom-fade-out { 0% { opacity: 1 ; transform: scale(1) }50% { opacity: 0.25 ; transform: scale(1.05) }100% { opacity: 0 ; transform: scale(1.35) }}.modal-buttons { display: flex ; justify-content: flex-end ; margin: 20px -5px -3px 0 ;"+(s?"flex-direction: column-reverse":"")+"}.chatgpt-modal button {"+`margin-left: ${s?0:10}px ; padding: ${s?15:4}px 18px ; border-radius: 15px ;`+(s?"margin-top: 5px ; margin-bottom: 3px ;":"")+`border: 1px solid ${"dark"==a?"white":"black"}}`+".primary-modal-btn {"+`border: 1px solid ${"dark"==a?"white":"black"} ;`+`background: ${"dark"==a?"white":"black"} ;`+`color: ${"dark"==a?"black":"white"}}`+".chatgpt-modal button:hover { color: #3d5d71 ; border-color: #6d9cb9 ;background-color: "+("dark"==a?"#00cfff":"#9cdaff")+";box-shadow: 2px 1px "+("dark"==a?"54px #00cfff":"30px #9cdaff")+"}.modal-close-btn {cursor: pointer ; width: 20px ; height: 20px ; float: right ; position: relative ; right: -2px }.modal-close-btn svg { margin: 5px 5px }"+`.modal-close-btn:hover { background-color: #f2f2f2${"dark"==a?"00":""}}`+".chatgpt-modal .checkbox-group { display: flex ; margin-top: -18px }.chatgpt-modal .checkbox-group label {font-size: .7rem ; margin: -.04rem 0 0px .3rem ;"+`color: ${"dark"==a?"#e1e1e1":"#1e1e1e"}}`+'.chatgpt-modal input[type="checkbox"] { transform: scale(0.7) ;'+`border: 1px solid ${"dark"==a?"white":"black"}}`+'.chatgpt-modal input[type="checkbox"]:checked {'+`border: 1px solid ${"dark"==a?"white":"black"} ;`+'background-color: black ; position: inherit }.chatgpt-modal input[type="checkbox"]:focus { outline: none ; box-shadow: none }'),l.innerText=e||"",u.innerText=t||"",this.renderHTML(u);const p=document.createElement("div");p.classList.add("modal-buttons"),n&&(n=Array.isArray(n)?n:[n]).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.addEventListener("click",()=>{v(),e()}),p.insertBefore(t,p.firstChild)});d=document.createElement("button"),d.textContent=n?"Dismiss":"OK",p.insertBefore(d,p.firstChild),p.lastChild.classList.add("primary-modal-btn"),e=document.createElement("div");if(o){e.classList.add("checkbox-group");const b=o,w=document.createElement("input");w.type="checkbox",w.addEventListener("change",b);t=document.createElement("label");t.addEventListener("click",()=>{w.checked=!w.checked,b()}),t.textContent=b.name.charAt(0).toUpperCase()+b.name.slice(1).replace(/([A-Z])/g,(e,t)=>" "+t.toLowerCase()).replace(/\b(\w+)nt\b/gi,"$1n't").trim(),e.append(w),e.append(t)}n=document.createElement("div"),n.title="Close",n.classList.add("modal-close-btn"),o=document.createElementNS("http://www.w3.org/2000/svg","svg"),o.setAttribute("height","10px"),o.setAttribute("viewBox","0 0 14 14"),o.setAttribute("fill","none"),t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("fill-rule","evenodd"),t.setAttribute("clip-rule","evenodd"),t.setAttribute("fill",chatgpt.isDarkMode()?"white":"black"),t.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"),o.append(t),n.append(o),[n,l,u,p,e].forEach(e=>{c.append(e)}),c.style.width=`${r||458}px`,i.append(c),document.body.append(i);let h=JSON.parse(localStorage.alertQueue);h.push(i.id),localStorage.alertQueue=JSON.stringify(h),i.style.display="none",1===h.length&&(i.style.display="",setTimeout(()=>{i.style.backgroundColor=`rgba(67, 70, 72, ${"dark"==a?.62:0})`,i.classList.add("animated")},100));const f=e=>{(e.target==e.currentTarget||e.target instanceof SVGPathElement)&&v()},m=e=>{if([13,27].includes(e.keyCode))for(const n of h){var t=document.getElementById(n);if(t&&"none"!==t.style.display)return void(27===e.keyCode?v():13===e.keyCode&&(t=t.querySelector(".modal-buttons").lastChild)&&(t.click(),e.preventDefault()))}},y=[i,n,o,d],v=(y.forEach(e=>{e.addEventListener("click",f)}),document.addEventListener("keydown",m),()=>{i.style.backgroundColor="transparent",c.style.animation="alert-zoom-fade-out 0.075s ease-out",setTimeout(()=>{if(i.remove(),(h=JSON.parse(localStorage.alertQueue)).shift(),localStorage.alertQueue=JSON.stringify(h),y.forEach(e=>{e.removeEventListener("click",f)}),document.removeEventListener("keydown",m),0<h.length){const e=document.getElementById(h[0]);setTimeout(()=>{e.style.display="",setTimeout(()=>{e.classList.add("animated")},100)},500)}},50)});return i.id},askAndGetReply:async function(e){return chatgpt.send(e),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},autoRefresh:{activate:function(e){if(this.isActive)console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already active!");else{const n=this,o=(this.toggle.refreshFrame(),t=>{var e=Math.max(2,Math.floor(21*chatgpt.randomFloat()-10));n.isActive=setTimeout(()=>{var e=document.querySelector('script[src*="_ssgManifest.js"]');document.querySelector("#refresh-frame").src=e.src+"?"+Date.now(),console.log("↻ ChatGPT >> ["+n.nowTimeStamp()+"] ChatGPT session refreshed"),o(t)},1e3*(t+e))});o(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:function(){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:function(){var e=new Date,t=e.getHours()%12||12;let n=e.getMinutes(),o=e.getSeconds();n<10&&(n="0"+n),o<10&&(o="0"+o);e=e.getHours()<12?"AM":"PM";return t+":"+n+":"+o+" "+e},toggle:{beacons:function(){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:function(){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:function(){return window.matchMedia?.("(prefers-color-scheme: light)")?.matches},isDarkMode:function(){return window.matchMedia?.("(prefers-color-scheme: dark)")?.matches},isChromium:function(){return navigator.userAgent.includes("Chrome")},isFirefox:function(){return navigator.userAgent.includes("Firefox")},isFullScreen:function(){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:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}},clearChats:async function(e){var t=["api","dom"];if((e=(e||"dom").trim().toLowerCase())&&!t.includes(e))return console.log(`Method argument must be one of: [${t}]`);if("dom"!=e)return new Promise((n,o)=>{chatgpt.getAccessToken().then(e=>{const t=new XMLHttpRequest;t.open("PATCH",endpoints.openAI.chats,!0),t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("Authorization","Bearer "+e),t.onload=()=>{if(200!==t.status)return o("🤖 chatgpt.js >> Request failed. Cannot clear chats.");console.info("Chats successfully cleared"),n()},t.send(JSON.stringify({is_visible:!1}))}).catch(o)});try{await chatgpt.getChatData()}catch{return}chatgpt.menu.open(),setTimeout(()=>{var e=document.querySelector('a[role="menuitem"] svg path[d*="M12.003 10.5a1.5"]')?.parentNode.parentNode;e&&e.click(),setTimeout(()=>{var e=document.querySelectorAll("[id*=radix] button"),e=e[e.length-1];e&&e.click(),setTimeout(()=>{document.querySelector('button[class*="danger"').click()},10)},333)},10)},code:{execute:async function(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:function(e){var t=e.match(/(?<=```.*\n)[\s\S]*?(?=```)/g);return t?t[t.length-1]:e},minify:async function(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!")},obfuscate:async function(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!")},refactor:async function(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"))},review:async function(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!")},unminify:async function(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!")},write:async function(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"))}},detectLanguage:async function(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:function(){chatgpt.code.execute()},exportChat:async function(e,t){e=e?Number.isInteger(e)||/^\d+$/.test(e)?parseInt(e,10):e:"active",t=t.toLowerCase()||"html",console.info("Generating transcript...");let o="",n;if(/te?xt/.test(t)){var r=new Date,a=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(n=`ChatGPT_${a}-${s}-${i}_${c}-${r}.txt`,"active"==e&&/\/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(window.location.href)){a=document.querySelectorAll("main > div > div > div > div > div > div[class*=group]");if(0===a.length)return console.error("Chat is empty!");const l=[];let n=!0;a.forEach(e=>{var t=n?"USER":"CHATGPT",e=(n=!n,Array.from(e.childNodes).map(e=>e.innerText).join("\n\n").replace("Copy code",""));l.push(t+": "+e)}),o=l.join("\n\n")}else for(const u of await chatgpt.getChatData(e,"msg","both","all"))o=(o+=`USER: ${u.user}
|
|
7
|
+
const endpoints={assets:"https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@46788405f827728a239e8883e97740d80a2e9835",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"}},chatgpt=(localStorage.alertQueue=JSON.stringify([]),localStorage.notifyProps=JSON.stringify({queue:{topRight:[],bottomRight:[],bottomLeft:[],topLeft:[]}}),{openAIaccessToken:{},actAs:function(s){return new Promise((o,r)=>{const a=new XMLHttpRequest;a.open("GET","https://raw.githubusercontent.com/KudoAI/chat-prompts/main/dist/personas.min.json",!0),a.send(),a.onload=()=>{if(200!==a.status)return r("🤖 chatgpt.js >> Request failed. Cannot retrieve prompts data.");var e=JSON.parse(a.responseText).personas;if(s){var t=e.find(e=>e.title.toLowerCase()==s.toLowerCase());if(!t)return r(`🤖 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(const n of e)console.log("%c"+n.title,"font-family: monospace ; font-size: larger ;")}return o()}})},activateDarkMode:function(){document.documentElement.classList.replace("light","dark"),document.documentElement.style.colorScheme="dark",localStorage.setItem("theme","dark")},activateLightMode:function(){document.documentElement.classList.replace("dark","light"),document.documentElement.style.colorScheme="light",localStorage.setItem("theme","light")},alert:function(e,t,n,o,r){const a=chatgpt.isDarkMode()?"dark":"light",s=chatgpt.browser.isMobile(),i=document.createElement("div"),c=(i.id=Math.floor(1e6*chatgpt.randomFloat())+Date.now(),i.classList.add("chatgpt-modal"),document.createElement("div")),l=document.createElement("h2"),u=document.createElement("p");var d=20231203;let g=document.querySelector("#chatgpt-modal-style");(!g||parseInt(g.getAttribute("last-updated"),10)<d)&&(g||((g=document.createElement("style")).id="chatgpt-modal-style",g.setAttribute("last-updated",d.toString()),document.head.append(g)),g.innerText=".chatgpt-modal {position: fixed ; top: 0 ; left: 0 ; width: 100% ; height: 100% ;background-color: rgba(67, 70, 72, 0) ;transition: background-color 0.05s ease ;display: flex ; justify-content: center ; align-items: center ; z-index: 9999 }.chatgpt-modal > div {opacity: 0 ; transform: translateX(-2px) translateY(5px) ; max-width: 75vw ; word-wrap: break-word ;transition: opacity 0.1s cubic-bezier(.165,.84,.44,1), transform 0.2s cubic-bezier(.165,.84,.44,1) ;"+`background-color: ${"dark"==a?"black":"white"} ;`+("dark"!=a?"border: 1px solid rgba(0, 0, 0, 0.3) ;":"")+"padding: 20px ; margin: 12px 23px ; border-radius: 15px ; box-shadow: 0 30px 60px rgba(0, 0, 0, .12) ; -webkit-user-select: none ; -moz-user-select: none ; -ms-user-select: none ; user-select: none ; }.chatgpt-modal h2 { margin-bottom: 9px }"+`.chatgpt-modal a { color: ${"dark"==a?"#00cfff":"#1e9ebb"}}`+".chatgpt-modal.animated > div { opacity: 1 ; transform: translateX(0) translateY(0) }@keyframes alert-zoom-fade-out { 0% { opacity: 1 ; transform: scale(1) }50% { opacity: 0.25 ; transform: scale(1.05) }100% { opacity: 0 ; transform: scale(1.35) }}.modal-buttons { display: flex ; justify-content: flex-end ; margin: 20px -5px -3px 0 ;"+(s?"flex-direction: column-reverse":"")+"}.chatgpt-modal button {"+`margin-left: ${s?0:10}px ; padding: ${s?15:4}px 18px ; border-radius: 15px ;`+(s?"margin-top: 5px ; margin-bottom: 3px ;":"")+`border: 1px solid ${"dark"==a?"white":"black"}}`+".primary-modal-btn {"+`border: 1px solid ${"dark"==a?"white":"black"} ;`+`background: ${"dark"==a?"white":"black"} ;`+`color: ${"dark"==a?"black":"white"}}`+".chatgpt-modal button:hover { color: #3d5d71 ; border-color: #6d9cb9 ;background-color: "+("dark"==a?"#00cfff":"#9cdaff")+";box-shadow: 2px 1px "+("dark"==a?"54px #00cfff":"30px #9cdaff")+"}.modal-close-btn {cursor: pointer ; width: 20px ; height: 20px ; float: right ; position: relative ; right: -2px }.modal-close-btn svg { margin: 5px 5px }"+`.modal-close-btn:hover { background-color: #f2f2f2${"dark"==a?"00":""}}`+".chatgpt-modal .checkbox-group { display: flex ; margin-top: -18px }.chatgpt-modal .checkbox-group label {font-size: .7rem ; margin: -.04rem 0 0px .3rem ;"+`color: ${"dark"==a?"#e1e1e1":"#1e1e1e"}}`+'.chatgpt-modal input[type="checkbox"] { transform: scale(0.7) ;'+`border: 1px solid ${"dark"==a?"white":"black"}}`+'.chatgpt-modal input[type="checkbox"]:checked {'+`border: 1px solid ${"dark"==a?"white":"black"} ;`+'background-color: black ; position: inherit }.chatgpt-modal input[type="checkbox"]:focus { outline: none ; box-shadow: none }'),l.innerText=e||"",u.innerText=t||"",this.renderHTML(u);const p=document.createElement("div");p.classList.add("modal-buttons"),n&&(n=Array.isArray(n)?n:[n]).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.addEventListener("click",()=>{w(),e()}),p.insertBefore(t,p.firstChild)});d=document.createElement("button"),d.textContent=n?"Dismiss":"OK",p.insertBefore(d,p.firstChild),p.lastChild.classList.add("primary-modal-btn"),e=document.createElement("div");if(o){e.classList.add("checkbox-group");const v=o,b=document.createElement("input");b.type="checkbox",b.addEventListener("change",v);t=document.createElement("label");t.addEventListener("click",()=>{b.checked=!b.checked,v()}),t.textContent=v.name.charAt(0).toUpperCase()+v.name.slice(1).replace(/([A-Z])/g,(e,t)=>" "+t.toLowerCase()).replace(/\b(\w+)nt\b/gi,"$1n't").trim(),e.append(b),e.append(t)}n=document.createElement("div"),n.title="Close",n.classList.add("modal-close-btn"),o=document.createElementNS("http://www.w3.org/2000/svg","svg"),o.setAttribute("height","10px"),o.setAttribute("viewBox","0 0 14 14"),o.setAttribute("fill","none"),t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("fill-rule","evenodd"),t.setAttribute("clip-rule","evenodd"),t.setAttribute("fill",chatgpt.isDarkMode()?"white":"black"),t.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"),o.append(t),n.append(o),[n,l,u,p,e].forEach(e=>{c.append(e)}),c.style.width=`${r||458}px`,i.append(c),document.body.append(i);let h=JSON.parse(localStorage.alertQueue);h.push(i.id),localStorage.alertQueue=JSON.stringify(h),i.style.display="none",1===h.length&&(i.style.display="",setTimeout(()=>{i.style.backgroundColor=`rgba(67, 70, 72, ${"dark"==a?.62:0})`,i.classList.add("animated")},100));const f=e=>{(e.target==e.currentTarget||e.target instanceof SVGPathElement)&&w()},m=e=>{if([13,27].includes(e.keyCode))for(const n of h){var t=document.getElementById(n);if(t&&"none"!==t.style.display)return void(27===e.keyCode?w():13===e.keyCode&&(t=t.querySelector(".modal-buttons").lastChild)&&(t.click(),e.preventDefault()))}},y=[i,n,o,d],w=(y.forEach(e=>{e.addEventListener("click",f)}),document.addEventListener("keydown",m),()=>{i.style.backgroundColor="transparent",c.style.animation="alert-zoom-fade-out 0.075s ease-out",setTimeout(()=>{if(i.remove(),(h=JSON.parse(localStorage.alertQueue)).shift(),localStorage.alertQueue=JSON.stringify(h),y.forEach(e=>{e.removeEventListener("click",f)}),document.removeEventListener("keydown",m),0<h.length){const e=document.getElementById(h[0]);setTimeout(()=>{e.style.display="",setTimeout(()=>{e.classList.add("animated")},100)},500)}},50)});return i.id},askAndGetReply:async function(e){return chatgpt.send(e),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},autoRefresh:{activate:function(e){if(this.isActive)console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already active!");else{const n=this,o=(this.toggle.refreshFrame(),t=>{var e=Math.max(2,Math.floor(21*chatgpt.randomFloat()-10));n.isActive=setTimeout(()=>{var e=document.querySelector('script[src*="_ssgManifest.js"]');document.querySelector("#refresh-frame").src=e.src+"?"+Date.now(),console.log("↻ ChatGPT >> ["+n.nowTimeStamp()+"] ChatGPT session refreshed"),o(t)},1e3*(t+e))});o(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:function(){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:function(){var e=new Date,t=e.getHours()%12||12;let n=e.getMinutes(),o=e.getSeconds();n<10&&(n="0"+n),o<10&&(o="0"+o);e=e.getHours()<12?"AM":"PM";return t+":"+n+":"+o+" "+e},toggle:{beacons:function(){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:function(){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:function(){return window.matchMedia?.("(prefers-color-scheme: light)")?.matches},isDarkMode:function(){return window.matchMedia?.("(prefers-color-scheme: dark)")?.matches},isChromium:function(){return navigator.userAgent.includes("Chrome")},isFirefox:function(){return navigator.userAgent.includes("Firefox")},isFullScreen:function(){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:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}},clearChats:async function(e){var t=["api","dom"];if((e=(e||"dom").trim().toLowerCase())&&!t.includes(e))return console.error(`Method argument must be one of: [${t}]`);if("dom"!=e)return new Promise((n,o)=>{chatgpt.getAccessToken().then(e=>{const t=new XMLHttpRequest;t.open("PATCH",endpoints.openAI.chats,!0),t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("Authorization","Bearer "+e),t.onload=()=>{if(200!==t.status)return o("🤖 chatgpt.js >> Request failed. Cannot clear chats.");console.info("Chats successfully cleared"),n()},t.send(JSON.stringify({is_visible:!1}))}).catch(e=>o(new Error(e.message)))});t=t=>new Promise(e=>setTimeout(e,t));try{chatgpt.menu.open(),await t(10);document.querySelector('a[role="menuitem"] svg path[d*="M12.003 10.5a1.5"]').parentNode.parentNode.click(),await t(333);var n=document.querySelectorAll("[id*=radix] button");return n[n.length-1].click(),await t(10),document.querySelector('button[class*="danger"').click(),console.info("Chats successfully cleared.")}catch(e){console.error(e.message),0==arguments.length&&(console.info("Using backend API method instead."),this.clearChats("api"))}},code:{execute:async function(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:function(e){var t=e.match(/(?<=```.*\n)[\s\S]*?(?=```)/g);return t?t[t.length-1]:e},minify:async function(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!")},obfuscate:async function(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!")},refactor:async function(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"))},review:async function(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!")},unminify:async function(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!")},write:async function(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:function(){this.response.continue()},detectLanguage:async function(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:function(){chatgpt.code.execute()},exportChat:async function(e,t){e=e?Number.isInteger(e)||/^\d+$/.test(e)?parseInt(e,10):e:"active",t=t.toLowerCase()||"html",console.info("Generating transcript...");let o="",n;if(/te?xt/.test(t)){var r=new Date,a=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(n=`ChatGPT_${a}-${s}-${i}_${c}-${r}.txt`,"active"==e&&/\/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(window.location.href)){a=document.querySelectorAll("main > div > div > div > div > div > div[class*=group]");if(0===a.length)return console.error("Chat is empty!");const l=[];let n=!0;a.forEach(e=>{var t=n?"USER":"CHATGPT",e=(n=!n,Array.from(e.childNodes).map(e=>e.innerText).join("\n\n").replace("Copy code",""));l.push(t+": "+e)}),o=l.join("\n\n")}else for(const u of await chatgpt.getChatData(e,"msg","both","all"))o=(o+=`USER: ${u.user}
|
|
8
8
|
|
|
9
9
|
`)+`CHATGPT: ${u.chatgpt}
|
|
10
10
|
|
|
11
|
-
`}else{s=await(await fetch(await chatgpt.shareChat(e))).text(),i=(new DOMParser).parseFromString(s,"text/html");n=i.querySelector("title").textContent+".html",i.querySelectorAll('link[rel="stylesheet"]').forEach(e=>{var t=e.getAttribute("href");t?.startsWith("/")&&e.setAttribute("href","https://chat.openai.com"+t)}),o=(new XMLSerializer).serializeToString(i)}if(console.info(`Exporting transcript as ${t.toUpperCase()}...`),"pdf"==t){o=o.replace(/<svg.*?<\/svg>/g,e=>{return`<img src="${"data:image/svg+xml,"+encodeURIComponent(e)}">`});const d=window.open("","","toolbar=0, location=0, menubar=0, height=600, width=800");d.document.write(o),setTimeout(()=>{d.print({toPDF:!0})},100)}else{"md"==t&&(c=/<.*(?:<h1(.|\n)*?href=".*?continue[^"]*".*?\/a>.*?)<[^/]/.exec(o)[1],o=c||o,n=n.replace(".html",".md"));r=new Blob([o],{type:"text/"+("html"==t?"html":"md"==t?"markdown":"plain")}),a=document.createElement("a"),e=URL.createObjectURL(r);a.href=e,a.download=n,document.body.append(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(e)}},extractCode:function(){chatgpt.code.extract()},generateRandomIP:function(){var e=Array.from({length:4},()=>Math.floor(256*chatgpt.randomFloat())).join(".");return console.info("IP generated: "+e),e},get:function(e,t=""){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Invalid arguments. Both arguments must be strings.");if(!targetTypes.includes(e.toLowerCase()))throw new Error("Invalid targetType: "+e+". Valid values are: "+JSON.stringify(targetTypes));var n=[],o=new RegExp("^get(.*)"+e+"$","i");for(const a in chatgpt)"function"==typeof chatgpt[a]&&o.test(a)&&n.push(a.replace(o,"$1").toLowerCase());if(!n.includes(t.toLowerCase()))throw new Error("Invalid targetName: "+t+". "+(0<n.length?"Valid values are: "+JSON.stringify(n):"targetType "+e.toLowerCase()+" does not require additional options."));const r=("get"+t+e).toLowerCase();return this[Object.keys(this).find(e=>e.toLowerCase()==r)]()},getAccessToken:function(){return new Promise((e,t)=>{if(0<Object.keys(chatgpt.openAIaccessToken).length&&0<=Date.parse(chatgpt.openAIaccessToken.expireDate)-Date.parse(new Date))return e(chatgpt.openAIaccessToken.token);const n=new XMLHttpRequest;n.open("GET",endpoints.openAI.session,!0),n.setRequestHeader("Content-Type","application/json"),n.onload=()=>200!==n.status?t("🤖 chatgpt.js >> Request failed. Cannot retrieve access token."):(console.info("Token expiration: "+new Date(JSON.parse(n.responseText).expires).toLocaleString().replace(","," at")),chatgpt.openAIaccessToken={token:JSON.parse(n.responseText).accessToken,expireDate:JSON.parse(n.responseText).expires},e(chatgpt.openAIaccessToken.token)),n.send()})},getAccountDetails:function(...s){var e=["email","id","image","name","picture"];for(const t of s=arguments[0]?Array.isArray(arguments[0])?arguments[0]:Array.from(arguments):e)if(!e.includes(t))return console.error("Invalid detail arg '"+t+"' supplied. Valid details are:\n ["+e+"]");return new Promise((o,r)=>{const a=new XMLHttpRequest;a.open("GET",endpoints.openAI.session,!0),a.setRequestHeader("Content-Type","application/json"),a.onload=()=>{if(200!==a.status)return r("🤖 chatgpt.js >> Request failed. Cannot retrieve account details.");var e=JSON.parse(a.responseText).user,t={};for(const n of s)t[n]=e[n];return o(t)},a.send()})},getChatBox:function(){return document.getElementById("prompt-textarea")},getChatData:function(u=1,o="all",p="all",h="all"){var e=["all","id","title","create_time","update_time","msg"],t=["all","both","user","chatgpt"];u=u?Number.isInteger(u)||/^\d+$/.test(u)?0===parseInt(u,10)?0:parseInt(u,10)-1:u:"active",o=["all",""].includes(o)?e.filter(e=>/^(?!all$|msg$).*/.test(e)):Array.isArray(o)?o:[o],p=p?t.includes(p)?p:"invalid":"all",h=Number.isInteger(h)||/^\d+$/.test(h)?0===parseInt(h,10)?0:parseInt(h,10)-1:["all","latest"].includes(h.toLowerCase())?h.toLowerCase():h?"invalid":"all";for(const n of o)if(!e.includes(n))return console.error("Invalid detail arg '"+n+"' passed. Valid details are:\n ["+e+"]");if("invalid"==p)return console.error("Invalid sender arg passed. Valid senders are:\n ["+t+"]");if("invalid"==h)return console.error("Invalid msgToGet arg passed. Valid msg's to get are:\n [ 'all' | 'latest' | index of msg to get ]");const r=(e,c)=>{const l=/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/;return new Promise((t,s)=>{const i=new XMLHttpRequest;i.open("GET",endpoints.openAI.chats,!0),i.setRequestHeader("Content-Type","application/json"),i.setRequestHeader("Authorization","Bearer "+e),i.onload=()=>{if(200!==i.status)return s("🤖 chatgpt.js >> Request failed. Cannot retrieve chat details.");var n=JSON.parse(i.responseText).items;if(n.length<=0)return s("🤖 chatgpt.js >> Chat list is empty.");var o={};if(Number.isInteger(u)||"latest"==u||"active"==u&&!new RegExp("/"+l.source+"$").test(window.location.href)){if((u=Number.isInteger(u)?u:0)>n.length)return s("🤖 chatgpt.js >> Chat with index "+(u+1)+" is out of bounds. Only "+n.length+" chats exist!");for(const e of c)o[e]=n[u][e]}else{var r="active"==u||new RegExp("^"+l.source+"$").test(u)?"id":"title";"active"==u&&(u=l.exec(window.location.href)[0]);let e,t;for(e=0;e<n.length;e++)if(n[e][r]==u){t=!0;break}if(!t)return s("🤖 chatgpt.js >> No chat with "+r+" = "+u+" found.");for(const a of c)o[a]=n[e][a]}return t(o)},i.send()})};return new Promise(n=>chatgpt.getAccessToken().then(e=>{return n(o.includes("msg")?(t=e,new Promise((u,d)=>{const g=new XMLHttpRequest;r(t,["id"]).then(e=>{g.open("GET",endpoints.openAI.chat+"/"+e.id,!0),g.setRequestHeader("Content-Type","application/json"),g.setRequestHeader("Authorization","Bearer "+t),g.onload=()=>{if(200!==g.status)return d("🤖 chatgpt.js >> Request failed. Cannot retrieve chat messages.");var t=JSON.parse(g.responseText).mapping,n=[],o=[],r=[];for(const e in t)null!=t[e].message&&"user"==t[e].message.author.role&&n.push({id:t[e].id,msg:t[e].message});if(n.sort((e,t)=>e.msg.create_time-t.msg.create_time),parseInt(h,10)+1>n.length)return d("🤖 chatgpt.js >> Message/response with index "+(h+1)+" is out of bounds. Only "+n.length+" messages/responses exist!");for(const a of n){let e=[];for(const s in t)null!=t[s].message&&"assistant"==t[s].message.author.role&&t[s].parent==a.id&&e.push(t[s].message);e.sort((e,t)=>e.create_time-t.create_time),e=1===(e=e.map(e=>{switch(e.content.content_type){case"code":return e.content.text;case"text":return e.content.parts[0];default:return}})).length?e[0]:e,o.push(e)}if("user"==p)for(const i in n)r.push(n[i].msg.content.parts[0]);else if("chatgpt"==p)for(const c of o)r.push("latest"==h?o[o.length-1]:c);else{let e=0;for(const l in n)r.push({user:n[l].msg.content.parts[0],chatgpt:"latest"==h?o[e][o[e].length-1]:o[e]}),e++}return u("all"==h?r:"latest"==h?r[r.length-1]:r[h])},g.send()})})):r(e,o));var t}))},getChatInput:function(){return chatgpt.getChatBox().value},getContinueGeneratingButton:function(){for(const e of document.querySelectorAll("form button svg"))if(e.querySelector('
|
|
11
|
+
`}else{s=await(await fetch(await chatgpt.shareChat(e))).text(),i=(new DOMParser).parseFromString(s,"text/html");n=i.querySelector("title").textContent+".html",i.querySelectorAll('link[rel="stylesheet"]').forEach(e=>{var t=e.getAttribute("href");t?.startsWith("/")&&e.setAttribute("href","https://chat.openai.com"+t)}),o=(new XMLSerializer).serializeToString(i)}if(console.info(`Exporting transcript as ${t.toUpperCase()}...`),"pdf"==t){o=o.replace(/<svg.*?<\/svg>/g,e=>{return`<img src="${"data:image/svg+xml,"+encodeURIComponent(e)}">`});const d=window.open("","","toolbar=0, location=0, menubar=0, height=600, width=800");d.document.write(o),setTimeout(()=>{d.print({toPDF:!0})},100)}else{"md"==t&&(c=/<.*(?:<h1(.|\n)*?href=".*?continue[^"]*".*?\/a>.*?)<[^/]/.exec(o)[1],o=c||o,n=n.replace(".html",".md"));r=new Blob([o],{type:"text/"+("html"==t?"html":"md"==t?"markdown":"plain")}),a=document.createElement("a"),e=URL.createObjectURL(r);a.href=e,a.download=n,document.body.append(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(e)}},extractCode:function(){chatgpt.code.extract()},generateRandomIP:function(){var e=Array.from({length:4},()=>Math.floor(256*chatgpt.randomFloat())).join(".");return console.info("IP generated: "+e),e},get:function(e,t=""){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Invalid arguments. Both arguments must be strings.");if(!targetTypes.includes(e.toLowerCase()))throw new Error("Invalid targetType: "+e+". Valid values are: "+JSON.stringify(targetTypes));var n=[],o=new RegExp("^get(.*)"+e+"$","i");for(const a in chatgpt)"function"==typeof chatgpt[a]&&o.test(a)&&n.push(a.replace(o,"$1").toLowerCase());if(!n.includes(t.toLowerCase()))throw new Error("Invalid targetName: "+t+". "+(0<n.length?"Valid values are: "+JSON.stringify(n):"targetType "+e.toLowerCase()+" does not require additional options."));const r=("get"+t+e).toLowerCase();return this[Object.keys(this).find(e=>e.toLowerCase()==r)]()},getAccessToken:function(){return new Promise((e,t)=>{if(0<Object.keys(chatgpt.openAIaccessToken).length&&0<=Date.parse(chatgpt.openAIaccessToken.expireDate)-Date.parse(new Date))return e(chatgpt.openAIaccessToken.token);const n=new XMLHttpRequest;n.open("GET",endpoints.openAI.session,!0),n.setRequestHeader("Content-Type","application/json"),n.onload=()=>200!==n.status?t("🤖 chatgpt.js >> Request failed. Cannot retrieve access token."):(console.info("Token expiration: "+new Date(JSON.parse(n.responseText).expires).toLocaleString().replace(","," at")),chatgpt.openAIaccessToken={token:JSON.parse(n.responseText).accessToken,expireDate:JSON.parse(n.responseText).expires},e(chatgpt.openAIaccessToken.token)),n.send()})},getAccountDetails:function(...s){var e=["email","id","image","name","picture"];for(const t of s=arguments[0]?Array.isArray(arguments[0])?arguments[0]:Array.from(arguments):e)if(!e.includes(t))return console.error("Invalid detail arg '"+t+"' supplied. Valid details are:\n ["+e+"]");return new Promise((o,r)=>{const a=new XMLHttpRequest;a.open("GET",endpoints.openAI.session,!0),a.setRequestHeader("Content-Type","application/json"),a.onload=()=>{if(200!==a.status)return r("🤖 chatgpt.js >> Request failed. Cannot retrieve account details.");var e=JSON.parse(a.responseText).user,t={};for(const n of s)t[n]=e[n];return o(t)},a.send()})},getChatBox:function(){return document.getElementById("prompt-textarea")},getChatData:function(u=1,o="all",p="all",h="all"){var e=["all","id","title","create_time","update_time","msg"],t=["all","both","user","chatgpt"];u=u?Number.isInteger(u)||/^\d+$/.test(u)?0===parseInt(u,10)?0:parseInt(u,10)-1:u:"active",o=["all",""].includes(o)?e.filter(e=>/^(?!all$|msg$).*/.test(e)):Array.isArray(o)?o:[o],p=p?t.includes(p)?p:"invalid":"all",h=Number.isInteger(h)||/^\d+$/.test(h)?0===parseInt(h,10)?0:parseInt(h,10)-1:["all","latest"].includes(h.toLowerCase())?h.toLowerCase():h?"invalid":"all";for(const n of o)if(!e.includes(n))return console.error("Invalid detail arg '"+n+"' passed. Valid details are:\n ["+e+"]");if("invalid"==p)return console.error("Invalid sender arg passed. Valid senders are:\n ["+t+"]");if("invalid"==h)return console.error("Invalid msgToGet arg passed. Valid msg's to get are:\n [ 'all' | 'latest' | index of msg to get ]");const r=(e,c)=>{const l=/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/;return new Promise((t,s)=>{const i=new XMLHttpRequest;i.open("GET",endpoints.openAI.chats,!0),i.setRequestHeader("Content-Type","application/json"),i.setRequestHeader("Authorization","Bearer "+e),i.onload=()=>{if(200!==i.status)return s("🤖 chatgpt.js >> Request failed. Cannot retrieve chat details.");var n=JSON.parse(i.responseText).items;if(n.length<=0)return s("🤖 chatgpt.js >> Chat list is empty.");var o={};if(Number.isInteger(u)||"latest"==u||"active"==u&&!new RegExp("/"+l.source+"$").test(window.location.href)){if((u=Number.isInteger(u)?u:0)>n.length)return s("🤖 chatgpt.js >> Chat with index "+(u+1)+" is out of bounds. Only "+n.length+" chats exist!");for(const e of c)o[e]=n[u][e]}else{var r="active"==u||new RegExp("^"+l.source+"$").test(u)?"id":"title";"active"==u&&(u=l.exec(window.location.href)[0]);let e,t;for(e=0;e<n.length;e++)if(n[e][r]==u){t=!0;break}if(!t)return s("🤖 chatgpt.js >> No chat with "+r+" = "+u+" found.");for(const a of c)o[a]=n[e][a]}return t(o)},i.send()})};return new Promise(n=>chatgpt.getAccessToken().then(e=>{return n(o.includes("msg")?(t=e,new Promise((u,d)=>{const g=new XMLHttpRequest;r(t,["id"]).then(e=>{g.open("GET",endpoints.openAI.chat+"/"+e.id,!0),g.setRequestHeader("Content-Type","application/json"),g.setRequestHeader("Authorization","Bearer "+t),g.onload=()=>{if(200!==g.status)return d("🤖 chatgpt.js >> Request failed. Cannot retrieve chat messages.");var t=JSON.parse(g.responseText).mapping,n=[],o=[],r=[];for(const e in t)null!=t[e].message&&"user"==t[e].message.author.role&&n.push({id:t[e].id,msg:t[e].message});if(n.sort((e,t)=>e.msg.create_time-t.msg.create_time),parseInt(h,10)+1>n.length)return d("🤖 chatgpt.js >> Message/response with index "+(h+1)+" is out of bounds. Only "+n.length+" messages/responses exist!");for(const a of n){let e=[];for(const s in t)null!=t[s].message&&"assistant"==t[s].message.author.role&&t[s].parent==a.id&&e.push(t[s].message);e.sort((e,t)=>e.create_time-t.create_time),e=1===(e=e.map(e=>{switch(e.content.content_type){case"code":return e.content.text;case"text":return e.content.parts[0];default:return}})).length?e[0]:e,o.push(e)}if("user"==p)for(const i in n)r.push(n[i].msg.content.parts[0]);else if("chatgpt"==p)for(const c of o)r.push("latest"==h?o[o.length-1]:c);else{let e=0;for(const l in n)r.push({user:n[l].msg.content.parts[0],chatgpt:"latest"==h?o[e][o[e].length-1]:o[e]}),e++}return u("all"==h?r:"latest"==h?r[r.length-1]:r[h])},g.send()})})):r(e,o));var t}))},getChatInput:function(){return chatgpt.getChatBox().value},getContinueGeneratingButton:function(){for(const e of document.querySelectorAll("form button svg"))if(e.querySelector('path[d*="M4.472 2.5a1"]'))return e.parentNode.parentNode},getFooterDiv:function(){return document.querySelector("main form").parentNode.parentNode.nextElementSibling},getHeaderDiv:function(){return document.querySelector("main .sticky")},getLastPrompt:function(){return chatgpt.getChatData("active","msg","user","latest")},getLastResponse:function(){return chatgpt.getChatData("active","msg","chatgpt","latest")},getNewChatButton:function(){for(const e of document.querySelectorAll("nav button svg"))if(e.querySelector('path[d*="M15.673 3.913a3.121"]'))return e.parentNode},getNewChatLink:function(){return document.querySelector('nav a[href="/"]')},getRegenerateButton:function(){for(const e of document.querySelectorAll("main svg"))if(e.querySelector('path[d*="M3.07 10.876C3.623"]'))return e.parentNode},getResponse:function(){return chatgpt.response.get(...arguments)},getResponseFromAPI:function(e,t){return chatgpt.response.getFromAPI(e,t)},getResponseFromDOM:function(e){return chatgpt.response.getFromDOM(e)},getScrollToBottomButton:function(){return document.querySelector('button[class*="cursor"][class*="bottom"]')},getSendButton:function(){return document.querySelector('[data-testid="send-button"]')||document.querySelector('path[d*="M15.192 8.906a1.143"]')?.parentNode.parentNode},getStopGeneratingButton:function(){for(const e of document.querySelectorAll("form button svg"))if(e.querySelector('path[d*="2 0 0 1 2"], rect'))return e.parentNode},getUserLanguage:function(){return navigator.languages[0]||navigator.language||navigator.browserLanguage||navigator.systemLanguage||navigator.userLanguage||""},hideFooter:function(){chatgpt.getFooterDiv().style.display="none"},hideHeader:function(){chatgpt.getHeaderDiv().style.display="none"},history:{isLoaded:function(){return new Promise(t=>{!function e(){document.querySelector("nav")?t(!0):setTimeout(e,100)}()})}},instructions:{add:function(o,r){var e;return o?"string"!=typeof o?console.error("Instruction must be a string"):(e=["user","chatgpt"],r?"string"!=typeof r?console.error("Target must be a string"):(r=r.toLowerCase(),e.includes(r)?(o=`
|
|
12
12
|
|
|
13
|
-
`+o,new Promise(n=>{chatgpt.getAccessToken().then(async e=>{var t=await this.fetchData();return"user"==r?t.about_user_message+=o:"chatgpt"==r&&(t.about_model_message+=o),await this.sendRequest("POST",e,t),n()})})):console.error(`Invalid target ${r}. Valid targets are [${e}]`)):console.error("Please provide a valid target!")):console.error("Please provide an instruction")},clear:function(o){var e=["user","chatgpt"];return o?"string"!=typeof o?console.error("Target must be a string"):(o=o.toLowerCase(),e.includes(o)?new Promise(n=>{chatgpt.getAccessToken().then(async e=>{var t=await this.fetchData();return"user"==o?t.about_user_message="":"chatgpt"==o&&(t.about_model_message=""),await this.sendRequest("POST",e,t),n()})}):console.error(`Invalid target ${o}. Valid targets are [${e}]`)):console.error("Please provide a valid target!")},fetchData:function(){return new Promise(t=>{chatgpt.getAccessToken().then(async e=>t(await this.sendRequest("GET",e)))})},sendRequest:function(r,e,a){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(r=(r||"").trim().toUpperCase())&&t.includes(r)?e?a&&"object"!=typeof a?console.error(`Invalid body data type. Got ${typeof a}, expected object`):new Promise((t,n)=>{const o=new XMLHttpRequest;o.open(r,endpoints.openAI.instructions,!0),o.setRequestHeader("Accept-Language","en-US"),o.setRequestHeader("Authorization","Bearer "+e),"POST"==r&&o.setRequestHeader("Content-Type","application/json"),o.onload=()=>{var e=JSON.parse(o.responseText);return 422===o.status?n("🤖 chatgpt.js >> Character limit exceeded. Custom instructions can have a maximum length of 1500 characters."):403===o.status&&"content_policy"==e.detail.reason?n("🤖 chatgpt.js >> "+e.detail.description):200!==o.status?n("🤖 chatgpt.js >> Request failed. Cannot contact custom instructions endpoint."):(console.info("Custom instructions successfully contacted with method "+r),t(e||{}))},o.send(JSON.stringify(a)||"")}):console.error("Please provide a valid access token!"):console.error("Valid methods are "+t)},turnOff:function(){return new Promise(n=>{chatgpt.getAccessToken().then(async e=>{var t=await this.fetchData();return t.enabled=!1,await this.sendRequest("POST",e,t),n()})})},turnOn:function(){return new Promise(n=>{chatgpt.getAccessToken().then(async e=>{var t=await this.fetchData();return t.enabled=!0,await this.sendRequest("POST",e,t),n()})})},toggle:function(){return new Promise(t=>{this.fetchData().then(async e=>(await(e.enabled?this.turnOff():this.turnOn()),t()))})}},isChromium:function(){return chatgpt.browser.isChromium()},isDarkMode:function(){return document.documentElement.classList.toString().includes("dark")},isFirefox:function(){return chatgpt.browser.isFirefox()},isFullScreen:function(){return chatgpt.browser.isFullScreen()},isIdle:function(){return new Promise(e=>{const t=setInterval(()=>{chatgpt.getRegenerateButton()&&(clearInterval(t),e(!0))},100)})},isLoaded:function(){return new Promise(t=>{!function e(){chatgpt.getNewChatButton()?t(!0):setTimeout(e,100)}()})},isLightMode:function(){return document.documentElement.classList.toString().includes("light")},isMobileDevice:function(){return chatgpt.browser.isMobile()},logout:function(){window.location.href="https://chat.openai.com/auth/logout"},menu:{elements:[],addedEvent:!1,append:function(e,t={}){var n=["button","dropdown"];if(!e||"string"!=typeof e)return console.error("🤖 chatgpt.js >> Please supply a valid string element name!");if(e=e.toLowerCase(),!n.includes(e))return console.error(`🤖 chatgpt.js >> Invalid element! Valid elements are [${n}]`);const o=document.createElement("dropdown"==e?"select":"button"==e?"a":e);if(o.id=Math.floor(1e6*chatgpt.randomFloat())+Date.now(),"button"==e){o.textContent=t?.label&&"string"==typeof t.label?t.label:"chatgpt.js button";n=document.createElement("img");n.src=t?.icon&&"string"==typeof t.icon?t.icon:endpoints.assets+"/starters/chrome/extension/icons/icon128.png",n.width=18,o.insertBefore(n,o.firstChild),o.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!");o.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,o.add(t)})}const r=()=>{var e,t=document.querySelectorAll('a[role="menuitem"]');let n;for(e of t)if("Settings"==e.textContent){n=e.classList;break}const o=t[0].parentNode;chatgpt.menu.elements.forEach(e=>{if(e.setAttribute("class",n),!o.contains(e))try{o.insertBefore(e,o.firstChild)}catch(e){console.error(e)}})};this.elements.push(o);n=document.querySelector('nav button[id*="headless"]');return this.addedEvent||(n.addEventListener("click",()=>{setTimeout(r,25)}),this.addedEvent=!0),o.id},close:function(){var e=document.querySelector('nav [id*="menu-button"][aria-expanded="true"]');if(e)try{e.click()}catch(e){return console.error(e.message)}else console.info("Menu already hidden!")},open:function(){var e=document.querySelector('nav [id*="menu-button"][aria-expanded="false"]');if(e)try{e.click()}catch(e){return console.error(e.message)}else console.info("Menu already open!")}},minify:function(){chatgpt.code.minify()},notify:async function(e,t,n,o){n=n?+n:1.75;const r=document.createElement("div");r.id=Math.floor(1e6*chatgpt.randomFloat())+Date.now(),r.classList.add("chatgpt-notif"),r.innerText=e,document.body.append(r);var e=document.createElement("div"),a=(e.title="Dismiss",e.classList.add("notif-close-btn"),document.createElementNS("http://www.w3.org/2000/svg","svg")),s=(a.setAttribute("height","8px"),a.setAttribute("viewBox","0 0 14 14"),a.setAttribute("fill","none"),a.style.height=a.style.width="8px",document.createElementNS("http://www.w3.org/2000/svg","path"));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"),a.append(s),e.append(a),r.append(e),r.isTop=!t||!/low|bottom/i.test(t),r.isRight=!t||!/left/i.test(t),r.quadrant=(r.isTop?"top":"bottom")+(r.isRight?"Right":"Left");let i=document.querySelector("#chatgpt-notif-style"),c=((!i||parseInt(i.getAttribute("last-updated"),10)<20231110)&&(i||((i=document.createElement("style")).id="chatgpt-notif-style",i.setAttribute("last-updated",20231110..toString()),document.head.append(i)),i.innerText=".chatgpt-notif {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 ;-webkit-user-select: none ; -moz-user-select: none ; -ms-user-select: none ; user-select: none ;"+`transform: translateX(${r.isRight?"":"-"}35px) ;`+(o?"box-shadow: -8px 13px 25px 0 "+(/\b(shadow|on)\b/gi.test(o)?"gray":o):"")+"}.notif-close-btn { 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[r.quadrant].push(r.id),localStorage.notifyProps=JSON.stringify(c),r.style.top=r.isTop?23..toString()+"px":"",r.style.bottom=r.isTop?"":23..toString()+"px",r.style.right=r.isRight?27..toString()+"px":"",r.style.left=r.isRight?"":27..toString()+"px";s=c.queue[r.quadrant];if(1<s.length)try{for(const p of s.slice(0,-1)){var l=document.getElementById(p),u=l.style.top?"top":"bottom",d=+/\d+/.exec(l.style[u])[0]+5+l.getBoundingClientRect().height;l.style[u]=d+"px"}}catch(e){}setTimeout(()=>{r.style.opacity=chatgpt.isDarkMode()?.8:.67,r.style.transform="translateX(0)",r.style.transition="transform 0.15s ease, opacity 0.15s ease"},10);e=()=>{r.style.animation="notif-zoom-fade-out 0.3s ease-out",clearTimeout(g)};const g=setTimeout(e,1e3*(n<.3?0:n-.3));a.addEventListener("click",e,{once:!0}),r.addEventListener("animationend",()=>{r.remove(),(c=JSON.parse(localStorage.notifyProps)).queue[r.quadrant].shift(),localStorage.notifyProps=JSON.stringify(c)},{once:!0})},obfuscate:function(){chatgpt.code.obfuscate()},printAllFunctions:function(){const t={cmdPrompt:["#ff00ff","#00ff00"],objName:["#0611e9","#f9ee16"],methodName:["#005aff","#ffa500"],entryType:["#467e06","#b981f9"],srcMethod:["#ff0000","#00ffff"]};Object.keys(t).forEach(e=>{t[e][1]=t[e][1]||"#"+(16777215^Number("0x1"+t[e][0].replace(/^#/,""))).toString(16).substring(1).toUpperCase()});var e=[];for(const c in this)if("function"==typeof this[c]){var n=!Object.keys(this).find(e=>Object.keys(this[e]).includes(this[c].name));e.push([n?"chatgpt":"other",c])}else if("object"==typeof this[c])for(const l in this[c])"function"==typeof this[c][l]&&e.push([c,l]);e.sort((e,t)=>e[0].localeCompare(t[0])||e[1].localeCompare(t[1]));var o=window.matchMedia("(prefers-color-scheme: dark)").matches,r="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(const u of e){var a=/chatgpt|other/.test(u[0]),s="chatgpt"==u[0]?this[u[1]].name:"other"!==u[0]?u[0]+"."+u[1]:Object.keys(this).find(e=>Object.keys(this[e]).includes(this[u[1]].name))+"."+this[u[1]].name,i="AsyncFunction"==this[u[1]]?.constructor.name;console.log("%c>> %c"+(a?"":u[0]+".%c")+u[1]+" - https://chatgptjs.org/userguide/"+/(?:.*\.)?(.*)/.exec(s)[1].toLowerCase()+(i?"-async":"")+"\n%c[%c"+("chatgpt"==u[0]&&u[1]==this[u[1]].name||!a?"Function":"Alias of")+"%c: %c"+s+"%c]",r+"font-weight: bold ; color:"+t.cmdPrompt[+o],r+"font-weight: bold ;color:"+t[a?"methodName":"objName"][+o],r+"font-weight: "+(a?"initial":"bold")+";color:"+(a?"initial":t.methodName[+o]),r+"font-weight: "+(a?"bold":"initial")+";color:"+(a?t.entryType[+o]:"initial"),r+"font-weight: "+(a?"initial":"bold")+";color:"+(a?"initial":t.entryType[+o]),r+(a?"font-style: italic":"font-weight: initial")+";color:"+(a?t.srcMethod[+o]:"initial"),r+(a?"font-weight: initial":"font-style: italic")+";color:"+(a?"initial":t.srcMethod[+o]),a?"":r+"color: initial ; font-weight: initial")}},randomFloat:function(){return(window.crypto||window.msCrypto)?.getRandomValues(new Uint32Array(1))[0]/4294967295||Math.random()},refactor:function(){chatgpt.code.refactor()},regenerate:function(){chatgpt.response.regenerate()},renderHTML:function(e){var t=/<([a-z\d]+)\b([^>]*)>([\s\S]*?)<\/\1>/g,n=/(\S+)=['"]?((?:.(?!['"]?\s+\S+=|[>']))+.)['"]?/g,o=e.childNodes;this.renderHTML.preWrapSet||(e.style.whiteSpace="pre-wrap",this.renderHTML.preWrapSet=!0,setTimeout(()=>{this.renderHTML.preWrapSet=!1},100));for(const i of o)if(i.nodeType==Node.TEXT_NODE){var r=i.nodeValue,a=Array.from(r.matchAll(t));if(0<a.length){const c=a[0],[l,u,d,g]=c.slice(0,4),p=document.createElement(u);p.textContent=g;Array.from(d.matchAll(n)).forEach(e=>{var t=e[1],e=e[2].replace(/['"]/g,"");p.setAttribute(t,e)});var a=this.renderHTML(p),s=document.createTextNode(r.substring(0,c.index)),r=document.createTextNode(r.substring(c.index+l.length));e.replaceChild(s,i),e.insertBefore(a,s.nextSibling),e.insertBefore(r,a.nextSibling)}}else i.nodeType==Node.ELEMENT_NODE&&this.renderHTML(i);return e},resend:async function(){chatgpt.send(await chatgpt.getChatData("latest","msg","user","latest"))},response:{get:function(){return(window.location.href.startsWith("https://chatgpt.com/c/")?this.getFromDOM:this.getFromAPI).apply(null,arguments)},getFromAPI:function(e,t){return e=e||"latest",t=t||"latest",chatgpt.getChatData(e,"msg","chatgpt",t)},getFromDOM:function(e){var t=document.querySelectorAll('div[data-testid*="conversation-turn"]:nth-child(odd)'),n=e.toString().toLowerCase();let o="";return o=t.length?(o=(/last|final/.test(n)?t[t.length-1]:t[(Number.isInteger(e)?e:/^\d+/.test(n)?/^\d+/.exec(n)[0]:(/^(?:1|one|fir)(?:st)?$/.test(n)?1:/^(?:2|tw(?:o|en|el(?:ve|f))|seco)(?:nd|t[yi])?(?:e?th)?$/.test(n)?2:/^(?:3|th(?:ree|ir?))(?:rd|teen|t[yi])?(?:e?th)?$/.test(n)?3:/^(?:4|fou?r)(?:teen|t[yi])?(?:e?th)?$/.test(n)?4:/^(?:5|fi(?:ve|f))(?:teen|t[yi])?(?:e?th)?$/.test(n)?5:/^(?:6|six)(?:teen|t[yi])?(?:e?th)?$/.test(n)?6:/^(?:7|seven)(?:teen|t[yi])?(?:e?th)?$/.test(n)?7:/^(?:8|eight?)(?:teen|t[yi])?(?:e?th)?$/.test(n)?8:/^(?:9|nine?)(?:teen|t[yi])?(?:e?th)?$/.test(n)?9:/^(?:10|ten)(?:th)?$/.test(n)?10:1)*(/(ty|ieth)$/.test(n)?10:1)+(/teen(th)?$/.test(n)?10:0))-1]).textContent).replace(/^ChatGPT(?:ChatGPT)?/,""):o},getLast:function(){return chatgpt.getChatData("active","msg","chatgpt","latest")},regenerate:function(){var e=chatgpt.getRegenerateButton();e?e.click():console.error("Regenerate button not found!")},stopGenerating:function(){for(const e of document.querySelectorAll("form button svg"))if(e.querySelector('path[d*="2 0 0 1 2"]'))return void e.parentNode.click()}},reviewCode:function(){chatgpt.code.review()},scrollToBottom:function(){var e=chatgpt.getScrollToBottomButton();e?e.click():console.error("Scroll button not found!")},send:function(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!`);const n=document.querySelector("form textarea"),o=document.querySelector('form button[class*="bottom"]'),r=(n.value=e,n.dispatchEvent(new Event("input",{bubbles:!0})),setInterval(()=>{o?.hasAttribute("disabled")||("click"==t.toLowerCase()||chatgpt.browser.isMobile()?o.click():n.dispatchEvent(new KeyboardEvent("keydown",{keyCode:13,bubbles:!0})),clearInterval(r))},25))},sendInNewChat:function(e){if("string"!=typeof e)return console.error("Message must be a string!");for(const t of document.querySelectorAll("nav a"))if(/(new|clear) chat/i.test(t.text)){t.click();break}setTimeout(()=>{chatgpt.send(e)},500)},settings:{scheme:{isDark:function(){return document.documentElement.classList.contains("dark")},isLight:function(){return document.documentElement.classList.contains("light")},set:function(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 n=e;"system"==e&&(n=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),localStorage.setItem("theme",e),console.info(`Scheme set to ${e.toUpperCase()}.`),document.documentElement.classList.contains(n)||this.toggle()},toggle:function(){var[e,t]=this.isDark()?["dark","light"]:["light","dark"];document.documentElement.classList.replace(e,t),document.documentElement.style.colorScheme=t,localStorage.setItem("theme",t)}}},sentiment:async function(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:function(e){chatgpt.settings.scheme.set(e)},shareChat:function(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(n=>{chatgpt.getAccessToken().then(t=>{var r;r=t,new Promise((t,n)=>{const o=new XMLHttpRequest;chatgpt.getChatData(s).then(e=>{o.open("GET",endpoints.openAI.chat+"/"+e.id,!0),o.setRequestHeader("Content-Type","application/json"),o.setRequestHeader("Authorization","Bearer "+r),o.onload=()=>200!==o.status?n("🤖 chatgpt.js >> Request failed. Cannot retrieve chat node."):t(JSON.parse(o.responseText).current_node),o.send()})}).then(e=>{var r,a;r=t,a=e,new Promise((t,n)=>{const o=new XMLHttpRequest;chatgpt.getChatData(s).then(e=>{o.open("POST",endpoints.openAI.share_create,!0),o.setRequestHeader("Content-Type","application/json"),o.setRequestHeader("Authorization","Bearer "+r),o.onload=()=>200!==o.status?n("🤖 chatgpt.js >> Request failed. Cannot initialize share chat."):t(JSON.parse(o.responseText)),o.send(JSON.stringify({current_node_id:a,conversation_id:e.id,is_anonymous:!0}))})}).then(e=>{var o,r;o=t,r=e,new Promise((e,t)=>{const n=new XMLHttpRequest;n.open("PATCH",endpoints.openAI.share+"/"+r.share_id,!0),n.setRequestHeader("Content-Type","application/json"),n.setRequestHeader("Authorization","Bearer "+o),n.onload=()=>200!==n.status?t("🤖 chatgpt.js >> Request failed. Cannot share chat."):(console.info(`Chat shared at '${r.share_url}'`),e()),n.send(JSON.stringify({share_id:r.share_id,highlighted_message_id:r.highlighted_message_id,title:r.title,is_public:!0,is_visible:r.is_visible,is_anonymous:r.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)}]),n(e.share_url)})})})})})},showFooter:function(){chatgpt.getFooterDiv().style.display="revert"},showHeader:function(){chatgpt.getHeaderDiv().style.display="flex"},sidebar:{elements:[],observer:{},activateObserver:function(){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"});const n=document.querySelector("nav");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(!n.contains(e))try{n.insertBefore(e,n.querySelector("a").parentNode)}catch(e){console.error(e)}})})}),this.observer.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0})},append:function(e,t={}){var n=["button","dropdown"];if(!e||"string"!=typeof e)return console.error("🤖 chatgpt.js >> Please supply a valid string element name!");if(e=e.toLowerCase(),!n.includes(e))return console.error(`🤖 chatgpt.js >> Invalid element! Valid elements are [${n}]`);const o=document.createElement("dropdown"==e?"select":e);if(o.id=Math.floor(1e6*chatgpt.randomFloat())+Date.now(),"button"==e){o.textContent=t?.label&&"string"==typeof t.label?t.label:"chatgpt.js button";n=document.createElement("img");n.src=t?.icon&&"string"==typeof t.icon?t.icon:endpoints.assets+"/starters/chrome/extension/icons/icon128.png",n.width=18,o.insertBefore(n,o.firstChild),o.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,o.add(t)})}return"dropdown"==e&&(o.style.backgroundColor="var(--gray-900, rgb(32, 33, 35))"),this.elements.push(o),this.activateObserver(),document.body.setAttribute("data-chatgptjs","observer-trigger"),o.id},hide:function(){this.isOn()?this.toggle():console.info("Sidebar already hidden!")},show:function(){this.isOff()?this.toggle():console.info("Sidebar already shown!")},isOff:function(){return!this.isOn()},isOn:function(){var e=document.querySelector("#__next > div > div");return chatgpt.browser.isMobile()?"hidden"==document.documentElement.style.overflow:"hidden"!=e.style.visibility&&"0px"!=e.style.width},toggle:function(){var e=chatgpt.browser.isMobile(),t=!!document.documentElement.className.includes(" "),n=e?()=>!0:t?e=>0<e.querySelectorAll('svg path[d*="M8.857 3h6.286c1.084"]').length:e=>[...e.querySelectorAll("*")].some(e=>e.style.transform.includes("translateY"));for(const o of document.querySelectorAll(e?"#__next button":t?"nav button":"main button"))if(n(o))return void o.click()}},startNewChat:function(){try{this.getNewChatButton().click()}catch(e){console.error(e.message)}},stop:function(){this.response.stopGenerating()},suggest:async function(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:function(e,t={}){var n,{voice:o=2,pitch:r=2,speed:a=1.1}=t;if("string"!=typeof e)return console.error("Message must be a string!");for(n in t){var s=t[n];if("number"!=typeof s&&!/^\d+$/.test(s))return console.error(`Invalid ${n} index '${s}'. Must be a number!`)}try{var i=speechSynthesis.getVoices(),c=new SpeechSynthesisUtterance;c.text=e,c.voice=i[o],c.pitch=r,c.rate=a,speechSynthesis.speak(c)}catch(e){console.error(e)}},summarize:async function(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:function(){chatgpt.settings.scheme.toggle()},translate:async function(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:function(){chatgpt.code.unminify()},uuidv4:function(){let n=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{var t=(n+window.crypto.getRandomValues(new Uint32Array(1))[0]/(Math.pow(2,32)-1)*16)%16|0;return n=Math.floor(n/16),("x"==e?t:3&t|8).toString(16)})},writeCode:function(){chatgpt.code.write()}}),buttonActions=(chatgpt.scheme={...chatgpt.settings.scheme},["click","get"]),targetTypes=["button","link","div","response"];for(const Nd of buttonActions)chatgpt[Nd+"Button"]=function(n){var e=/^[.#]/.test(n)?document.querySelector(n):/send/i.test(n)?document.querySelector('form button[class*="bottom"]'):/scroll/i.test(n)?document.querySelector('button[class*="cursor"]'):function(){for(const e of document.querySelectorAll("button"))if(e.textContent.toLowerCase().includes(n.toLowerCase()))return e;for(const t of document.querySelectorAll("nav a"))if(t.textContent.toLowerCase().includes(n.toLowerCase()))return t}();if("click"!=Nd)return e;e.click()};const funcAliases=[["actAs","actas","act","become","persona","premadePrompt","preMadePrompt","prePrompt","preprompt","roleplay","rolePlay","rp"],["activateAutoRefresh","activateAutoRefresher","activateRefresher","activateSessionRefresher","autoRefresh","autoRefresher","autoRefreshSession","refresher","sessionRefresher"],["deactivateAutoRefresh","deactivateAutoRefresher","deactivateRefresher","deactivateSessionRefresher"],["detectLanguage","getLanguage"],["executeCode","codeExecute"],["exportChat","chatExport","export"],["getFooterDiv","getFooter"],["getHeaderDiv","getHeader"],["getLastPrompt","getLastQuery","getMyLastMsg","getMyLastQuery"],["getScrollToBottomButton","getScrollButton"],["getTextarea","getTextArea","getChatbox","getChatBox"],["isFullScreen","isFullscreen"],["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","stopGenerating"],["suggest","suggestion","recommend"],["toggleAutoRefresh","toggleAutoRefresher","toggleRefresher","toggleSessionRefresher"],["toggleScheme","toggleMode"],["translate","translation","translator"],["unminify","unminifyCode","codeUnminify"],["writeCode","codeWrite"]],synonyms=[["account","acct"],["activate","turnOn"],["analyze","check","evaluate","review"],["ask","send","submit"],["button","btn"],["chat","conversation","convo"],["data","details"],["deactivate","deActivate","turnOff"],["execute","interpret","interpreter","run"],["generating","generation"],["minify","uglify"],["refactor","rewrite"],["regenerate","regen"],["render","parse"],["reply","response"],["sentiment","attitude","emotion","feeling","opinion","perception"],["speak","say","speech","talk","tts"],["summarize","tldr"],["unminify","beautify","prettify","prettyPrint"]],camelCaser=e=>e.map((e,t)=>0===t||"s"==e?e:e.charAt(0).toUpperCase()+e.slice(1)).join("");for(const Wd in chatgpt){for(const Xd of funcAliases)if(Xd.includes(Wd))if(Xd.some(e=>e.includes("."))){const Zd=Xd.find(e=>e.includes(".")).split(".")[1];for(const _d of Xd)/^(\w+)/.exec(_d)[1]!==Wd&&(chatgpt[_d]=chatgpt[Wd][Zd])}else for(const a3 of Xd)a3!==Wd&&(chatgpt[a3]=chatgpt[Wd]);do{var newFunctionsCreated=!1;for(const b3 in chatgpt)if("function"==typeof chatgpt[b3]){const c3=b3.split(/(?=[A-Zs])/);for(const d3 of c3){const e3=[].concat(...synonyms.filter(e=>e.includes(d3.toLowerCase())).map(e=>e.filter(e=>e!==d3.toLowerCase())));for(const i3 of e3){const j3=camelCaser(c3.map(e=>e==d3?i3:e));chatgpt[j3]||(chatgpt[j3]=chatgpt[b3],newFunctionsCreated=!0)}}}}while(newFunctionsCreated)}const 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){}
|
|
13
|
+
`+o,new Promise(n=>{chatgpt.getAccessToken().then(async e=>{var t=await this.fetchData();return"user"==r?t.about_user_message+=o:"chatgpt"==r&&(t.about_model_message+=o),await this.sendRequest("POST",e,t),n()})})):console.error(`Invalid target ${r}. Valid targets are [${e}]`)):console.error("Please provide a valid target!")):console.error("Please provide an instruction")},clear:function(o){var e=["user","chatgpt"];return o?"string"!=typeof o?console.error("Target must be a string"):(o=o.toLowerCase(),e.includes(o)?new Promise(n=>{chatgpt.getAccessToken().then(async e=>{var t=await this.fetchData();return"user"==o?t.about_user_message="":"chatgpt"==o&&(t.about_model_message=""),await this.sendRequest("POST",e,t),n()})}):console.error(`Invalid target ${o}. Valid targets are [${e}]`)):console.error("Please provide a valid target!")},fetchData:function(){return new Promise(t=>{chatgpt.getAccessToken().then(async e=>t(await this.sendRequest("GET",e)))})},sendRequest:function(r,e,a){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(r=(r||"").trim().toUpperCase())&&t.includes(r)?e?a&&"object"!=typeof a?console.error(`Invalid body data type. Got ${typeof a}, expected object`):new Promise((t,n)=>{const o=new XMLHttpRequest;o.open(r,endpoints.openAI.instructions,!0),o.setRequestHeader("Accept-Language","en-US"),o.setRequestHeader("Authorization","Bearer "+e),"POST"==r&&o.setRequestHeader("Content-Type","application/json"),o.onload=()=>{var e=JSON.parse(o.responseText);return 422===o.status?n("🤖 chatgpt.js >> Character limit exceeded. Custom instructions can have a maximum length of 1500 characters."):403===o.status&&"content_policy"==e.detail.reason?n("🤖 chatgpt.js >> "+e.detail.description):200!==o.status?n("🤖 chatgpt.js >> Request failed. Cannot contact custom instructions endpoint."):(console.info("Custom instructions successfully contacted with method "+r),t(e||{}))},o.send(JSON.stringify(a)||"")}):console.error("Please provide a valid access token!"):console.error("Valid methods are "+t)},turnOff:function(){return new Promise(n=>{chatgpt.getAccessToken().then(async e=>{var t=await this.fetchData();return t.enabled=!1,await this.sendRequest("POST",e,t),n()})})},turnOn:function(){return new Promise(n=>{chatgpt.getAccessToken().then(async e=>{var t=await this.fetchData();return t.enabled=!0,await this.sendRequest("POST",e,t),n()})})},toggle:function(){return new Promise(t=>{this.fetchData().then(async e=>(await(e.enabled?this.turnOff():this.turnOn()),t()))})}},isChromium:function(){return chatgpt.browser.isChromium()},isDarkMode:function(){return document.documentElement.classList.toString().includes("dark")},isFirefox:function(){return chatgpt.browser.isFirefox()},isFullScreen:function(){return chatgpt.browser.isFullScreen()},isIdle:function(){return new Promise(t=>{!function e(){chatgpt.getRegenerateButton()?t(!0):setTimeout(e,100)}()})},isLoaded:function(){return new Promise(t=>{!function e(){chatgpt.getNewChatButton()?t(!0):setTimeout(e,100)}()})},isLightMode:function(){return document.documentElement.classList.toString().includes("light")},isMobileDevice:function(){return chatgpt.browser.isMobile()},logout:function(){window.location.href="https://chat.openai.com/auth/logout"},menu:{elements:[],addedEvent:!1,append:function(e,t={}){var n=["button","dropdown"];if(!e||"string"!=typeof e)return console.error("🤖 chatgpt.js >> Please supply a valid string element name!");if(e=e.toLowerCase(),!n.includes(e))return console.error(`🤖 chatgpt.js >> Invalid element! Valid elements are [${n}]`);const o=document.createElement("dropdown"==e?"select":"button"==e?"a":e);if(o.id=Math.floor(1e6*chatgpt.randomFloat())+Date.now(),"button"==e){o.textContent=t?.label&&"string"==typeof t.label?t.label:"chatgpt.js button";n=document.createElement("img");n.src=t?.icon&&"string"==typeof t.icon?t.icon:endpoints.assets+"/starters/chrome/extension/icons/icon128.png",n.width=18,o.insertBefore(n,o.firstChild),o.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!");o.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,o.add(t)})}const r=()=>{var e,t=document.querySelectorAll('a[role="menuitem"]');let n;for(e of t)if("Settings"==e.textContent){n=e.classList;break}const o=t[0].parentNode;chatgpt.menu.elements.forEach(e=>{if(e.setAttribute("class",n),!o.contains(e))try{o.insertBefore(e,o.firstChild)}catch(e){console.error(e)}})};this.elements.push(o);n=document.querySelector('nav button[id*="headless"]');return this.addedEvent||(n.addEventListener("click",()=>{setTimeout(r,25)}),this.addedEvent=!0),o.id},close:function(){try{document.querySelector('nav [id*="menu-button"][aria-expanded="true"]').click()}catch(e){console.error(e.message)}},open:function(){try{document.querySelector('nav [id*="menu-button"][aria-expanded="false"]').click()}catch(e){console.error(e.message)}}},minify:function(){chatgpt.code.minify()},notify:async function(e,t,n,o){n=n?+n:1.75;const r=document.createElement("div");r.id=Math.floor(1e6*chatgpt.randomFloat())+Date.now(),r.classList.add("chatgpt-notif"),r.innerText=e,document.body.append(r);var e=document.createElement("div"),a=(e.title="Dismiss",e.classList.add("notif-close-btn"),document.createElementNS("http://www.w3.org/2000/svg","svg")),s=(a.setAttribute("height","8px"),a.setAttribute("viewBox","0 0 14 14"),a.setAttribute("fill","none"),a.style.height=a.style.width="8px",document.createElementNS("http://www.w3.org/2000/svg","path"));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"),a.append(s),e.append(a),r.append(e),r.isTop=!t||!/low|bottom/i.test(t),r.isRight=!t||!/left/i.test(t),r.quadrant=(r.isTop?"top":"bottom")+(r.isRight?"Right":"Left");let i=document.querySelector("#chatgpt-notif-style"),c=((!i||parseInt(i.getAttribute("last-updated"),10)<20231110)&&(i||((i=document.createElement("style")).id="chatgpt-notif-style",i.setAttribute("last-updated",20231110..toString()),document.head.append(i)),i.innerText=".chatgpt-notif {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 ;-webkit-user-select: none ; -moz-user-select: none ; -ms-user-select: none ; user-select: none ;"+`transform: translateX(${r.isRight?"":"-"}35px) ;`+(o?"box-shadow: -8px 13px 25px 0 "+(/\b(shadow|on)\b/gi.test(o)?"gray":o):"")+"}.notif-close-btn { 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[r.quadrant].push(r.id),localStorage.notifyProps=JSON.stringify(c),r.style.top=r.isTop?23..toString()+"px":"",r.style.bottom=r.isTop?"":23..toString()+"px",r.style.right=r.isRight?27..toString()+"px":"",r.style.left=r.isRight?"":27..toString()+"px";s=c.queue[r.quadrant];if(1<s.length)try{for(const p of s.slice(0,-1)){var l=document.getElementById(p),u=l.style.top?"top":"bottom",d=+/\d+/.exec(l.style[u])[0]+5+l.getBoundingClientRect().height;l.style[u]=d+"px"}}catch(e){}setTimeout(()=>{r.style.opacity=chatgpt.isDarkMode()?.8:.67,r.style.transform="translateX(0)",r.style.transition="transform 0.15s ease, opacity 0.15s ease"},10);e=()=>{r.style.animation="notif-zoom-fade-out 0.3s ease-out",clearTimeout(g)};const g=setTimeout(e,1e3*(n<.3?0:n-.3));a.addEventListener("click",e,{once:!0}),r.addEventListener("animationend",()=>{r.remove(),(c=JSON.parse(localStorage.notifyProps)).queue[r.quadrant].shift(),localStorage.notifyProps=JSON.stringify(c)},{once:!0})},obfuscate:function(){chatgpt.code.obfuscate()},printAllFunctions:function(){const t={cmdPrompt:["#ff00ff","#00ff00"],objName:["#0611e9","#f9ee16"],methodName:["#005aff","#ffa500"],entryType:["#467e06","#b981f9"],srcMethod:["#ff0000","#00ffff"]};Object.keys(t).forEach(e=>{t[e][1]=t[e][1]||"#"+(16777215^Number("0x1"+t[e][0].replace(/^#/,""))).toString(16).substring(1).toUpperCase()});var e=[];for(const c in this)if("function"==typeof this[c]){var n=!Object.keys(this).find(e=>Object.keys(this[e]).includes(this[c].name));e.push([n?"chatgpt":"other",c])}else if("object"==typeof this[c])for(const l in this[c])"function"==typeof this[c][l]&&e.push([c,l]);e.sort((e,t)=>e[0].localeCompare(t[0])||e[1].localeCompare(t[1]));var o=window.matchMedia("(prefers-color-scheme: dark)").matches,r="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(const u of e){var a=/chatgpt|other/.test(u[0]),s="chatgpt"==u[0]?this[u[1]].name:"other"!==u[0]?u[0]+"."+u[1]:Object.keys(this).find(e=>Object.keys(this[e]).includes(this[u[1]].name))+"."+this[u[1]].name,i="AsyncFunction"==this[u[1]]?.constructor.name;console.log("%c>> %c"+(a?"":u[0]+".%c")+u[1]+" - https://chatgptjs.org/userguide/"+/(?:.*\.)?(.*)/.exec(s)[1].toLowerCase()+(i?"-async":"")+"\n%c[%c"+("chatgpt"==u[0]&&u[1]==this[u[1]].name||!a?"Function":"Alias of")+"%c: %c"+s+"%c]",r+"font-weight: bold ; color:"+t.cmdPrompt[+o],r+"font-weight: bold ;color:"+t[a?"methodName":"objName"][+o],r+"font-weight: "+(a?"initial":"bold")+";color:"+(a?"initial":t.methodName[+o]),r+"font-weight: "+(a?"bold":"initial")+";color:"+(a?t.entryType[+o]:"initial"),r+"font-weight: "+(a?"initial":"bold")+";color:"+(a?"initial":t.entryType[+o]),r+(a?"font-style: italic":"font-weight: initial")+";color:"+(a?t.srcMethod[+o]:"initial"),r+(a?"font-weight: initial":"font-style: italic")+";color:"+(a?"initial":t.srcMethod[+o]),a?"":r+"color: initial ; font-weight: initial")}},randomFloat:function(){return(window.crypto||window.msCrypto)?.getRandomValues(new Uint32Array(1))[0]/4294967295||Math.random()},refactor:function(){chatgpt.code.refactor()},regenerate:function(){chatgpt.response.regenerate()},renderHTML:function(e){var t=/<([a-z\d]+)\b([^>]*)>([\s\S]*?)<\/\1>/g,n=/(\S+)=['"]?((?:.(?!['"]?\s+\S+=|[>']))+.)['"]?/g,o=e.childNodes;this.renderHTML.preWrapSet||(e.style.whiteSpace="pre-wrap",this.renderHTML.preWrapSet=!0,setTimeout(()=>{this.renderHTML.preWrapSet=!1},100));for(const i of o)if(i.nodeType==Node.TEXT_NODE){var r=i.nodeValue,a=Array.from(r.matchAll(t));if(0<a.length){const c=a[0],[l,u,d,g]=c.slice(0,4),p=document.createElement(u);p.textContent=g;Array.from(d.matchAll(n)).forEach(e=>{var t=e[1],e=e[2].replace(/['"]/g,"");p.setAttribute(t,e)});var a=this.renderHTML(p),s=document.createTextNode(r.substring(0,c.index)),r=document.createTextNode(r.substring(c.index+l.length));e.replaceChild(s,i),e.insertBefore(a,s.nextSibling),e.insertBefore(r,a.nextSibling)}}else i.nodeType==Node.ELEMENT_NODE&&this.renderHTML(i);return e},resend:async function(){chatgpt.send(await chatgpt.getChatData("latest","msg","user","latest"))},response:{continue:function(){try{chatgpt.getContinueBtn().click()}catch(e){console.error(e.message)}},get:function(){return(window.location.href.startsWith("https://chatgpt.com/c/")?this.getFromDOM:this.getFromAPI).apply(null,arguments)},getFromAPI:function(e,t){return e=e||"latest",t=t||"latest",chatgpt.getChatData(e,"msg","chatgpt",t)},getFromDOM:function(e){var t=document.querySelectorAll('div[data-testid*="conversation-turn"]:nth-child(odd)'),n=e.toString().toLowerCase();let o="";return o=t.length?(o=(/last|final/.test(n)?t[t.length-1]:t[(Number.isInteger(e)?e:/^\d+/.test(n)?/^\d+/.exec(n)[0]:(/^(?:1|one|fir)(?:st)?$/.test(n)?1:/^(?:2|tw(?:o|en|el(?:ve|f))|seco)(?:nd|t[yi])?(?:e?th)?$/.test(n)?2:/^(?:3|th(?:ree|ir?))(?:rd|teen|t[yi])?(?:e?th)?$/.test(n)?3:/^(?:4|fou?r)(?:teen|t[yi])?(?:e?th)?$/.test(n)?4:/^(?:5|fi(?:ve|f))(?:teen|t[yi])?(?:e?th)?$/.test(n)?5:/^(?:6|six)(?:teen|t[yi])?(?:e?th)?$/.test(n)?6:/^(?:7|seven)(?:teen|t[yi])?(?:e?th)?$/.test(n)?7:/^(?:8|eight?)(?:teen|t[yi])?(?:e?th)?$/.test(n)?8:/^(?:9|nine?)(?:teen|t[yi])?(?:e?th)?$/.test(n)?9:/^(?:10|ten)(?:th)?$/.test(n)?10:1)*(/(ty|ieth)$/.test(n)?10:1)+(/teen(th)?$/.test(n)?10:0))-1]).textContent).replace(/^ChatGPT(?:ChatGPT)?/,""):o},getLast:function(){return chatgpt.getChatData("active","msg","chatgpt","latest")},regenerate:function(){try{chatgpt.getRegenerateBtn().click()}catch(e){console.error(e.message)}},stopGenerating:function(){try{chatgpt.getStopBtn().click()}catch(e){console.error(e.message)}}},reviewCode:function(){chatgpt.code.review()},scrollToBottom:function(){try{chatgpt.getScrollBtn().click()}catch(e){console.error(e.message)}},send:function(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!`);const n=document.querySelector("form textarea"),o=this.getSendButton();n.value=e,n.dispatchEvent(new Event("input",{bubbles:!0})),setTimeout(function e(){o?.hasAttribute("disabled")?setTimeout(e,25):"click"==t.toLowerCase()||chatgpt.browser.isMobile()?o.click():n.dispatchEvent(new KeyboardEvent("keydown",{keyCode:13,bubbles:!0}))},25)},sendInNewChat:function(e){if("string"!=typeof e)return console.error("Message must be a string!");for(const t of document.querySelectorAll("nav a"))if(/(new|clear) chat/i.test(t.text)){t.click();break}setTimeout(()=>{chatgpt.send(e)},500)},settings:{scheme:{isDark:function(){return document.documentElement.classList.contains("dark")},isLight:function(){return document.documentElement.classList.contains("light")},set:function(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 n=e;"system"==e&&(n=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),localStorage.setItem("theme",e),console.info(`Scheme set to ${e.toUpperCase()}.`),document.documentElement.classList.contains(n)||this.toggle()},toggle:function(){var[e,t]=this.isDark()?["dark","light"]:["light","dark"];document.documentElement.classList.replace(e,t),document.documentElement.style.colorScheme=t,localStorage.setItem("theme",t)}}},sentiment:async function(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:function(e){chatgpt.settings.scheme.set(e)},shareChat:function(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(n=>{chatgpt.getAccessToken().then(t=>{var r;r=t,new Promise((t,n)=>{const o=new XMLHttpRequest;chatgpt.getChatData(s).then(e=>{o.open("GET",endpoints.openAI.chat+"/"+e.id,!0),o.setRequestHeader("Content-Type","application/json"),o.setRequestHeader("Authorization","Bearer "+r),o.onload=()=>200!==o.status?n("🤖 chatgpt.js >> Request failed. Cannot retrieve chat node."):t(JSON.parse(o.responseText).current_node),o.send()})}).then(e=>{var r,a;r=t,a=e,new Promise((t,n)=>{const o=new XMLHttpRequest;chatgpt.getChatData(s).then(e=>{o.open("POST",endpoints.openAI.share_create,!0),o.setRequestHeader("Content-Type","application/json"),o.setRequestHeader("Authorization","Bearer "+r),o.onload=()=>200!==o.status?n("🤖 chatgpt.js >> Request failed. Cannot initialize share chat."):t(JSON.parse(o.responseText)),o.send(JSON.stringify({current_node_id:a,conversation_id:e.id,is_anonymous:!0}))})}).then(e=>{var o,r;o=t,r=e,new Promise((e,t)=>{const n=new XMLHttpRequest;n.open("PATCH",endpoints.openAI.share+"/"+r.share_id,!0),n.setRequestHeader("Content-Type","application/json"),n.setRequestHeader("Authorization","Bearer "+o),n.onload=()=>200!==n.status?t("🤖 chatgpt.js >> Request failed. Cannot share chat."):(console.info(`Chat shared at '${r.share_url}'`),e()),n.send(JSON.stringify({share_id:r.share_id,highlighted_message_id:r.highlighted_message_id,title:r.title,is_public:!0,is_visible:r.is_visible,is_anonymous:r.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)}]),n(e.share_url)})})})})})},showFooter:function(){chatgpt.getFooterDiv().style.display="revert"},showHeader:function(){chatgpt.getHeaderDiv().style.display="flex"},sidebar:{elements:[],observer:{},activateObserver:function(){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"});const n=document.querySelector("nav");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(!n.contains(e))try{n.insertBefore(e,n.querySelector("a").parentNode)}catch(e){console.error(e)}})})}),this.observer.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0})},append:function(e,t={}){var n=["button","dropdown"];if(!e||"string"!=typeof e)return console.error("🤖 chatgpt.js >> Please supply a valid string element name!");if(e=e.toLowerCase(),!n.includes(e))return console.error(`🤖 chatgpt.js >> Invalid element! Valid elements are [${n}]`);const o=document.createElement("dropdown"==e?"select":e);if(o.id=Math.floor(1e6*chatgpt.randomFloat())+Date.now(),"button"==e){o.textContent=t?.label&&"string"==typeof t.label?t.label:"chatgpt.js button";n=document.createElement("img");n.src=t?.icon&&"string"==typeof t.icon?t.icon:endpoints.assets+"/starters/chrome/extension/icons/icon128.png",n.width=18,o.insertBefore(n,o.firstChild),o.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,o.add(t)})}return"dropdown"==e&&(o.style.backgroundColor="var(--gray-900, rgb(32, 33, 35))"),this.elements.push(o),this.activateObserver(),document.body.setAttribute("data-chatgptjs","observer-trigger"),o.id},hide:function(){this.isOn()?this.toggle():console.info("Sidebar already hidden!")},show:function(){this.isOff()?this.toggle():console.info("Sidebar already shown!")},isOff:function(){return!this.isOn()},isOn:function(){var e=document.querySelector("#__next > div > div");return chatgpt.browser.isMobile()?"hidden"==document.documentElement.style.overflow:"hidden"!=e.style.visibility&&"0px"!=e.style.width},toggle:function(){var e=chatgpt.browser.isMobile(),t=!!document.documentElement.className.includes(" "),n=e?()=>!0:t?e=>0<e.querySelectorAll('svg path[d*="M8.857 3h6.286c1.084"]').length:e=>[...e.querySelectorAll("*")].some(e=>e.style.transform.includes("translateY"));for(const o of document.querySelectorAll(e?"#__next button":t?"nav button":"main button"))if(n(o))return void o.click()},isloaded:function(){return new Promise(t=>{!function e(){document.querySelector('nav a[href="/"]')?t(!0):setTimeout(e,100)}()})}},startNewChat:function(){try{this.getNewChatBtn().click()}catch(e){console.error(e.message)}},stop:function(){this.response.stopGenerating()},suggest:async function(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:function(e,t={}){var n,{voice:o=2,pitch:r=2,speed:a=1.1}=t;if("string"!=typeof e)return console.error("Message must be a string!");for(n in t){var s=t[n];if("number"!=typeof s&&!/^\d+$/.test(s))return console.error(`Invalid ${n} index '${s}'. Must be a number!`)}try{var i=speechSynthesis.getVoices(),c=new SpeechSynthesisUtterance;c.text=e,c.voice=i[o],c.pitch=r,c.rate=a,speechSynthesis.speak(c)}catch(e){console.error(e)}},summarize:async function(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:function(){chatgpt.settings.scheme.toggle()},translate:async function(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:function(){chatgpt.code.unminify()},uuidv4:function(){let n=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{var t=(n+window.crypto.getRandomValues(new Uint32Array(1))[0]/(Math.pow(2,32)-1)*16)%16|0;return n=Math.floor(n/16),("x"==e?t:3&t|8).toString(16)})},writeCode:function(){chatgpt.code.write()}}),buttonActions=(chatgpt.scheme={...chatgpt.settings.scheme},["click","get"]),targetTypes=["button","link","div","response"];for(const Td of buttonActions)chatgpt[Td+"Button"]=function(n){var e=/^[.#]/.test(n)?document.querySelector(n):/send/i.test(n)?document.querySelector('form button[class*="bottom"]'):/scroll/i.test(n)?document.querySelector('button[class*="cursor"]'):function(){for(const e of document.querySelectorAll("button"))if(e.textContent.toLowerCase().includes(n.toLowerCase()))return e;for(const t of document.querySelectorAll("nav a"))if(t.textContent.toLowerCase().includes(n.toLowerCase()))return t}();if("click"!=Td)return e;e.click()};const funcAliases=[["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"],["exportChat","chatExport","export"],["getFooterDiv","getFooter"],["getHeaderDiv","getHeader"],["getLastPrompt","getLastQuery","getMyLastMsg","getMyLastQuery"],["getContinueGeneratingButton","getContinueButton"],["getScrollToBottomButton","getScrollButton"],["getStopGeneratingButton","getStopButton"],["getTextarea","getTextArea","getChatbox","getChatBox"],["isFullScreen","isFullscreen"],["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"]],synonyms=[["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"],["generating","generation"],["minify","uglify"],["refactor","rewrite"],["regenerate","regen"],["render","parse"],["reply","response"],["sentiment","attitude","emotion","feeling","opinion","perception"],["speak","say","speech","talk","tts"],["summarize","tldr"],["unminify","beautify","prettify","prettyPrint"]],camelCaser=e=>e.map((e,t)=>0===t||"s"==e?e:e.charAt(0).toUpperCase()+e.slice(1)).join("");for(const a3 in chatgpt){for(const b3 of funcAliases)if(b3.includes(a3))if(b3.some(e=>e.includes("."))){const d3=b3.find(e=>e.includes(".")).split(".")[1];for(const f3 of b3)/^(\w+)/.exec(f3)[1]!==a3&&(chatgpt[f3]=chatgpt[a3][d3])}else for(const g3 of b3)g3!==a3&&(chatgpt[g3]=chatgpt[a3]);do{var newFunctionsCreated=!1;for(const h3 in chatgpt)if("function"==typeof chatgpt[h3]){const i3=h3.split(/(?=[A-Zs])/);for(const j3 of i3){const k3=[].concat(...synonyms.filter(e=>e.includes(j3.toLowerCase())).map(e=>e.filter(e=>e!==j3.toLowerCase())));for(const o3 of k3){const p3=camelCaser(i3.map(e=>e==j3?o3:e));chatgpt[p3]||(chatgpt[p3]=chatgpt[h3],newFunctionsCreated=!0)}}}}while(newFunctionsCreated)}const 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
|
@@ -45,12 +45,12 @@
|
|
|
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.9.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
|
|
|
@@ -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.9.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.9.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.9.0/dist/chatgpt.min.js
|
|
118
118
|
// ==/UserScript==
|
|
119
119
|
|
|
120
120
|
// Your code here...
|
|
@@ -189,7 +189,7 @@ 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.9.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
194
|
<img height=8px width="100%" src="https://media.chatgptjs.org/images/separators/gradient-aqua.png?78210a7">
|
|
195
195
|
|
|
@@ -301,6 +301,7 @@ This library exists thanks to code, translations, issues & ideas from the follow
|
|
|
301
301
|
[](https://github.com/thedayofcondor)
|
|
302
302
|
[](https://github.com/Luwa-Tech)
|
|
303
303
|
[](https://github.com/micz)
|
|
304
|
+
[](https://github.com/imranaalam)
|
|
304
305
|
[](https://github.com/dependabot)
|
|
305
306
|
<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
307
|
<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>
|
|
@@ -334,7 +335,7 @@ This library exists thanks to code, translations, issues & ideas from the follow
|
|
|
334
335
|
<div align="center">
|
|
335
336
|
|
|
336
337
|
**[Releases](https://github.com/KudoAI/chatgpt.js/releases)** /
|
|
337
|
-
[Userguide](https://github.com/KudoAI/chatgpt.js/blob/v2.
|
|
338
|
+
[Userguide](https://github.com/KudoAI/chatgpt.js/blob/v2.9.0/docs/USERGUIDE.md) /
|
|
338
339
|
[Discuss](https://github.com/KudoAI/chatgpt.js/discussions) /
|
|
339
340
|
<a href="#--------------------------------------------------------------------------------english---------简体中文---------繁體中文---------日本---------한국인---------हिंदी---------नेपाली---------deutsch---------español---------français---------italiano---------nederlands---------português---------việt----">Back to top ↑</a>
|
|
340
341
|
|
package/docs/USERGUIDE.md
CHANGED
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
- [getContinueGeneratingButton](#getcontinuegeneratingbutton)
|
|
76
76
|
- [getFooterDiv](#getfooterdiv)
|
|
77
77
|
- [getHeaderDiv](#getheaderdiv)
|
|
78
|
+
- [getNewChatButton](#getnewchatbutton)
|
|
78
79
|
- [getNewChatLink](#getnewchatlink)
|
|
79
80
|
- [getRegenerateButton](#getregeneratebutton)
|
|
80
81
|
- [getScrollToBottomButton](#getscrolltobottombutton)
|
|
@@ -117,6 +118,7 @@
|
|
|
117
118
|
- [open](#open)
|
|
118
119
|
- [close](#close)
|
|
119
120
|
- [response `api`](#response-api)
|
|
121
|
+
- [continue](#continue)
|
|
120
122
|
- [get](#get-1)
|
|
121
123
|
- [getFromAPI `async`](#getfromapi-async)
|
|
122
124
|
- [getFromDOM](#getfromdom)
|
|
@@ -136,6 +138,7 @@
|
|
|
136
138
|
- [hide](#hide)
|
|
137
139
|
- [show](#show)
|
|
138
140
|
- [toggle](#toggle-2)
|
|
141
|
+
- [isloaded](#isloaded-async-2)
|
|
139
142
|
|
|
140
143
|
# Importing the library
|
|
141
144
|
|
|
@@ -145,7 +148,7 @@
|
|
|
145
148
|
|
|
146
149
|
```js
|
|
147
150
|
(async () => {
|
|
148
|
-
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.
|
|
151
|
+
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.9.0/dist/chatgpt.min.js');
|
|
149
152
|
// Your code here...
|
|
150
153
|
})();
|
|
151
154
|
```
|
|
@@ -154,7 +157,7 @@
|
|
|
154
157
|
|
|
155
158
|
```js
|
|
156
159
|
var xhr = new XMLHttpRequest();
|
|
157
|
-
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.
|
|
160
|
+
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.9.0/dist/chatgpt.min.js');
|
|
158
161
|
xhr.onload = function () {
|
|
159
162
|
if (xhr.status === 200) {
|
|
160
163
|
var chatgptJS = document.createElement('script');
|
|
@@ -176,7 +179,7 @@ function yourCode() {
|
|
|
176
179
|
|
|
177
180
|
```js
|
|
178
181
|
...
|
|
179
|
-
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.
|
|
182
|
+
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.9.0/dist/chatgpt.min.js
|
|
180
183
|
// ==/UserScript==
|
|
181
184
|
|
|
182
185
|
// Your code here...
|
|
@@ -665,6 +668,8 @@ Example code:
|
|
|
665
668
|
|
|
666
669
|
### clearChats `async`
|
|
667
670
|
|
|
671
|
+
**Parameters**:
|
|
672
|
+
|
|
668
673
|
`method` (optional): The string `'api'` or `'dom'` representing the method to use.
|
|
669
674
|
|
|
670
675
|
> **Note** _The API method does not update DOM chat list (until session refresh)_
|
|
@@ -1109,9 +1114,20 @@ const headerDiv = chatgpt.getHeaderDiv();
|
|
|
1109
1114
|
headerDiv.style.display = none; // hide the header
|
|
1110
1115
|
```
|
|
1111
1116
|
|
|
1117
|
+
### getNewChatButton
|
|
1118
|
+
|
|
1119
|
+
Returns the sidebar button (w/ icon) that creates a new chat as an HTML element.
|
|
1120
|
+
|
|
1121
|
+
Example code:
|
|
1122
|
+
|
|
1123
|
+
```js
|
|
1124
|
+
const newChatBtn = chatgpt.getNewChatButton();
|
|
1125
|
+
newChatBtn.click();
|
|
1126
|
+
```
|
|
1127
|
+
|
|
1112
1128
|
### getNewChatLink
|
|
1113
1129
|
|
|
1114
|
-
Returns the
|
|
1130
|
+
Returns the sidebar link (w/ label) that creates a new chat as an HTML element.
|
|
1115
1131
|
|
|
1116
1132
|
Example code:
|
|
1117
1133
|
|
|
@@ -1638,6 +1654,16 @@ chatgpt.menu.close();
|
|
|
1638
1654
|
|
|
1639
1655
|
API related to ChatGPT's responses.
|
|
1640
1656
|
|
|
1657
|
+
### continue
|
|
1658
|
+
|
|
1659
|
+
Continues the generation of ChatGPT's cut-off response.
|
|
1660
|
+
|
|
1661
|
+
Example code:
|
|
1662
|
+
|
|
1663
|
+
```js
|
|
1664
|
+
chatgpt.response.continue();
|
|
1665
|
+
```
|
|
1666
|
+
|
|
1641
1667
|
### get
|
|
1642
1668
|
|
|
1643
1669
|
If it's a previously created chat, read [chatgpt.getResponseFromDOM](#getresponsefromdom)
|
|
@@ -1826,6 +1852,19 @@ Example code:
|
|
|
1826
1852
|
chatgpt.sidebar.toggle();
|
|
1827
1853
|
```
|
|
1828
1854
|
|
|
1855
|
+
### isLoaded `async`
|
|
1856
|
+
|
|
1857
|
+
Resolves a promise when the ChatGPT sidebar has finished loading.
|
|
1858
|
+
|
|
1859
|
+
Example code:
|
|
1860
|
+
|
|
1861
|
+
```js
|
|
1862
|
+
(async () => {
|
|
1863
|
+
await chatgpt.sidebar.isLoaded();
|
|
1864
|
+
console.log('ChatGPT sidebar has finished loading.');
|
|
1865
|
+
})();
|
|
1866
|
+
```
|
|
1867
|
+
|
|
1829
1868
|
<br>
|
|
1830
1869
|
<br>
|
|
1831
1870
|
|
package/package.json
CHANGED
|
@@ -8,11 +8,11 @@ const endpoints = {
|
|
|
8
8
|
assets: 'https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js',
|
|
9
9
|
openAI: {
|
|
10
10
|
session: 'https://chatgpt.com/api/auth/session',
|
|
11
|
-
chats: 'https://
|
|
12
|
-
chat: 'https://
|
|
13
|
-
share_create: 'https://
|
|
14
|
-
share: 'https://
|
|
15
|
-
instructions: 'https://
|
|
11
|
+
chats: 'https://chatgpt.com/backend-api/conversations',
|
|
12
|
+
chat: 'https://chatgpt.com/backend-api/conversation',
|
|
13
|
+
share_create: 'https://chatgpt.com/backend-api/share/create',
|
|
14
|
+
share: 'https://chatgpt.com/backend-api/share',
|
|
15
|
+
instructions: 'https://chatgpt.com/backend-api/user_system_messages'
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
|
|
@@ -383,21 +383,25 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
383
383
|
const validMethods = ['api', 'dom'];
|
|
384
384
|
method = (method || 'dom').trim().toLowerCase(); // set to 'dom' by default
|
|
385
385
|
if (method && !validMethods.includes(method))
|
|
386
|
-
return console.
|
|
386
|
+
return console.error(`Method argument must be one of: [${validMethods}]`);
|
|
387
387
|
|
|
388
388
|
if (method == 'dom') {
|
|
389
|
-
|
|
390
|
-
|
|
389
|
+
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
390
|
+
try {
|
|
391
|
+
chatgpt.menu.open(); await delay(10);
|
|
391
392
|
const settingsBtn = document.querySelector(
|
|
392
|
-
'a[role="menuitem"] svg path[d*="M12.003 10.5a1.5"]')
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
393
|
+
'a[role="menuitem"] svg path[d*="M12.003 10.5a1.5"]').parentNode.parentNode;
|
|
394
|
+
settingsBtn.click(); await delay(333);
|
|
395
|
+
const settingsBtns = document.querySelectorAll('[id*=radix] button'),
|
|
396
|
+
deleteBtn = settingsBtns[settingsBtns.length - 1];
|
|
397
|
+
deleteBtn.click(); await delay(10);
|
|
398
|
+
document.querySelector('button[class*="danger"').click(); // confirm clear
|
|
399
|
+
return console.info('Chats successfully cleared.');
|
|
400
|
+
} catch (err) {
|
|
401
|
+
console.error(err.message);
|
|
402
|
+
if (arguments.length == 0) {
|
|
403
|
+
console.info('Using backend API method instead.'); this.clearChats('api'); }
|
|
404
|
+
}
|
|
401
405
|
|
|
402
406
|
} else { // API method
|
|
403
407
|
// NOTE: DOM is not updated to reflect new empty chat list (until session refresh)
|
|
@@ -413,7 +417,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
413
417
|
console.info('Chats successfully cleared'); resolve();
|
|
414
418
|
};
|
|
415
419
|
xhr.send(JSON.stringify({ is_visible: false }));
|
|
416
|
-
}).catch(reject);
|
|
420
|
+
}).catch(err => reject(new Error(err.message)));
|
|
417
421
|
});
|
|
418
422
|
}
|
|
419
423
|
},
|
|
@@ -493,6 +497,8 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
493
497
|
}
|
|
494
498
|
},
|
|
495
499
|
|
|
500
|
+
continue: function() { this.response.continue(); },
|
|
501
|
+
|
|
496
502
|
detectLanguage: async function(text) {
|
|
497
503
|
if (!text) return console.error('Text argument not supplied. Pass some text!');
|
|
498
504
|
if (typeof text !== 'string') return console.error('Text argument must be a string!');
|
|
@@ -851,9 +857,9 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
851
857
|
getChatInput: function() { return chatgpt.getChatBox().value; },
|
|
852
858
|
|
|
853
859
|
getContinueGeneratingButton: function() {
|
|
854
|
-
for (const
|
|
855
|
-
if (
|
|
856
|
-
return
|
|
860
|
+
for (const formBtnSVG of document.querySelectorAll('form button svg')) {
|
|
861
|
+
if (formBtnSVG.querySelector('path[d*="M4.472 2.5a1"]'))
|
|
862
|
+
return formBtnSVG.parentNode.parentNode;
|
|
857
863
|
}},
|
|
858
864
|
|
|
859
865
|
getFooterDiv: function() { return document.querySelector('main form').parentNode.parentNode.nextElementSibling; },
|
|
@@ -895,7 +901,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
895
901
|
|
|
896
902
|
getStopGeneratingButton: function() {
|
|
897
903
|
for (const svg of document.querySelectorAll('form button svg')) {
|
|
898
|
-
if (svg.querySelector('path[d*="2 0 0 1 2"]'))
|
|
904
|
+
if (svg.querySelector('path[d*="2 0 0 1 2"], rect'))
|
|
899
905
|
return svg.parentNode;
|
|
900
906
|
}},
|
|
901
907
|
|
|
@@ -1048,10 +1054,11 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
1048
1054
|
|
|
1049
1055
|
isIdle: function() {
|
|
1050
1056
|
return new Promise(resolve => {
|
|
1051
|
-
|
|
1052
|
-
if (chatgpt.getRegenerateButton())
|
|
1053
|
-
|
|
1054
|
-
|
|
1057
|
+
(function checkIsIdle() {
|
|
1058
|
+
if (chatgpt.getRegenerateButton()) resolve(true);
|
|
1059
|
+
else setTimeout(checkIsIdle, 100);
|
|
1060
|
+
})();
|
|
1061
|
+
});},
|
|
1055
1062
|
|
|
1056
1063
|
isLoaded: function() {
|
|
1057
1064
|
return new Promise(resolve => {
|
|
@@ -1155,15 +1162,13 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
1155
1162
|
},
|
|
1156
1163
|
|
|
1157
1164
|
close: function() {
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
else { console.info('Menu already hidden!'); }
|
|
1165
|
+
try { document.querySelector('nav [id*="menu-button"][aria-expanded="true"]').click(); }
|
|
1166
|
+
catch (err) { console.error(err.message); }
|
|
1161
1167
|
},
|
|
1162
1168
|
|
|
1163
1169
|
open: function() {
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
else { console.info('Menu already open!'); }
|
|
1170
|
+
try { document.querySelector('nav [id*="menu-button"][aria-expanded="false"]').click(); }
|
|
1171
|
+
catch (err) { console.error(err.message); }
|
|
1167
1172
|
}
|
|
1168
1173
|
},
|
|
1169
1174
|
|
|
@@ -1410,6 +1415,8 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
1410
1415
|
resend: async function() { chatgpt.send(await chatgpt.getChatData('latest', 'msg', 'user', 'latest')); },
|
|
1411
1416
|
|
|
1412
1417
|
response: {
|
|
1418
|
+
continue: function() { try { chatgpt.getContinueBtn().click(); } catch (err) { console.error(err.message); }},
|
|
1419
|
+
|
|
1413
1420
|
get: function() {
|
|
1414
1421
|
// * Returns response via DOM by index arg if OpenAI chat page is active, otherwise uses API w/ following args:
|
|
1415
1422
|
// chatToGet = index|title|id of chat to get (defaults to latest if '' unpassed)
|
|
@@ -1467,41 +1474,26 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
1467
1474
|
},
|
|
1468
1475
|
|
|
1469
1476
|
getLast: function() { return chatgpt.getChatData('active', 'msg', 'chatgpt', 'latest'); },
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
const regenBtn = chatgpt.getRegenerateButton();
|
|
1473
|
-
if (regenBtn) regenBtn.click();
|
|
1474
|
-
else console.error('Regenerate button not found!');
|
|
1475
|
-
},
|
|
1476
|
-
|
|
1477
|
-
stopGenerating: function() {
|
|
1478
|
-
for (const svg of document.querySelectorAll('form button svg')) {
|
|
1479
|
-
if (svg.querySelector('path[d*="2 0 0 1 2"]')) {
|
|
1480
|
-
svg.parentNode.click(); return;
|
|
1481
|
-
}}}
|
|
1477
|
+
regenerate: function() { try { chatgpt.getRegenerateBtn().click(); } catch (err) { console.error(err.message); }},
|
|
1478
|
+
stopGenerating: function() { try { chatgpt.getStopBtn().click(); } catch (err) { console.error(err.message); }}
|
|
1482
1479
|
},
|
|
1483
1480
|
|
|
1484
1481
|
reviewCode: function() { chatgpt.code.review(); },
|
|
1485
|
-
|
|
1486
|
-
scrollToBottom: function() {
|
|
1487
|
-
const scrollBtn = chatgpt.getScrollToBottomButton();
|
|
1488
|
-
if (scrollBtn) scrollBtn.click();
|
|
1489
|
-
else console.error('Scroll button not found!');
|
|
1490
|
-
},
|
|
1482
|
+
scrollToBottom: function() { try { chatgpt.getScrollBtn().click(); } catch (err) { console.error(err.message); }},
|
|
1491
1483
|
|
|
1492
1484
|
send: function(msg, method='') {
|
|
1493
1485
|
for (let i = 0; i < arguments.length; i++) if (typeof arguments[i] !== 'string')
|
|
1494
1486
|
return console.error(`Argument ${ i + 1 } must be a string!`);
|
|
1495
1487
|
const textArea = document.querySelector('form textarea'),
|
|
1496
|
-
|
|
1488
|
+
sendBtn = this.getSendButton();
|
|
1497
1489
|
textArea.value = msg;
|
|
1498
1490
|
textArea.dispatchEvent(new Event('input', { bubbles: true })); // enable send button
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1491
|
+
|
|
1492
|
+
setTimeout(function delaySend() {
|
|
1493
|
+
if (!sendBtn?.hasAttribute('disabled')) { // send msg
|
|
1494
|
+
method.toLowerCase() == 'click' || chatgpt.browser.isMobile() ? sendBtn.click()
|
|
1502
1495
|
: textArea.dispatchEvent(new KeyboardEvent('keydown', { keyCode: 13, bubbles: true }));
|
|
1503
|
-
|
|
1504
|
-
}
|
|
1496
|
+
} else setTimeout(delaySend, 25);
|
|
1505
1497
|
}, 25);
|
|
1506
1498
|
},
|
|
1507
1499
|
|
|
@@ -1767,10 +1759,18 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
1767
1759
|
.some(child => child.style.transform.includes('translateY'));
|
|
1768
1760
|
for (const btn of document.querySelectorAll(navBtnSelector))
|
|
1769
1761
|
if (isToggleBtn(btn)) { btn.click(); return; }
|
|
1770
|
-
}
|
|
1762
|
+
},
|
|
1763
|
+
|
|
1764
|
+
isloaded: function() {
|
|
1765
|
+
return new Promise(resolve => {
|
|
1766
|
+
(function checkIsLoaded() {
|
|
1767
|
+
if (document.querySelector('nav a[href="/"]')) resolve(true);
|
|
1768
|
+
else setTimeout(checkIsLoaded, 100);
|
|
1769
|
+
})();
|
|
1770
|
+
});}
|
|
1771
1771
|
},
|
|
1772
1772
|
|
|
1773
|
-
startNewChat: function() { try { this.
|
|
1773
|
+
startNewChat: function() { try { this.getNewChatBtn().click(); } catch (err) { console.error(err.message); }},
|
|
1774
1774
|
stop: function() { this.response.stopGenerating(); },
|
|
1775
1775
|
|
|
1776
1776
|
suggest: async function(ideaType, details) {
|
|
@@ -1875,6 +1875,7 @@ const funcAliases = [
|
|
|
1875
1875
|
['actAs', 'actas', 'act', 'become', 'persona', 'premadePrompt', 'preMadePrompt', 'prePrompt', 'preprompt', 'roleplay', 'rolePlay', 'rp'],
|
|
1876
1876
|
['activateAutoRefresh', 'activateAutoRefresher', 'activateRefresher', 'activateSessionRefresher',
|
|
1877
1877
|
'autoRefresh', 'autoRefresher', 'autoRefreshSession', 'refresher', 'sessionRefresher'],
|
|
1878
|
+
['continue', 'continueChat', 'continueGenerating', 'continueResponse'],
|
|
1878
1879
|
['deactivateAutoRefresh', 'deactivateAutoRefresher', 'deactivateRefresher', 'deactivateSessionRefresher'],
|
|
1879
1880
|
['detectLanguage', 'getLanguage'],
|
|
1880
1881
|
['executeCode', 'codeExecute'],
|
|
@@ -1882,7 +1883,9 @@ const funcAliases = [
|
|
|
1882
1883
|
['getFooterDiv', 'getFooter'],
|
|
1883
1884
|
['getHeaderDiv', 'getHeader'],
|
|
1884
1885
|
['getLastPrompt', 'getLastQuery', 'getMyLastMsg', 'getMyLastQuery'],
|
|
1886
|
+
['getContinueGeneratingButton', 'getContinueButton'],
|
|
1885
1887
|
['getScrollToBottomButton', 'getScrollButton'],
|
|
1888
|
+
['getStopGeneratingButton', 'getStopButton'],
|
|
1886
1889
|
['getTextarea', 'getTextArea', 'getChatbox', 'getChatBox'],
|
|
1887
1890
|
['isFullScreen', 'isFullscreen'],
|
|
1888
1891
|
['logOut', 'logout', 'logOff', 'logoff', 'signOut', 'signout', 'signOff', 'signoff'],
|
|
@@ -1899,7 +1902,7 @@ const funcAliases = [
|
|
|
1899
1902
|
['sendInNewChat', 'sendNewChat'],
|
|
1900
1903
|
['sentiment', 'analyzeSentiment', 'sentimentAnalysis'],
|
|
1901
1904
|
['startNewChat', 'new', 'newChat'],
|
|
1902
|
-
['stop', 'stopGenerating'],
|
|
1905
|
+
['stop', 'stopChat', 'stopGenerating', 'stopResponse'],
|
|
1903
1906
|
['suggest', 'suggestion', 'recommend'],
|
|
1904
1907
|
['toggleAutoRefresh', 'toggleAutoRefresher', 'toggleRefresher', 'toggleSessionRefresher'],
|
|
1905
1908
|
['toggleScheme', 'toggleMode'],
|
|
@@ -1913,7 +1916,10 @@ const synonyms = [
|
|
|
1913
1916
|
['analyze', 'check', 'evaluate', 'review'],
|
|
1914
1917
|
['ask', 'send', 'submit'],
|
|
1915
1918
|
['button', 'btn'],
|
|
1919
|
+
['continue', 'resume'],
|
|
1920
|
+
['chats', 'history'],
|
|
1916
1921
|
['chat', 'conversation', 'convo'],
|
|
1922
|
+
['clear', 'delete', 'remove'],
|
|
1917
1923
|
['data', 'details'],
|
|
1918
1924
|
['deactivate', 'deActivate', 'turnOff'],
|
|
1919
1925
|
['execute', 'interpret', 'interpreter', 'run'],
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
// @description A Greasemonkey template to start using chatgpt.js like a boss
|
|
4
4
|
// @author chatgpt.js
|
|
5
5
|
// @namespace https://chatgpt.js.org
|
|
6
|
-
// @version 2024.5.
|
|
6
|
+
// @version 2024.5.17
|
|
7
7
|
// @license MIT
|
|
8
|
-
// @match
|
|
8
|
+
// @match *://chatgpt.com/*
|
|
9
|
+
// @match *://chat.openai.com/*
|
|
9
10
|
// @icon https://raw.githubusercontent.com/KudoAI/chatgpt.js-greasemonkey-starter/main/media/images/icons/robot/icon48.png
|
|
10
11
|
// @icon64 https://raw.githubusercontent.com/KudoAI/chatgpt.js-greasemonkey-starter/main/media/images/icons/robot/icon64.png
|
|
11
|
-
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.
|
|
12
|
+
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.9.0/dist/chatgpt.min.js
|
|
12
13
|
// @grant GM_getValue
|
|
13
14
|
// @grant GM_setValue
|
|
14
15
|
// @noframes
|