@kudoai/chatgpt.js 3.3.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/chatgpt.js +6 -21
- package/dist/chatgpt.min.js +3 -3
- package/docs/README.md +7 -7
- package/docs/USERGUIDE.md +69 -69
- package/package.json +1 -1
- package/starters/chrome/extension/lib/chatgpt.js +6 -21
- package/starters/chrome/extension/manifest.json +1 -1
- package/starters/greasemonkey/chatgpt.js-greasemonkey-starter.user.js +4 -4
package/README.md
CHANGED
|
@@ -45,8 +45,8 @@
|
|
|
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
|
-

|
|
49
|
+
[](https://github.com/KudoAI/chatgpt.js/tree/v3.3.1/dist/chatgpt.min.js)
|
|
50
50
|
[](https://www.codefactor.io/repository/github/kudoai/chatgpt.js)
|
|
51
51
|
[](https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=kudoai_chatgpt.js)
|
|
52
52
|
[](https://github.com/sindresorhus/awesome-chatgpt#javascript)
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
|
|
85
85
|
```js
|
|
86
86
|
(async () => {
|
|
87
|
-
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.
|
|
87
|
+
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.1/dist/chatgpt.min.js');
|
|
88
88
|
// Your code here...
|
|
89
89
|
})();
|
|
90
90
|
```
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
|
|
94
94
|
```js
|
|
95
95
|
var xhr = new XMLHttpRequest();
|
|
96
|
-
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.
|
|
96
|
+
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.1/dist/chatgpt.min.js');
|
|
97
97
|
xhr.onload = function () {
|
|
98
98
|
if (xhr.status === 200) {
|
|
99
99
|
var chatgptJS = document.createElement('script');
|
|
@@ -115,7 +115,7 @@ function yourCode() {
|
|
|
115
115
|
|
|
116
116
|
```js
|
|
117
117
|
...
|
|
118
|
-
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.
|
|
118
|
+
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.1/dist/chatgpt.min.js
|
|
119
119
|
// ==/UserScript==
|
|
120
120
|
|
|
121
121
|
// Your code here...
|
|
@@ -190,7 +190,7 @@ chatgpt.get('reply', 'last');
|
|
|
190
190
|
|
|
191
191
|
Each call equally fetches the last response. If you think it works, it probably will... so just type it!
|
|
192
192
|
|
|
193
|
-
If it didn't, check out the extended [userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.3.
|
|
193
|
+
If it didn't, check out the extended [userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.3.1/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!
|
|
194
194
|
|
|
195
195
|
<img height=8px width="100%" src="https://media.chatgptjs.org/images/separators/gradient-aqua.png?78210a7">
|
|
196
196
|
|
|
@@ -360,7 +360,7 @@ This library exists thanks to code, translations, issues & ideas from the follow
|
|
|
360
360
|
<div align="center">
|
|
361
361
|
|
|
362
362
|
**[Releases](https://github.com/KudoAI/chatgpt.js/releases)** /
|
|
363
|
-
[Userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.3.
|
|
363
|
+
[Userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.3.1/docs/USERGUIDE.md) /
|
|
364
364
|
[Discuss](https://github.com/KudoAI/chatgpt.js/discussions) /
|
|
365
365
|
<a href="#--------------------------------------------------------------------------------english---------简体中文---------繁體中文---------日本---------한국인---------हिंदी---------नेपाली---------deutsch---------español---------français---------italiano---------nederlands---------português---------việt----">Back to top ↑</a>
|
|
366
366
|
|
package/chatgpt.js
CHANGED
|
@@ -883,13 +883,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
883
883
|
},
|
|
884
884
|
|
|
885
885
|
getChatInput() { return chatgpt.getChatBox().value; },
|
|
886
|
-
|
|
887
|
-
getContinueGeneratingButton() {
|
|
888
|
-
for (const formBtnSVG of document.querySelectorAll('form button svg')) {
|
|
889
|
-
if (formBtnSVG.querySelector('path[d*="M4.472 2.5a1"]'))
|
|
890
|
-
return formBtnSVG.parentNode.parentNode;
|
|
891
|
-
}},
|
|
892
|
-
|
|
886
|
+
getContinueButton() { return document.querySelector('button:has([d^="M4.47189"])'); },
|
|
893
887
|
getFooterDiv() { return chatgpt.footer.get(); },
|
|
894
888
|
getHeaderDiv() { return chatgpt.header.get(); },
|
|
895
889
|
getLastPrompt() { return chatgpt.getChatData('active', 'msg', 'user', 'latest'); },
|
|
@@ -901,12 +895,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
901
895
|
},
|
|
902
896
|
|
|
903
897
|
getNewChatLink() { return document.querySelector('nav a[href="/"]'); },
|
|
904
|
-
|
|
905
|
-
getRegenerateButton() {
|
|
906
|
-
for (const mainSVG of document.querySelectorAll('main svg')) {
|
|
907
|
-
if (mainSVG.querySelector('path[d^="M3.06957"]')) // regen icon found
|
|
908
|
-
return mainSVG.parentNode;
|
|
909
|
-
}},
|
|
898
|
+
getRegenerateButton() { return document.querySelector('button:has([d^="M3.06957"])'); },
|
|
910
899
|
|
|
911
900
|
getResponse() {
|
|
912
901
|
// * Returns response via DOM by index arg if OpenAI chat page is active, otherwise uses API w/ following args:
|
|
@@ -926,11 +915,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
926
915
|
|| document.querySelector('path[d*="M15.192 8.906a1.143"]')?.parentNode.parentNode; // post-GPT-4o
|
|
927
916
|
},
|
|
928
917
|
|
|
929
|
-
|
|
930
|
-
for (const svg of document.querySelectorAll('form button svg')) {
|
|
931
|
-
if (svg.querySelector('path[d*="2 0 0 1 2"], rect'))
|
|
932
|
-
return svg.parentNode;
|
|
933
|
-
}},
|
|
918
|
+
getStopButton() { return document.querySelector('button:has([d*="2 0 0 1 2"], rect)'); },
|
|
934
919
|
|
|
935
920
|
getUserLanguage() {
|
|
936
921
|
return navigator.languages[0] || navigator.language || navigator.browserLanguage ||
|
|
@@ -1804,7 +1789,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
1804
1789
|
isOff() { return !this.isOn(); },
|
|
1805
1790
|
isOn() {
|
|
1806
1791
|
const sidebar = (() => {
|
|
1807
|
-
return chatgpt.sidebar.exists() ? document.querySelector('
|
|
1792
|
+
return chatgpt.sidebar.exists() ? document.querySelector('[class*="sidebar"]') : null; })();
|
|
1808
1793
|
if (!sidebar) { console.error('Sidebar element not found!'); return false; }
|
|
1809
1794
|
else return chatgpt.browser.isMobile() ?
|
|
1810
1795
|
document.documentElement.style.overflow == 'hidden'
|
|
@@ -1948,9 +1933,9 @@ const cjsFuncAliases = [
|
|
|
1948
1933
|
['getFooterDiv', 'getFooter'],
|
|
1949
1934
|
['getHeaderDiv', 'getHeader'],
|
|
1950
1935
|
['getLastPrompt', 'getLastQuery', 'getMyLastMsg', 'getMyLastQuery'],
|
|
1951
|
-
['
|
|
1936
|
+
['getContinueButton', 'getContinueGeneratingButton'],
|
|
1952
1937
|
['getScrollToBottomButton', 'getScrollButton'],
|
|
1953
|
-
['
|
|
1938
|
+
['getStopButton', 'getStopGeneratingButton'],
|
|
1954
1939
|
['getTextarea', 'getTextArea', 'getChatbar', 'getChatBar', 'getChatbox', 'getChatBox'],
|
|
1955
1940
|
['isFullScreen', 'isFullscreen', 'isfullscreen'],
|
|
1956
1941
|
['isLoaded', 'isloaded'],
|
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
|
-
localStorage.alertQueue=JSON.stringify([]),localStorage.notifyProps=JSON.stringify({queue:{topRight:[],bottomRight:[],bottomLeft:[],topLeft:[]}});let chatgpt={openAIaccessToken:{},endpoints:{assets:"https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@8279d328a657ca9d7cf815720c1428dd4c3139a5",openAI:{session:"https://chatgpt.com/api/auth/session",chats:"https://chatgpt.com/backend-api/conversations",chat:"https://chatgpt.com/backend-api/conversation",share_create:"https://chatgpt.com/backend-api/share/create",share:"https://chatgpt.com/backend-api/share",instructions:"https://chatgpt.com/backend-api/user_system_messages"}},actAs(s){return new Promise((o,a)=>{let n=new XMLHttpRequest;n.open("GET","https://raw.githubusercontent.com/KudoAI/chat-prompts/main/dist/personas.min.json",!0),n.send(),n.onload=()=>{if(200!==n.status)return a("🤖 chatgpt.js >> Request failed. Cannot retrieve prompts data.");var e=JSON.parse(n.responseText).personas;if(s){var t=e.find(e=>e.title.toLowerCase()==s.toLowerCase());if(!t)return a(`🤖 chatgpt.js >> Persona '${s}' was not found!`);chatgpt.send(t.prompt,"click"),console.info(`Loading ${s} persona...`),chatgpt.isIdle().then(()=>{console.info("Persona activated!")})}else{console.log("\n%c🤖 chatgpt.js personas\n","font-family: sans-serif ; font-size: xxx-large ; font-weight: bold");for(var r of e)console.log("%c"+r.title,"font-family: monospace ; font-size: larger ;")}return o()}})},activateDarkMode(){document.documentElement.classList.replace("light","dark"),document.documentElement.style.colorScheme="dark",localStorage.setItem("theme","dark")},activateLightMode(){document.documentElement.classList.replace("dark","light"),document.documentElement.style.colorScheme="light",localStorage.setItem("theme","light")},alert(r,o,e,a,t){let n=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"),d=document.createElement("p");var g=20231203;let u=document.querySelector("#chatgpt-modal-style"),p=((!u||parseInt(u.getAttribute("last-updated"),10)<g)&&(u||((u=document.createElement("style")).id="chatgpt-modal-style",u.setAttribute("last-updated",g.toString()),document.head.append(u)),u.innerText=".no-mobile-tap-outline { outline: none ; -webkit-tap-highlight-color: transparent }.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"==n?"black":"white"} ;`+("dark"!=n?"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"==n?"#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"==n?"white":"black"}}`+".primary-modal-btn {"+`border: 1px solid ${"dark"==n?"white":"black"} ;`+`background: ${"dark"==n?"white":"black"} ;`+`color: ${"dark"==n?"black":"white"}}`+".chatgpt-modal button:hover { color: #3d5d71 ; border-color: #6d9cb9 ;background-color: "+("dark"==n?"#00cfff":"#9cdaff")+";box-shadow: 2px 1px "+("dark"==n?"54px #00cfff":"30px #9cdaff")+"}.modal-close-btn {cursor: pointer ; width: 29px ; height: 29px ; border-radius: 17px ;float: right ; position: relative ; right: -6px ; top: -5px }.modal-close-btn svg { margin: 10px }"+`.modal-close-btn:hover { background-color: #f2f2f2${"dark"==n?"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"==n?"#e1e1e1":"#1e1e1e"}}`+'.chatgpt-modal input[type="checkbox"] { transform: scale(0.7) ;'+`border: 1px solid ${"dark"==n?"white":"black"}}`+'.chatgpt-modal input[type="checkbox"]:checked {'+`border: 1px solid ${"dark"==n?"white":"black"} ;`+'background-color: black ; position: inherit }.chatgpt-modal input[type="checkbox"]:focus { outline: none ; box-shadow: none }'),l.innerText=r||"",d.innerText=o||"",chatgpt.renderHTML(d),document.createElement("div"));p.classList.add("modal-buttons","no-mobile-tap-outline"),e&&(e=Array.isArray(e)?e:[e]).forEach(e=>{var t=document.createElement("button");t.textContent=e.name.replace(/[_-]\w/g,e=>e.slice(1).toUpperCase()).replace(/([A-Z])/g," $1").replace(/^\w/,e=>e.toUpperCase()),t.onclick=()=>{y(),e()},p.insertBefore(t,p.firstChild)});g=document.createElement("button"),g.textContent=e?"Dismiss":"OK",p.insertBefore(g,p.firstChild),p.lastChild.classList.add("primary-modal-btn"),r=document.createElement("div");if(a){r.classList.add("checkbox-group");let e=a,t=document.createElement("input");t.type="checkbox",t.onchange=e;o=document.createElement("label");o.onclick=()=>{t.checked=!t.checked,e()},o.textContent=e.name.charAt(0).toUpperCase()+e.name.slice(1).replace(/([A-Z])/g,(e,t)=>" "+t.toLowerCase()).replace(/\b(\w+)nt\b/gi,"$1n't").trim(),r.append(t),r.append(o)}e=document.createElement("div"),e.title="Close",e.classList.add("modal-close-btn","no-mobile-tap-outline"),a=document.createElementNS("http://www.w3.org/2000/svg","svg"),a.setAttribute("height","10px"),a.setAttribute("viewBox","0 0 14 14"),a.setAttribute("fill","none"),o=document.createElementNS("http://www.w3.org/2000/svg","path");o.setAttribute("fill-rule","evenodd"),o.setAttribute("clip-rule","evenodd"),o.setAttribute("fill",chatgpt.isDarkMode()?"white":"black"),o.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(o),e.append(a),[e,l,d,p,r].forEach(e=>{c.append(e)}),c.style.width=`${t||458}px`,i.append(c),document.body.append(i);let h=JSON.parse(localStorage.alertQueue),m=(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"==n?.62:.1})`,i.classList.add("animated")},100)),e=>{(e.target==e.currentTarget||e.target instanceof SVGPathElement)&&y()}),f=e=>{if([" ","Spacebar","Enter","Return","Escape","Esc"].includes(e.key)||[32,13,27].includes(e.keyCode))for(var t of h){var t=document.getElementById(t);if(t&&"none"!==t.style.display)return void(e.key.includes("Esc")||27==e.keyCode?y():([" ","Spacebar","Enter","Return"].includes(e.key)||[32,13].includes(e.keyCode))&&(t=t.querySelector(".modal-buttons").lastChild)&&(t.click(),e.preventDefault()))}},y=([i,e,a,g].forEach(e=>e.onclick=m),document.addEventListener("keydown",f),()=>{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),document.removeEventListener("keydown",f),0<h.length){let e=document.getElementById(h[0]);setTimeout(()=>{e.style.display="",setTimeout(()=>{e.classList.add("animated")},100)},500)}},50)});return i.id},async askAndGetReply(e){return chatgpt.send(e),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},autoRefresh:{activate(e){if(this.isActive)console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already active!");else{let r=this,o=(this.toggle.refreshFrame(),t=>{var e=Math.max(2,Math.floor(21*chatgpt.randomFloat()-10));r.isActive=setTimeout(()=>{var e=document.querySelector('script[src*="_ssgManifest.js"]');e&&(document.querySelector("#refresh-frame").src=e.src+"?"+Date.now(),console.log("↻ ChatGPT >> ["+r.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(){this.isActive?(this.toggle.refreshFrame(),document.removeEventListener("visibilitychange",this.toggle.beacons),clearTimeout(this.isActive),this.isActive=null,console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh de-activated")):console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already inactive!")},nowTimeStamp(){var e=new Date,t=e.getHours()%12||12;let r=e.getMinutes(),o=e.getSeconds();r<10&&(r="0"+r),o<10&&(o="0"+o);e=e.getHours()<12?"AM":"PM";return t+":"+r+":"+o+" "+e},toggle:{beacons(){chatgpt.autoRefresh.beaconID?(clearInterval(chatgpt.autoRefresh.beaconID),chatgpt.autoRefresh.beaconID=null,console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacons de-activated")):(chatgpt.autoRefresh.beaconID=setInterval(()=>{navigator.sendBeacon("https://httpbin.org/post",new Uint8Array),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacon sent")},9e4),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacons activated"))},refreshFrame(){let e=document.querySelector("#refresh-frame");e?e.remove():(e=Object.assign(document.createElement("iframe"),{id:"refresh-frame",style:"display: none"}),document.head.prepend(e))}}},browser:{isLightMode(){return window.matchMedia?.("(prefers-color-scheme: light)")?.matches},isDarkMode(){return window.matchMedia?.("(prefers-color-scheme: dark)")?.matches},isChromium(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Chromium")},isChrome(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Chrome")},isEdge(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Edge")},isBrave(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Brave")},isFirefox(){return navigator.userAgent.includes("Firefox")},isFullScreen(){var e=navigator.userAgent;return e.includes("Chrome")?window.matchMedia("(display-mode: fullscreen)").matches:e.includes("Firefox")?window.fullScreen:/MSIE|rv:/.test(e)?document.msFullscreenElement:document.webkitIsFullScreen},isMobile(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}},async clearChats(){return new Promise((r,o)=>{chatgpt.getAccessToken().then(e=>{let t=new XMLHttpRequest;t.open("PATCH",chatgpt.endpoints.openAI.chats,!0),t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("Authorization","Bearer "+e),t.onload=()=>{if(200!==t.status)return o("🤖 chatgpt.js >> Request failed. Cannot clear chats.");console.info("Chats successfully cleared"),r()},t.send(JSON.stringify({is_visible:!1}))}).catch(e=>o(new Error(e.message)))})},code:{async execute(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Display the output as if you were terminal:\n\n"+e),console.info("Executing code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},extract(e){var t=e.match(/(?<=```.*\n)[\s\S]*?(?=```)/g);return t?t[t.length-1]:e},async isIdle(t=null){let a={childList:!0,subtree:!0},n={msgDiv:"div[data-message-author-role]",replyDiv:'div[data-message-author-role="assistant"]'};var e=t?new Promise(e=>setTimeout(()=>e(!1),t)):null,r=(async()=>{await new Promise(r=>{document.querySelector(n.msgDiv)?r():new MutationObserver((e,t)=>{document.querySelector(n.msgDiv)&&(t.disconnect(),r())}).observe(document.body,a)}),await new Promise(r=>{new MutationObserver((e,t)=>{chatgpt.getStopBtn()&&(t.disconnect(),r())}).observe(document.body,{childList:!0,subtree:!0})});let e=document.querySelectorAll(n.replyDiv),o=e[e.length-1];return await new Promise(r=>{new MutationObserver((e,t)=>{o?.querySelector("pre")&&(t.disconnect(),r())}).observe(document.body,a)}),new Promise(r=>{new MutationObserver((e,t)=>{!o?.querySelector("pre")?.nextElementSibling&&chatgpt.getStopBtn()||(t.disconnect(),r(!0))}).observe(document.body,a)})})();return e?Promise.race([r,e]):r},async minify(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Minify the following code:\n\n"+e),console.info("Minifying code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},async obfuscate(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Obfuscate the following code:\n\n"+e),console.info("Obfuscating code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},async refactor(e,t){if(!e)return console.error("Code (1st) argument not supplied. Pass some code!");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send("Refactor the following code for "+(t||"brevity")+":\n\n"+e),console.info("Refactoring code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))},async review(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Review the following code for me:\n\n"+e),console.info("Reviewing code..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")):console.error("Code argument not supplied. Pass some code!")},async unminify(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Unminify the following code.:\n\n"+e),console.info("Unminifying code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},async write(e,t){if(!e)return console.error("Prompt (1st) argument not supplied. Pass a prompt!");if(!t)return console.error("outputLang (2nd) argument not supplied. Pass a language!");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send(e+"\n\nWrite this as code in "+t),console.info("Writing code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))}},continue(){chatgpt.response.continue()},async detectLanguage(e){return e?"string"!=typeof e?console.error("Text argument must be a string!"):(chatgpt.send("Detect the language of the following text:\n\n"+e+"\n\nOnly respond with the name of the language"),console.info("Reviewing text..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")):console.error("Text argument not supplied. Pass some text!")},executeCode(){chatgpt.code.execute()},async exportChat(e,t){e=e?Number.isInteger(e)||/^\d+$/.test(e)?parseInt(e,10):e:"active",t=t.toLowerCase()||"html",console.info("Generating transcript...");let a="",r;if(/te?xt/.test(t)){var o=new Date,n=o.getDate().toString().padStart(2,"0"),s=(o.getMonth()+1).toString().padStart(2,"0"),i=o.getFullYear(),c=o.getHours().toString().padStart(2,"0"),o=o.getMinutes().toString().padStart(2,"0");if(r=`ChatGPT_${n}-${s}-${i}_${c}-${o}.txt`,"active"==e&&/\/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(window.location.href)){n=document.querySelectorAll("main > div > div > div > div > div > div[class*=group]");if(0===n.length)return console.error("Chat is empty!");let r=[],o=!0;n.forEach(e=>{var t=o?"USER":"CHATGPT",e=(o=!o,Array.from(e.childNodes).map(e=>e.innerText).join("\n\n").replace("Copy code",""));r.push(t+": "+e)}),a=r.join("\n\n")}else for(var l of await chatgpt.getChatData(e,"msg","both","all"))a=(a+=`USER: ${l.user}
|
|
7
|
+
localStorage.alertQueue=JSON.stringify([]),localStorage.notifyProps=JSON.stringify({queue:{topRight:[],bottomRight:[],bottomLeft:[],topLeft:[]}});let chatgpt={openAIaccessToken:{},endpoints:{assets:"https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@2740f5cd4e9152e44176adce6b4dc22a8228b454",openAI:{session:"https://chatgpt.com/api/auth/session",chats:"https://chatgpt.com/backend-api/conversations",chat:"https://chatgpt.com/backend-api/conversation",share_create:"https://chatgpt.com/backend-api/share/create",share:"https://chatgpt.com/backend-api/share",instructions:"https://chatgpt.com/backend-api/user_system_messages"}},actAs(s){return new Promise((o,a)=>{let n=new XMLHttpRequest;n.open("GET","https://raw.githubusercontent.com/KudoAI/chat-prompts/main/dist/personas.min.json",!0),n.send(),n.onload=()=>{if(200!==n.status)return a("🤖 chatgpt.js >> Request failed. Cannot retrieve prompts data.");var e=JSON.parse(n.responseText).personas;if(s){var t=e.find(e=>e.title.toLowerCase()==s.toLowerCase());if(!t)return a(`🤖 chatgpt.js >> Persona '${s}' was not found!`);chatgpt.send(t.prompt,"click"),console.info(`Loading ${s} persona...`),chatgpt.isIdle().then(()=>{console.info("Persona activated!")})}else{console.log("\n%c🤖 chatgpt.js personas\n","font-family: sans-serif ; font-size: xxx-large ; font-weight: bold");for(var r of e)console.log("%c"+r.title,"font-family: monospace ; font-size: larger ;")}return o()}})},activateDarkMode(){document.documentElement.classList.replace("light","dark"),document.documentElement.style.colorScheme="dark",localStorage.setItem("theme","dark")},activateLightMode(){document.documentElement.classList.replace("dark","light"),document.documentElement.style.colorScheme="light",localStorage.setItem("theme","light")},alert(r,o,e,a,t){let n=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"),d=document.createElement("p");var g=20231203;let u=document.querySelector("#chatgpt-modal-style"),p=((!u||parseInt(u.getAttribute("last-updated"),10)<g)&&(u||((u=document.createElement("style")).id="chatgpt-modal-style",u.setAttribute("last-updated",g.toString()),document.head.append(u)),u.innerText=".no-mobile-tap-outline { outline: none ; -webkit-tap-highlight-color: transparent }.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"==n?"black":"white"} ;`+("dark"!=n?"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"==n?"#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"==n?"white":"black"}}`+".primary-modal-btn {"+`border: 1px solid ${"dark"==n?"white":"black"} ;`+`background: ${"dark"==n?"white":"black"} ;`+`color: ${"dark"==n?"black":"white"}}`+".chatgpt-modal button:hover { color: #3d5d71 ; border-color: #6d9cb9 ;background-color: "+("dark"==n?"#00cfff":"#9cdaff")+";box-shadow: 2px 1px "+("dark"==n?"54px #00cfff":"30px #9cdaff")+"}.modal-close-btn {cursor: pointer ; width: 29px ; height: 29px ; border-radius: 17px ;float: right ; position: relative ; right: -6px ; top: -5px }.modal-close-btn svg { margin: 10px }"+`.modal-close-btn:hover { background-color: #f2f2f2${"dark"==n?"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"==n?"#e1e1e1":"#1e1e1e"}}`+'.chatgpt-modal input[type="checkbox"] { transform: scale(0.7) ;'+`border: 1px solid ${"dark"==n?"white":"black"}}`+'.chatgpt-modal input[type="checkbox"]:checked {'+`border: 1px solid ${"dark"==n?"white":"black"} ;`+'background-color: black ; position: inherit }.chatgpt-modal input[type="checkbox"]:focus { outline: none ; box-shadow: none }'),l.innerText=r||"",d.innerText=o||"",chatgpt.renderHTML(d),document.createElement("div"));p.classList.add("modal-buttons","no-mobile-tap-outline"),e&&(e=Array.isArray(e)?e:[e]).forEach(e=>{var t=document.createElement("button");t.textContent=e.name.replace(/[_-]\w/g,e=>e.slice(1).toUpperCase()).replace(/([A-Z])/g," $1").replace(/^\w/,e=>e.toUpperCase()),t.onclick=()=>{y(),e()},p.insertBefore(t,p.firstChild)});g=document.createElement("button"),g.textContent=e?"Dismiss":"OK",p.insertBefore(g,p.firstChild),p.lastChild.classList.add("primary-modal-btn"),r=document.createElement("div");if(a){r.classList.add("checkbox-group");let e=a,t=document.createElement("input");t.type="checkbox",t.onchange=e;o=document.createElement("label");o.onclick=()=>{t.checked=!t.checked,e()},o.textContent=e.name.charAt(0).toUpperCase()+e.name.slice(1).replace(/([A-Z])/g,(e,t)=>" "+t.toLowerCase()).replace(/\b(\w+)nt\b/gi,"$1n't").trim(),r.append(t),r.append(o)}e=document.createElement("div"),e.title="Close",e.classList.add("modal-close-btn","no-mobile-tap-outline"),a=document.createElementNS("http://www.w3.org/2000/svg","svg"),a.setAttribute("height","10px"),a.setAttribute("viewBox","0 0 14 14"),a.setAttribute("fill","none"),o=document.createElementNS("http://www.w3.org/2000/svg","path");o.setAttribute("fill-rule","evenodd"),o.setAttribute("clip-rule","evenodd"),o.setAttribute("fill",chatgpt.isDarkMode()?"white":"black"),o.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(o),e.append(a),[e,l,d,p,r].forEach(e=>{c.append(e)}),c.style.width=`${t||458}px`,i.append(c),document.body.append(i);let h=JSON.parse(localStorage.alertQueue),m=(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"==n?.62:.1})`,i.classList.add("animated")},100)),e=>{(e.target==e.currentTarget||e.target instanceof SVGPathElement)&&y()}),f=e=>{if([" ","Spacebar","Enter","Return","Escape","Esc"].includes(e.key)||[32,13,27].includes(e.keyCode))for(var t of h){var t=document.getElementById(t);if(t&&"none"!==t.style.display)return void(e.key.includes("Esc")||27==e.keyCode?y():([" ","Spacebar","Enter","Return"].includes(e.key)||[32,13].includes(e.keyCode))&&(t=t.querySelector(".modal-buttons").lastChild)&&(t.click(),e.preventDefault()))}},y=([i,e,a,g].forEach(e=>e.onclick=m),document.addEventListener("keydown",f),()=>{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),document.removeEventListener("keydown",f),0<h.length){let e=document.getElementById(h[0]);setTimeout(()=>{e.style.display="",setTimeout(()=>{e.classList.add("animated")},100)},500)}},50)});return i.id},async askAndGetReply(e){return chatgpt.send(e),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},autoRefresh:{activate(e){if(this.isActive)console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already active!");else{let r=this,o=(this.toggle.refreshFrame(),t=>{var e=Math.max(2,Math.floor(21*chatgpt.randomFloat()-10));r.isActive=setTimeout(()=>{var e=document.querySelector('script[src*="_ssgManifest.js"]');e&&(document.querySelector("#refresh-frame").src=e.src+"?"+Date.now(),console.log("↻ ChatGPT >> ["+r.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(){this.isActive?(this.toggle.refreshFrame(),document.removeEventListener("visibilitychange",this.toggle.beacons),clearTimeout(this.isActive),this.isActive=null,console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh de-activated")):console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already inactive!")},nowTimeStamp(){var e=new Date,t=e.getHours()%12||12;let r=e.getMinutes(),o=e.getSeconds();r<10&&(r="0"+r),o<10&&(o="0"+o);e=e.getHours()<12?"AM":"PM";return t+":"+r+":"+o+" "+e},toggle:{beacons(){chatgpt.autoRefresh.beaconID?(clearInterval(chatgpt.autoRefresh.beaconID),chatgpt.autoRefresh.beaconID=null,console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacons de-activated")):(chatgpt.autoRefresh.beaconID=setInterval(()=>{navigator.sendBeacon("https://httpbin.org/post",new Uint8Array),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacon sent")},9e4),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacons activated"))},refreshFrame(){let e=document.querySelector("#refresh-frame");e?e.remove():(e=Object.assign(document.createElement("iframe"),{id:"refresh-frame",style:"display: none"}),document.head.prepend(e))}}},browser:{isLightMode(){return window.matchMedia?.("(prefers-color-scheme: light)")?.matches},isDarkMode(){return window.matchMedia?.("(prefers-color-scheme: dark)")?.matches},isChromium(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Chromium")},isChrome(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Chrome")},isEdge(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Edge")},isBrave(){return!!JSON.stringify(navigator.userAgentData?.brands)?.includes("Brave")},isFirefox(){return navigator.userAgent.includes("Firefox")},isFullScreen(){var e=navigator.userAgent;return e.includes("Chrome")?window.matchMedia("(display-mode: fullscreen)").matches:e.includes("Firefox")?window.fullScreen:/MSIE|rv:/.test(e)?document.msFullscreenElement:document.webkitIsFullScreen},isMobile(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}},async clearChats(){return new Promise((r,o)=>{chatgpt.getAccessToken().then(e=>{let t=new XMLHttpRequest;t.open("PATCH",chatgpt.endpoints.openAI.chats,!0),t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("Authorization","Bearer "+e),t.onload=()=>{if(200!==t.status)return o("🤖 chatgpt.js >> Request failed. Cannot clear chats.");console.info("Chats successfully cleared"),r()},t.send(JSON.stringify({is_visible:!1}))}).catch(e=>o(new Error(e.message)))})},code:{async execute(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Display the output as if you were terminal:\n\n"+e),console.info("Executing code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},extract(e){var t=e.match(/(?<=```.*\n)[\s\S]*?(?=```)/g);return t?t[t.length-1]:e},async isIdle(t=null){let a={childList:!0,subtree:!0},n={msgDiv:"div[data-message-author-role]",replyDiv:'div[data-message-author-role="assistant"]'};var e=t?new Promise(e=>setTimeout(()=>e(!1),t)):null,r=(async()=>{await new Promise(r=>{document.querySelector(n.msgDiv)?r():new MutationObserver((e,t)=>{document.querySelector(n.msgDiv)&&(t.disconnect(),r())}).observe(document.body,a)}),await new Promise(r=>{new MutationObserver((e,t)=>{chatgpt.getStopBtn()&&(t.disconnect(),r())}).observe(document.body,{childList:!0,subtree:!0})});let e=document.querySelectorAll(n.replyDiv),o=e[e.length-1];return await new Promise(r=>{new MutationObserver((e,t)=>{o?.querySelector("pre")&&(t.disconnect(),r())}).observe(document.body,a)}),new Promise(r=>{new MutationObserver((e,t)=>{!o?.querySelector("pre")?.nextElementSibling&&chatgpt.getStopBtn()||(t.disconnect(),r(!0))}).observe(document.body,a)})})();return e?Promise.race([r,e]):r},async minify(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Minify the following code:\n\n"+e),console.info("Minifying code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},async obfuscate(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Obfuscate the following code:\n\n"+e),console.info("Obfuscating code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},async refactor(e,t){if(!e)return console.error("Code (1st) argument not supplied. Pass some code!");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send("Refactor the following code for "+(t||"brevity")+":\n\n"+e),console.info("Refactoring code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))},async review(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Review the following code for me:\n\n"+e),console.info("Reviewing code..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")):console.error("Code argument not supplied. Pass some code!")},async unminify(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Unminify the following code.:\n\n"+e),console.info("Unminifying code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},async write(e,t){if(!e)return console.error("Prompt (1st) argument not supplied. Pass a prompt!");if(!t)return console.error("outputLang (2nd) argument not supplied. Pass a language!");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send(e+"\n\nWrite this as code in "+t),console.info("Writing code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))}},continue(){chatgpt.response.continue()},async detectLanguage(e){return e?"string"!=typeof e?console.error("Text argument must be a string!"):(chatgpt.send("Detect the language of the following text:\n\n"+e+"\n\nOnly respond with the name of the language"),console.info("Reviewing text..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")):console.error("Text argument not supplied. Pass some text!")},executeCode(){chatgpt.code.execute()},async exportChat(e,t){e=e?Number.isInteger(e)||/^\d+$/.test(e)?parseInt(e,10):e:"active",t=t.toLowerCase()||"html",console.info("Generating transcript...");let a="",r;if(/te?xt/.test(t)){var o=new Date,n=o.getDate().toString().padStart(2,"0"),s=(o.getMonth()+1).toString().padStart(2,"0"),i=o.getFullYear(),c=o.getHours().toString().padStart(2,"0"),o=o.getMinutes().toString().padStart(2,"0");if(r=`ChatGPT_${n}-${s}-${i}_${c}-${o}.txt`,"active"==e&&/\/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(window.location.href)){n=document.querySelectorAll("main > div > div > div > div > div > div[class*=group]");if(0===n.length)return console.error("Chat is empty!");let r=[],o=!0;n.forEach(e=>{var t=o?"USER":"CHATGPT",e=(o=!o,Array.from(e.childNodes).map(e=>e.innerText).join("\n\n").replace("Copy code",""));r.push(t+": "+e)}),a=r.join("\n\n")}else for(var l of await chatgpt.getChatData(e,"msg","both","all"))a=(a+=`USER: ${l.user}
|
|
8
8
|
|
|
9
9
|
`)+`CHATGPT: ${l.chatgpt}
|
|
10
10
|
|
|
11
|
-
`}else{s=await(await fetch(await chatgpt.shareChat(e))).text(),i=(new DOMParser).parseFromString(s,"text/html");r=`${i.querySelector("title").textContent||"ChatGPT conversation"}.html`,i.querySelectorAll('link[rel="stylesheet"]').forEach(e=>{var t=e.getAttribute("href");t?.startsWith("/")&&e.setAttribute("href","https://chat.openai.com"+t)}),a=(new XMLSerializer).serializeToString(i)}if(console.info(`Exporting transcript as ${t.toUpperCase()}...`),"pdf"==t){a=a.replace(/<svg.*?<\/svg>/g,e=>`<img src="${"data:image/svg+xml,"+encodeURIComponent(e)}">`);let e=window.open("","","toolbar=0, location=0, menubar=0, height=600, width=800");e.document.write(a),setTimeout(()=>{e.print({toPDF:!0})},100)}else{"md"==t&&(c=/<.*(?:<h1(.|\n)*?href=".*?continue[^"]*".*?\/a>.*?)<[^/]/.exec(a)[1],a=c||a,r=r.replace(".html",".md"));o=new Blob([a],{type:"text/"+("html"==t?"html":"md"==t?"markdown":"plain")}),n=document.createElement("a"),e=URL.createObjectURL(o);n.href=e,n.download=r,document.body.append(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(e)}},extractCode(){chatgpt.code.extract()},focusChatbar(){chatgpt.getChatBox()?.focus()},footer:{get(){return document.querySelector("main form")?.parentNode.parentNode.nextElementSibling},hide(){var e=chatgpt.footer.get();return e?"hidden"==e.style.visibility?console.info("Footer already hidden!"):(e.style.visibility="hidden",void(e.style.height="3px")):console.error("Footer element not found!")},show(){var e=chatgpt.footer.get();return e?"hidden"!=e.style.visibility?console.info("Footer already shown!"):void(e.style.visibility=e.style.height="inherit"):console.error("Footer element not found!")}},generateRandomIP(){var e=Array.from({length:4},()=>Math.floor(256*chatgpt.randomFloat())).join(".");return console.info("IP generated: "+e),e},get(e,t=""){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Invalid arguments. Both arguments must be strings.");if(!cjsTargetTypes.includes(e.toLowerCase()))throw new Error("Invalid targetType: "+e+". Valid values are: "+JSON.stringify(cjsTargetTypes));var r,o=[],a=new RegExp("^get(.*)"+e+"$","i");for(r in chatgpt)"function"==typeof chatgpt[r]&&a.test(r)&&o.push(r.replace(a,"$1").toLowerCase());if(!o.includes(t.toLowerCase()))throw new Error("Invalid targetName: "+t+". "+(0<o.length?"Valid values are: "+JSON.stringify(o):"targetType "+e.toLowerCase()+" does not require additional options."));let n=("get"+t+e).toLowerCase();return this[Object.keys(this).find(e=>e.toLowerCase()==n)]()},getAccessToken(){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);let r=new XMLHttpRequest;r.open("GET",chatgpt.endpoints.openAI.session,!0),r.setRequestHeader("Content-Type","application/json"),r.onload=()=>200!==r.status?t("🤖 chatgpt.js >> Request failed. Cannot retrieve access token."):(console.info("Token expiration: "+new Date(JSON.parse(r.responseText).expires).toLocaleString().replace(","," at")),chatgpt.openAIaccessToken={token:JSON.parse(r.responseText).accessToken,expireDate:JSON.parse(r.responseText).expires},e(chatgpt.openAIaccessToken.token)),r.send()})},getAccountDetails(...s){var e,t=["email","id","image","name","picture"];for(e of s=arguments[0]?Array.isArray(arguments[0])?arguments[0]:Array.from(arguments):t)if(!t.includes(e))return console.error("Invalid detail arg '"+e+"' supplied. Valid details are:\n ["+t+"]");return new Promise((o,a)=>{let n=new XMLHttpRequest;n.open("GET",chatgpt.endpoints.openAI.session,!0),n.setRequestHeader("Content-Type","application/json"),n.onload=()=>{if(200!==n.status)return a("🤖 chatgpt.js >> Request failed. Cannot retrieve account details.");var e,t=JSON.parse(n.responseText).user,r={};for(e of s)r[e]=t[e];return o(r)},n.send()})},getChatBox(){return document.getElementById("prompt-textarea")},getChatData(d=1,o="all",p="all",h="all"){var e,t=["all","id","title","create_time","update_time","msg"],r=["all","both","user","chatgpt"];d=d?Number.isInteger(d)||/^\d+$/.test(d)?0===parseInt(d,10)?0:parseInt(d,10)-1:d:"active",o=["all",""].includes(o)?t.filter(e=>/^(?!all$|msg$).*/.test(e)):Array.isArray(o)?o:[o],p=p?r.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(e of o)if(!t.includes(e))return console.error("Invalid detail arg '"+e+"' passed. Valid details are:\n ["+t+"]");if("invalid"==p)return console.error("Invalid sender arg passed. Valid senders are:\n ["+r+"]");if("invalid"==h)return console.error("Invalid msgToGet arg passed. Valid msg's to get are:\n [ 'all' | 'latest' | index of msg to get ]");let a=(e,c)=>{let l=/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/;return new Promise((t,s)=>{let i=new XMLHttpRequest;i.open("GET",chatgpt.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 r=JSON.parse(i.responseText).items;if(r.length<=0)return s("🤖 chatgpt.js >> Chat list is empty.");var o={};if(Number.isInteger(d)||"latest"==d||"active"==d&&!new RegExp("/"+l.source+"$").test(window.location.href)){if((d=Number.isInteger(d)?d:0)>r.length)return s("🤖 chatgpt.js >> Chat with index "+(d+1)+" is out of bounds. Only "+r.length+" chats exist!");for(var e of c)o[e]=r[d][e]}else{var a,n="active"==d||new RegExp("^"+l.source+"$").test(d)?"id":"title";"active"==d&&(d=l.exec(window.location.href)[0]);let e,t;for(e=0;e<r.length;e++)if(r[e][n]==d){t=!0;break}if(!t)return s("🤖 chatgpt.js >> No chat with "+n+" = "+d+" found.");for(a of c)o[a]=r[e][a]}return t(o)},i.send()})};return new Promise(r=>chatgpt.getAccessToken().then(e=>{return r(o.includes("msg")?(t=e,new Promise((d,g)=>{let u=new XMLHttpRequest;a(t,["id"]).then(e=>{u.open("GET",chatgpt.endpoints.openAI.chat+"/"+e.id,!0),u.setRequestHeader("Content-Type","application/json"),u.setRequestHeader("Authorization","Bearer "+t),u.onload=()=>{if(200!==u.status)return g("🤖 chatgpt.js >> Request failed. Cannot retrieve chat messages.");var e,t,r=JSON.parse(u.responseText).mapping,o=[],a=[],n=[];for(e in r)null!=r[e].message&&"user"==r[e].message.author.role&&o.push({id:r[e].id,msg:r[e].message});if(o.sort((e,t)=>e.msg.create_time-t.msg.create_time),parseInt(h,10)+1>o.length)return g("🤖 chatgpt.js >> Message/response with index "+(h+1)+" is out of bounds. Only "+o.length+" messages/responses exist!");for(t of o){let e=[];for(var s in r)null!=r[s].message&&"assistant"==r[s].message.author.role&&r[s].parent==t.id&&e.push(r[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,a.push(e)}if("user"==p)for(var i in o)n.push(o[i].msg.content.parts[0]);else if("chatgpt"==p)for(var c of a)n.push("latest"==h?a[a.length-1]:c);else{let e=0;for(var l in o)n.push({user:o[l].msg.content.parts[0],chatgpt:"latest"==h?a[e][a[e].length-1]:a[e]}),e++}return d("all"==h?n:"latest"==h?n[n.length-1]:n[h])},u.send()})})):a(e,o));var t}))},getChatInput(){return chatgpt.getChatBox().value},
|
|
11
|
+
`}else{s=await(await fetch(await chatgpt.shareChat(e))).text(),i=(new DOMParser).parseFromString(s,"text/html");r=`${i.querySelector("title").textContent||"ChatGPT conversation"}.html`,i.querySelectorAll('link[rel="stylesheet"]').forEach(e=>{var t=e.getAttribute("href");t?.startsWith("/")&&e.setAttribute("href","https://chat.openai.com"+t)}),a=(new XMLSerializer).serializeToString(i)}if(console.info(`Exporting transcript as ${t.toUpperCase()}...`),"pdf"==t){a=a.replace(/<svg.*?<\/svg>/g,e=>`<img src="${"data:image/svg+xml,"+encodeURIComponent(e)}">`);let e=window.open("","","toolbar=0, location=0, menubar=0, height=600, width=800");e.document.write(a),setTimeout(()=>{e.print({toPDF:!0})},100)}else{"md"==t&&(c=/<.*(?:<h1(.|\n)*?href=".*?continue[^"]*".*?\/a>.*?)<[^/]/.exec(a)[1],a=c||a,r=r.replace(".html",".md"));o=new Blob([a],{type:"text/"+("html"==t?"html":"md"==t?"markdown":"plain")}),n=document.createElement("a"),e=URL.createObjectURL(o);n.href=e,n.download=r,document.body.append(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(e)}},extractCode(){chatgpt.code.extract()},focusChatbar(){chatgpt.getChatBox()?.focus()},footer:{get(){return document.querySelector("main form")?.parentNode.parentNode.nextElementSibling},hide(){var e=chatgpt.footer.get();return e?"hidden"==e.style.visibility?console.info("Footer already hidden!"):(e.style.visibility="hidden",void(e.style.height="3px")):console.error("Footer element not found!")},show(){var e=chatgpt.footer.get();return e?"hidden"!=e.style.visibility?console.info("Footer already shown!"):void(e.style.visibility=e.style.height="inherit"):console.error("Footer element not found!")}},generateRandomIP(){var e=Array.from({length:4},()=>Math.floor(256*chatgpt.randomFloat())).join(".");return console.info("IP generated: "+e),e},get(e,t=""){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Invalid arguments. Both arguments must be strings.");if(!cjsTargetTypes.includes(e.toLowerCase()))throw new Error("Invalid targetType: "+e+". Valid values are: "+JSON.stringify(cjsTargetTypes));var r,o=[],a=new RegExp("^get(.*)"+e+"$","i");for(r in chatgpt)"function"==typeof chatgpt[r]&&a.test(r)&&o.push(r.replace(a,"$1").toLowerCase());if(!o.includes(t.toLowerCase()))throw new Error("Invalid targetName: "+t+". "+(0<o.length?"Valid values are: "+JSON.stringify(o):"targetType "+e.toLowerCase()+" does not require additional options."));let n=("get"+t+e).toLowerCase();return this[Object.keys(this).find(e=>e.toLowerCase()==n)]()},getAccessToken(){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);let r=new XMLHttpRequest;r.open("GET",chatgpt.endpoints.openAI.session,!0),r.setRequestHeader("Content-Type","application/json"),r.onload=()=>200!==r.status?t("🤖 chatgpt.js >> Request failed. Cannot retrieve access token."):(console.info("Token expiration: "+new Date(JSON.parse(r.responseText).expires).toLocaleString().replace(","," at")),chatgpt.openAIaccessToken={token:JSON.parse(r.responseText).accessToken,expireDate:JSON.parse(r.responseText).expires},e(chatgpt.openAIaccessToken.token)),r.send()})},getAccountDetails(...s){var e,t=["email","id","image","name","picture"];for(e of s=arguments[0]?Array.isArray(arguments[0])?arguments[0]:Array.from(arguments):t)if(!t.includes(e))return console.error("Invalid detail arg '"+e+"' supplied. Valid details are:\n ["+t+"]");return new Promise((o,a)=>{let n=new XMLHttpRequest;n.open("GET",chatgpt.endpoints.openAI.session,!0),n.setRequestHeader("Content-Type","application/json"),n.onload=()=>{if(200!==n.status)return a("🤖 chatgpt.js >> Request failed. Cannot retrieve account details.");var e,t=JSON.parse(n.responseText).user,r={};for(e of s)r[e]=t[e];return o(r)},n.send()})},getChatBox(){return document.getElementById("prompt-textarea")},getChatData(d=1,o="all",p="all",h="all"){var e,t=["all","id","title","create_time","update_time","msg"],r=["all","both","user","chatgpt"];d=d?Number.isInteger(d)||/^\d+$/.test(d)?0===parseInt(d,10)?0:parseInt(d,10)-1:d:"active",o=["all",""].includes(o)?t.filter(e=>/^(?!all$|msg$).*/.test(e)):Array.isArray(o)?o:[o],p=p?r.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(e of o)if(!t.includes(e))return console.error("Invalid detail arg '"+e+"' passed. Valid details are:\n ["+t+"]");if("invalid"==p)return console.error("Invalid sender arg passed. Valid senders are:\n ["+r+"]");if("invalid"==h)return console.error("Invalid msgToGet arg passed. Valid msg's to get are:\n [ 'all' | 'latest' | index of msg to get ]");let a=(e,c)=>{let l=/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/;return new Promise((t,s)=>{let i=new XMLHttpRequest;i.open("GET",chatgpt.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 r=JSON.parse(i.responseText).items;if(r.length<=0)return s("🤖 chatgpt.js >> Chat list is empty.");var o={};if(Number.isInteger(d)||"latest"==d||"active"==d&&!new RegExp("/"+l.source+"$").test(window.location.href)){if((d=Number.isInteger(d)?d:0)>r.length)return s("🤖 chatgpt.js >> Chat with index "+(d+1)+" is out of bounds. Only "+r.length+" chats exist!");for(var e of c)o[e]=r[d][e]}else{var a,n="active"==d||new RegExp("^"+l.source+"$").test(d)?"id":"title";"active"==d&&(d=l.exec(window.location.href)[0]);let e,t;for(e=0;e<r.length;e++)if(r[e][n]==d){t=!0;break}if(!t)return s("🤖 chatgpt.js >> No chat with "+n+" = "+d+" found.");for(a of c)o[a]=r[e][a]}return t(o)},i.send()})};return new Promise(r=>chatgpt.getAccessToken().then(e=>{return r(o.includes("msg")?(t=e,new Promise((d,g)=>{let u=new XMLHttpRequest;a(t,["id"]).then(e=>{u.open("GET",chatgpt.endpoints.openAI.chat+"/"+e.id,!0),u.setRequestHeader("Content-Type","application/json"),u.setRequestHeader("Authorization","Bearer "+t),u.onload=()=>{if(200!==u.status)return g("🤖 chatgpt.js >> Request failed. Cannot retrieve chat messages.");var e,t,r=JSON.parse(u.responseText).mapping,o=[],a=[],n=[];for(e in r)null!=r[e].message&&"user"==r[e].message.author.role&&o.push({id:r[e].id,msg:r[e].message});if(o.sort((e,t)=>e.msg.create_time-t.msg.create_time),parseInt(h,10)+1>o.length)return g("🤖 chatgpt.js >> Message/response with index "+(h+1)+" is out of bounds. Only "+o.length+" messages/responses exist!");for(t of o){let e=[];for(var s in r)null!=r[s].message&&"assistant"==r[s].message.author.role&&r[s].parent==t.id&&e.push(r[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,a.push(e)}if("user"==p)for(var i in o)n.push(o[i].msg.content.parts[0]);else if("chatgpt"==p)for(var c of a)n.push("latest"==h?a[a.length-1]:c);else{let e=0;for(var l in o)n.push({user:o[l].msg.content.parts[0],chatgpt:"latest"==h?a[e][a[e].length-1]:a[e]}),e++}return d("all"==h?n:"latest"==h?n[n.length-1]:n[h])},u.send()})})):a(e,o));var t}))},getChatInput(){return chatgpt.getChatBox().value},getContinueButton(){return document.querySelector('button:has([d^="M4.47189"])')},getFooterDiv(){return chatgpt.footer.get()},getHeaderDiv(){return chatgpt.header.get()},getLastPrompt(){return chatgpt.getChatData("active","msg","user","latest")},getLastResponse(){return chatgpt.getChatData("active","msg","chatgpt","latest")},getNewChatButton(){return document.querySelector('button:has([d*="M15.6729"],[d^="M3.06957"])')},getNewChatLink(){return document.querySelector('nav a[href="/"]')},getRegenerateButton(){return document.querySelector('button:has([d^="M3.06957"])')},getResponse(){return chatgpt.response.get(...arguments)},getResponseFromAPI(e,t){return chatgpt.response.getFromAPI(e,t)},getResponseFromDOM(e){return chatgpt.response.getFromDOM(e)},getScrollToBottomButton(){return document.querySelector('button[class*="cursor"][class*="bottom"]')},getSendButton(){return document.querySelector('[data-testid="send-button"]')||document.querySelector('path[d*="M15.192 8.906a1.143"]')?.parentNode.parentNode},getStopButton(){return document.querySelector('button:has([d*="2 0 0 1 2"], rect)')},getUserLanguage(){return navigator.languages[0]||navigator.language||navigator.browserLanguage||navigator.systemLanguage||navigator.userLanguage||""},header:{get(){return document.querySelector("main .sticky")},hide(){chatgpt.header.get().style.display="none"},show(){chatgpt.header.get().style.display="flex"}},hideFooter(){chatgpt.footer.hide()},hideHeader(){chatgpt.header.hide()},history:{async isLoaded(t=null){var e=t?new Promise(e=>setTimeout(()=>e(!1),t)):null,r=new Promise(r=>{document.querySelector("nav")?r(!0):new MutationObserver((e,t)=>{document.querySelector("nav")&&(t.disconnect(),r(!0))}).observe(document.body,{childList:!0,subtree:!0})});return e?Promise.race([r,e]):r}},instructions:{add(o,a){var e;return o?"string"!=typeof o?console.error("Instruction must be a string"):(e=["user","chatgpt"],a?"string"!=typeof a?console.error("Target must be a string"):(a=a.toLowerCase(),e.includes(a)?(o=`
|
|
12
12
|
|
|
13
|
-
`+o,new Promise(r=>{chatgpt.getAccessToken().then(async e=>{var t=await this.fetchData();return"user"==a?t.about_user_message+=o:"chatgpt"==a&&(t.about_model_message+=o),await this.sendRequest("POST",e,t),r()})})):console.error(`Invalid target ${a}. Valid targets are [${e}]`)):console.error("Please provide a valid target!")):console.error("Please provide an instruction")},clear(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(r=>{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),r()})}):console.error(`Invalid target ${o}. Valid targets are [${e}]`)):console.error("Please provide a valid target!")},fetchData(){return new Promise(t=>{chatgpt.getAccessToken().then(async e=>t(await this.sendRequest("GET",e)))})},sendRequest(a,e,n){for(let e=0;e<arguments.length-1;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string`);var t=["POST","GET"];return(a=(a||"").trim().toUpperCase())&&t.includes(a)?e?n&&"object"!=typeof n?console.error(`Invalid body data type. Got ${typeof n}, expected object`):new Promise((t,r)=>{let o=new XMLHttpRequest;o.open(a,chatgpt.endpoints.openAI.instructions,!0),o.setRequestHeader("Accept-Language","en-US"),o.setRequestHeader("Authorization","Bearer "+e),"POST"==a&&o.setRequestHeader("Content-Type","application/json"),o.onload=()=>{var e=JSON.parse(o.responseText);return 422===o.status?r("🤖 chatgpt.js >> Character limit exceeded. Custom instructions can have a maximum length of 1500 characters."):403===o.status&&"content_policy"==e.detail.reason?r("🤖 chatgpt.js >> "+e.detail.description):200!==o.status?r("🤖 chatgpt.js >> Request failed. Cannot contact custom instructions endpoint."):(console.info("Custom instructions successfully contacted with method "+a),t(e||{}))},o.send(JSON.stringify(n)||"")}):console.error("Please provide a valid access token!"):console.error("Valid methods are "+t)},turnOff(){return new Promise(r=>{chatgpt.getAccessToken().then(async e=>{var t=await this.fetchData();return t.enabled=!1,await this.sendRequest("POST",e,t),r()})})},turnOn(){return new Promise(r=>{chatgpt.getAccessToken().then(async e=>{var t=await this.fetchData();return t.enabled=!0,await this.sendRequest("POST",e,t),r()})})},toggle(){return new Promise(t=>{this.fetchData().then(async e=>(await(e.enabled?this.turnOff():this.turnOn()),t()))})}},isDarkMode(){return document.documentElement.classList.toString().includes("dark")},isFullScreen(){return chatgpt.browser.isFullScreen()},async isIdle(t=null){let e={childList:!0,subtree:!0},o="div[data-message-author-role]";var r=t?new Promise(e=>setTimeout(()=>e(!1),t)):null,a=(async()=>(await new Promise(r=>{document.querySelector(o)?r():new MutationObserver((e,t)=>{document.querySelector(o)&&(t.disconnect(),r())}).observe(document.body,e)}),await new Promise(r=>{new MutationObserver((e,t)=>{chatgpt.getStopBtn()&&(t.disconnect(),r())}).observe(document.body,e)}),new Promise(r=>{new MutationObserver((e,t)=>{chatgpt.getStopBtn()||(t.disconnect(),r(!0))}).observe(document.body,e)})))();return r?Promise.race([a,r]):a},async isLoaded(t=null){var e=t?new Promise(e=>setTimeout(()=>e(!1),t)):null,r=new Promise(r=>{chatgpt.getNewChatBtn()?r(!0):new MutationObserver((e,t)=>{chatgpt.getNewChatBtn()&&(t.disconnect(),r(!0))}).observe(document.body,{childList:!0,subtree:!0})});return e?Promise.race([r,e]):r},isLightMode(){return document.documentElement.classList.toString().includes("light")},logout(){window.location.href="https://chat.openai.com/auth/logout"},menu:{elements:[],addedEvent:!1,append(e,t={}){var r=["button","dropdown"];if(!e||"string"!=typeof e)return console.error("🤖 chatgpt.js >> Please supply a valid string element name!");if(e=e.toLowerCase(),!r.includes(e))return console.error(`🤖 chatgpt.js >> Invalid element! Valid elements are [${r}]`);let 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";r=document.createElement("img");r.src=t?.icon&&"string"==typeof t.icon?t.icon:chatgpt.endpoints.assets+"/starters/chrome/extension/icons/icon128.png",r.width=18,o.insertBefore(r,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)})}let a=()=>{var e,t=document.querySelectorAll('a[role="menuitem"]');let r;for(e of t)if("Settings"==e.textContent){r=e.classList;break}let o=t[0].parentNode;chatgpt.menu.elements.forEach(e=>{if(e.setAttribute("class",r),!o.contains(e))try{o.insertBefore(e,o.firstChild)}catch(e){console.error(e)}})};this.elements.push(o);r=document.querySelector('nav button[id*="headless"]');return this.addedEvent||(r?.addEventListener("click",()=>{setTimeout(a,25)}),this.addedEvent=!0),o.id},close(){try{document.querySelector('nav [id*="menu-button"][aria-expanded="true"]').click()}catch(e){console.error(e.message)}},open(){try{document.querySelector('nav [id*="menu-button"][aria-expanded="false"]').click()}catch(e){console.error(e.message)}}},minify(){chatgpt.code.minify()},notify(e,t,r,o){r=r?+r:1.75;let a=document.createElement("div");a.id=Math.floor(1e6*chatgpt.randomFloat())+Date.now(),a.classList.add("chatgpt-notif"),a.innerText=e,document.body.append(a);var e=document.createElement("div"),n=(e.title="Dismiss",e.classList.add("notif-close-btn","no-mobile-tap-outline"),document.createElementNS("http://www.w3.org/2000/svg","svg")),s=(n.setAttribute("height","8px"),n.setAttribute("viewBox","0 0 14 14"),n.setAttribute("fill","none"),n.style.height=n.style.width="8px",document.createElementNS("http://www.w3.org/2000/svg","path"));s.setAttribute("fill-rule","evenodd"),s.setAttribute("clip-rule","evenodd"),s.setAttribute("fill","white"),s.setAttribute("d","M13.7071 1.70711C14.0976 1.31658 14.0976 0.683417 13.7071 0.292893C13.3166 -0.0976312 12.6834 -0.0976312 12.2929 0.292893L7 5.58579L1.70711 0.292893C1.31658 -0.0976312 0.683417 -0.0976312 0.292893 0.292893C-0.0976312 0.683417 -0.0976312 1.31658 0.292893 1.70711L5.58579 7L0.292893 12.2929C-0.0976312 12.6834 -0.0976312 13.3166 0.292893 13.7071C0.683417 14.0976 1.31658 14.0976 1.70711 13.7071L7 8.41421L12.2929 13.7071C12.6834 14.0976 13.3166 14.0976 13.7071 13.7071C14.0976 13.3166 14.0976 12.6834 13.7071 12.2929L8.41421 7L13.7071 1.70711Z"),n.append(s),e.append(n),a.append(e),a.isTop=!t||!/low|bottom/i.test(t),a.isRight=!t||!/left/i.test(t),a.quadrant=(a.isTop?"top":"bottom")+(a.isRight?"Right":"Left");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 {.no-mobile-tap-outline { outline: none ; -webkit-tap-highlight-color: transparent }background-color: black ; padding: 10px 13px 10px 18px ; border-radius: 11px ; border: 1px solid #f5f5f7 ;opacity: 0 ; position: fixed ; z-index: 9999 ; font-size: 1.8rem ; color: white ;-webkit-user-select: none ; -moz-user-select: none ; -ms-user-select: none ; user-select: none ;"+`transform: translateX(${a.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[a.quadrant].push(a.id),localStorage.notifyProps=JSON.stringify(c),a.style.top=a.isTop?23..toString()+"px":"",a.style.bottom=a.isTop?"":23..toString()+"px",a.style.right=a.isRight?27..toString()+"px":"",a.style.left=a.isRight?"":27..toString()+"px";s=c.queue[a.quadrant];if(1<s.length)try{for(var l of s.slice(0,-1)){var d=document.getElementById(l),g=d.style.top?"top":"bottom",u=+/\d+/.exec(d.style[g])[0]+5+d.getBoundingClientRect().height;d.style[g]=u+"px"}}catch(e){}setTimeout(()=>{a.style.opacity=chatgpt.isDarkMode()?.8:.67,a.style.transform="translateX(0)",a.style.transition="transform 0.15s ease, opacity 0.15s ease"},10);e=()=>{a.style.animation="notif-zoom-fade-out 0.35s ease-out",clearTimeout(p)};let p=setTimeout(e,1e3*(r<.35?0:r-.35));return n.onclick=e,a.onanimationend=()=>{a.remove(),(c=JSON.parse(localStorage.notifyProps)).queue[a.quadrant].shift(),localStorage.notifyProps=JSON.stringify(c)},a},obfuscate(){chatgpt.code.obfuscate()},printAllFunctions(){let r={cmdPrompt:["#ff00ff","#00ff00"],objName:["#0611e9","#f9ee16"],methodName:["#005aff","#ffa500"],entryType:["#467e06","#b981f9"],srcMethod:["#ff0000","#00ffff"]};Object.keys(r).forEach(e=>{r[e][1]=r[e][1]||"#"+(16777215^Number("0x1"+r[e][0].replace(/^#/,""))).toString(16).substring(1).toUpperCase()});var e=[];for(let t in this)if("function"==typeof this[t]){var o=!Object.keys(this).find(e=>Object.keys(this[e]).includes(this[t].name));e.push([o?"chatgpt":"other",t])}else if("object"==typeof this[t])for(var a in this[t])"function"==typeof this[t][a]&&e.push([t,a]);e.sort((e,t)=>e[0].localeCompare(t[0])||e[1].localeCompare(t[1]));var n=window.matchMedia("(prefers-color-scheme: dark)").matches,s="font-family: monospace ; font-size: larger ; ";console.log("\n%c🤖 chatgpt.js methods\n","font-family: sans-serif ; font-size: xxx-large ; font-weight: bold");for(let t of e){var i=/chatgpt|other/.test(t[0]),c="chatgpt"==t[0]?this[t[1]].name:"other"!==t[0]?t[0]+"."+t[1]:Object.keys(this).find(e=>Object.keys(this[e]).includes(this[t[1]].name))+"."+this[t[1]].name,l="AsyncFunction"==this[t[1]]?.constructor.name;console.log("%c>> %c"+(i?"":t[0]+".%c")+t[1]+" - https://chatgptjs.org/userguide/"+/(?:.*\.)?(.*)/.exec(c)[1].toLowerCase()+(l?"-async":"")+"\n%c[%c"+("chatgpt"==t[0]&&t[1]==this[t[1]].name||!i?"Function":"Alias of")+"%c: %c"+c+"%c]",s+"font-weight: bold ; color:"+r.cmdPrompt[+n],s+"font-weight: bold ;color:"+r[i?"methodName":"objName"][+n],s+"font-weight: "+(i?"initial":"bold")+";color:"+(i?"initial":r.methodName[+n]),s+"font-weight: "+(i?"bold":"initial")+";color:"+(i?r.entryType[+n]:"initial"),s+"font-weight: "+(i?"initial":"bold")+";color:"+(i?"initial":r.entryType[+n]),s+(i?"font-style: italic":"font-weight: initial")+";color:"+(i?r.srcMethod[+n]:"initial"),s+(i?"font-weight: initial":"font-style: italic")+";color:"+(i?"initial":r.srcMethod[+n]),i?"":s+"color: initial ; font-weight: initial")}},randomFloat(){return(window.crypto||window.msCrypto)?.getRandomValues(new Uint32Array(1))[0]/4294967295||Math.random()},refactor(){chatgpt.code.refactor()},regenerate(){chatgpt.response.regenerate()},renderHTML(s){var i,e=/<([a-z\d]+)\b([^>]*)>([\s\S]*?)<\/\1>/g,c=/(\S+)=['"]?((?:.(?!['"]?\s+\S+=|[>']))+.)['"]?/g,t=s.childNodes;chatgpt.renderHTML.preWrapSet||(s.style.whiteSpace="pre-wrap",chatgpt.renderHTML.preWrapSet=!0,setTimeout(()=>{chatgpt.renderHTML.preWrapSet=!1},100));for(i of t)if(i.nodeType==Node.TEXT_NODE){var l=i.nodeValue,d=Array.from(l.matchAll(e));if(0<d.length){let e=d[0],[t,r,o,a]=e.slice(0,4),n=document.createElement(r);n.textContent=a;Array.from(o.matchAll(c)).forEach(e=>{var t=e[1],e=e[2].replace(/['"]/g,"");n.setAttribute(t,e)});var d=chatgpt.renderHTML(n),g=document.createTextNode(l.substring(0,e.index)),l=document.createTextNode(l.substring(e.index+t.length));s.replaceChild(g,i),s.insertBefore(d,g.nextSibling),s.insertBefore(l,d.nextSibling)}}else i.nodeType==Node.ELEMENT_NODE&&chatgpt.renderHTML(i);return s},async resend(){chatgpt.send(await chatgpt.getChatData("latest","msg","user","latest"))},response:{continue(){try{chatgpt.getContinueBtn().click()}catch(e){console.error(e.message)}},get(){return(window.location.href.startsWith("https://chatgpt.com/c/")?this.getFromDOM:this.getFromAPI).apply(null,arguments)},getFromAPI(e,t){return e=e||"latest",t=t||"latest",chatgpt.getChatData(e,"msg","chatgpt",t)},getFromDOM(e){var t=document.querySelectorAll('div[data-testid*="conversation-turn"]:nth-child(odd)'),r=e.toString().toLowerCase();let o="";return t.length?o=(o=(/last|final/.test(r)?t[t.length-1]:t[(Number.isInteger(e)?e:/^\d+/.test(r)?/^\d+/.exec(r)[0]:(/^(?:1|one|fir)(?:st)?$/.test(r)?1:/^(?:2|tw(?:o|en|el(?:ve|f))|seco)(?:nd|t[yi])?(?:e?th)?$/.test(r)?2:/^(?:3|th(?:ree|ir?))(?:rd|teen|t[yi])?(?:e?th)?$/.test(r)?3:/^(?:4|fou?r)(?:teen|t[yi])?(?:e?th)?$/.test(r)?4:/^(?:5|fi(?:ve|f))(?:teen|t[yi])?(?:e?th)?$/.test(r)?5:/^(?:6|six)(?:teen|t[yi])?(?:e?th)?$/.test(r)?6:/^(?:7|seven)(?:teen|t[yi])?(?:e?th)?$/.test(r)?7:/^(?:8|eight?)(?:teen|t[yi])?(?:e?th)?$/.test(r)?8:/^(?:9|nine?)(?:teen|t[yi])?(?:e?th)?$/.test(r)?9:/^(?:10|ten)(?:th)?$/.test(r)?10:1)*(/(ty|ieth)$/.test(r)?10:1)+(/teen(th)?$/.test(r)?10:0))-1]).textContent).replace(/^ChatGPT(?:ChatGPT)?/,""):console.error("No conversation found!")},getLast(){return chatgpt.getChatData("active","msg","chatgpt","latest")},regenerate(){try{chatgpt.getRegenerateBtn().click()}catch(e){console.error(e.message)}},stopGenerating(){try{chatgpt.getStopBtn().click()}catch(e){console.error(e.message)}}},reviewCode(){chatgpt.code.review()},scrollToBottom(){try{chatgpt.getScrollBtn().click()}catch(e){console.error(e.message)}},send(e,r=""){for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string!`);let o=chatgpt.getChatBox();if(!o)return console.error("Chatbar element not found!");var t=document.createElement("p");t.textContent=e,o.replaceChild(t,o.querySelector("p")),o.dispatchEvent(new Event("input",{bubbles:!0})),setTimeout(function e(){var t=chatgpt.getSendButton();t?.hasAttribute("disabled")?setTimeout(e,222):"click"==r.toLowerCase()||chatgpt.browser.isMobile()?t.click():o.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter",bubbles:!0}))},222)},sendInNewChat(e){if("string"!=typeof e)return console.error("Message must be a string!");try{chatgpt.getNewChatBtn().click()}catch(e){return console.error(e.message)}setTimeout(()=>{chatgpt.send(e)},500)},settings:{scheme:{isDark(){return document.documentElement.classList.contains("dark")},isLight(){return document.documentElement.classList.contains("light")},set(e){var t=["dark","light","system"];if(!e)return console.error("Please specify a scheme value!");if(!t.includes(e))return console.error(`Invalid scheme value. Valid values are [${t}]`);let r=e;"system"==e&&(r=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),localStorage.setItem("theme",e),console.info(`Scheme set to ${e.toUpperCase()}.`),document.documentElement.classList.contains(r)||this.toggle()},toggle(){var[e,t]=this.isDark()?["dark","light"]:["light","dark"];document.documentElement.classList.replace(e,t),document.documentElement.style.colorScheme=t,localStorage.setItem("theme",t)}}},async sentiment(e,t){for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send("What is the sentiment of the following text"+(t?` towards the entity ${t},`:"")+" from strongly negative to strongly positive?\n\n"+e),console.info("Analyzing sentiment..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},setScheme(e){chatgpt.settings.scheme.set(e)},shareChat(s,i="clipboard"){var e=["alert","notify","notification","clipboard","copy"];if(!e.includes(i))return console.error("Invalid method '"+i+"' passed. Valid methods are ["+e+"].");return new Promise(r=>{chatgpt.getAccessToken().then(t=>{var a;a=t,new Promise((t,r)=>{let o=new XMLHttpRequest;chatgpt.getChatData(s).then(e=>{o.open("GET",chatgpt.endpoints.openAI.chat+"/"+e.id,!0),o.setRequestHeader("Content-Type","application/json"),o.setRequestHeader("Authorization","Bearer "+a),o.onload=()=>200!==o.status?r("🤖 chatgpt.js >> Request failed. Cannot retrieve chat node."):t(JSON.parse(o.responseText).current_node),o.send()})}).then(e=>{var a,n;a=t,n=e,new Promise((t,r)=>{let o=new XMLHttpRequest;chatgpt.getChatData(s).then(e=>{o.open("POST",chatgpt.endpoints.openAI.share_create,!0),o.setRequestHeader("Content-Type","application/json"),o.setRequestHeader("Authorization","Bearer "+a),o.onload=()=>200!==o.status?r("🤖 chatgpt.js >> Request failed. Cannot initialize share chat."):t(JSON.parse(o.responseText)),o.send(JSON.stringify({current_node_id:n,conversation_id:e.id,is_anonymous:!0}))})}).then(e=>{var o,a;o=t,a=e,new Promise((e,t)=>{let r=new XMLHttpRequest;r.open("PATCH",chatgpt.endpoints.openAI.share+"/"+a.share_id,!0),r.setRequestHeader("Content-Type","application/json"),r.setRequestHeader("Authorization","Bearer "+o),r.onload=()=>200!==r.status?t("🤖 chatgpt.js >> Request failed. Cannot share chat."):(console.info(`Chat shared at '${a.share_url}'`),e()),r.send(JSON.stringify({share_id:a.share_id,highlighted_message_id:a.highlighted_message_id,title:a.title,is_public:!0,is_visible:a.is_visible,is_anonymous:a.is_anonymous}))}).then(()=>{["copy","clipboard"].includes(i)?navigator.clipboard.writeText(e.share_url):chatgpt.alert("🚀 Share link created!",'"'+e.title+'" is available at: <a target="blank" rel="noopener" href="'+e.share_url+'" >'+e.share_url+"</a>",[function(){window.open(e.share_url,"_blank","noopener")},function(){navigator.clipboard.writeText(e.share_url)}]),r(e.share_url)})})})})})},showFooter(){chatgpt.footer.show()},showHeader(){chatgpt.header.show()},sidebar:{elements:[],observer:{},activateObserver(){if(this.observer instanceof MutationObserver)try{this.observer.disconnect()}catch(e){}if(!this.elements.length)return console.error("🤖 chatgpt.js >> No elements to append!");let t;for(var e of document.querySelectorAll("nav a"))if(/.*chat/.exec(e.text)[0]){t=e.classList,e.parentNode.style.margin="2px 0";break}this.elements.forEach(e=>{e.setAttribute("class",t),e.style.maxHeight=e.style.minHeight="44px",e.style.margin="2px 0"});let r=document.querySelector("nav");if(!r)return console.error("Sidebar element not found!");this.observer=new MutationObserver(e=>{e.forEach(e=>{("childList"==e.type&&e.addedNodes.length||"attributes"==e.type&&"data-chatgptjs"==e.attributeName)&&this.elements.forEach(e=>{if(!r.contains(e))try{r.insertBefore(e,r.querySelector("a").parentNode)}catch(e){console.error(e)}})})}),this.observer.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0})},append(e,t={}){var r=["button","dropdown"];if(!e||"string"!=typeof e)return console.error("🤖 chatgpt.js >> Please supply a valid string element name!");if(e=e.toLowerCase(),!r.includes(e))return console.error(`🤖 chatgpt.js >> Invalid element! Valid elements are [${r}]`);let 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";r=document.createElement("img");r.src=t?.icon&&"string"==typeof t.icon?t.icon:chatgpt.endpoints.assets+"/starters/chrome/extension/icons/icon128.png",r.width=18,o.insertBefore(r,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},exists(){return!!chatgpt.getNewChatLink()},hide(){this.isOn()?this.toggle():console.info("Sidebar already hidden!")},show(){this.isOff()?this.toggle():console.info("Sidebar already shown!")},isOff(){return!this.isOn()},isOn(){var e=chatgpt.sidebar.exists()?document.querySelector("body script + div > div"):null;return e?chatgpt.browser.isMobile()?"hidden"==document.documentElement.style.overflow:"hidden"!=e.style.visibility&&"0px"!=e.style.width:(console.error("Sidebar element not found!"),!1)},toggle(){var e,t=chatgpt.browser.isMobile(),r=t?()=>!0:e=>e.querySelector('svg path[d^="M8.857"]');for(e of document.querySelectorAll(t?"button":"nav button"))if(r(e))return void e.click();console.error("Sidebar toggle not found!")},async isLoaded(t=5e3){await chatgpt.isLoaded();var e=new Promise(e=>setTimeout(()=>{e(!1)},t)),r=new Promise(r=>{chatgpt.getNewChatLink()?r(!0):new MutationObserver((e,t)=>{chatgpt.getNewChatLink()&&(t.disconnect(),r(!0))}).observe(document.body,{childList:!0,subtree:!0})});return Promise.race([r,e])}},startNewChat(){try{chatgpt.getNewChatBtn().click()}catch(e){console.error(e.message)}},stop(){chatgpt.response.stopGenerating()},async suggest(e,t){if(!e)return console.error("ideaType (1st argument) not supplied(e.g. 'gifts', 'names', 'recipes', etc.)");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send("Suggest some names. "+(t||"")),console.info(`Creating ${e}...`),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},speak(e,t={}){var r,{voice:o=2,pitch:a=2,speed:n=1.1}=t;if("string"!=typeof e)return console.error("Message must be a string!");for(r in t){var s=t[r];if("number"!=typeof s&&!/^\d+$/.test(s))return console.error(`Invalid ${r} index '${s}'. Must be a number!`)}try{var i=speechSynthesis.getVoices(),c=new SpeechSynthesisUtterance;c.text=e,c.voice=i[o],c.pitch=a,c.rate=n,speechSynthesis.speak(c)}catch(e){console.error(e)}},async summarize(e){return e?"string"!=typeof e?console.error("Text argument must be a string!"):(chatgpt.send("Summarize the following text:\n\n"+e),console.info("Summarizing text..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")):console.error("Text (1st) argument not supplied. Pass some text!")},toggleScheme(){chatgpt.settings.scheme.toggle()},async translate(e,t){if(!e)return console.error("Text (1st) argument not supplied. Pass some text!");if(!t)return console.error("outputLang (2nd) argument not supplied. Pass a language!");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string!`);return chatgpt.send("Translate the following text to "+t+". Only reply with the translation.\n\n"+e),console.info("Translating text..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},unminify(){chatgpt.code.unminify()},uuidv4(){let r=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{var t=(r+window.crypto.getRandomValues(new Uint32Array(1))[0]/(Math.pow(2,32)-1)*16)%16|0;return r=Math.floor(r/16),("x"==e?t:3&t|8).toString(16)})},writeCode(){chatgpt.code.write()}},cjsBtnActions=(chatgpt.scheme={...chatgpt.settings.scheme},["click","get"]),cjsTargetTypes=["button","link","div","response"];for(let t of cjsBtnActions)chatgpt[t+"Button"]=function(r){var e=/^[.#]/.test(r)?document.querySelector(r):/send/i.test(r)?document.querySelector('form button[class*="bottom"]'):/scroll/i.test(r)?document.querySelector('button[class*="cursor"]'):(()=>{for(var e of document.querySelectorAll("button"))if(e.textContent.toLowerCase().includes(r.toLowerCase()))return e;for(var t of document.querySelectorAll("nav a"))if(t.textContent.toLowerCase().includes(r.toLowerCase()))return t})();if("click"!=t)return e;e.click()};let cjsFuncAliases=[["actAs","actas","act","become","persona","premadePrompt","preMadePrompt","prePrompt","preprompt","roleplay","rolePlay","rp"],["activateAutoRefresh","activateAutoRefresher","activateRefresher","activateSessionRefresher","autoRefresh","autoRefresher","autoRefreshSession","refresher","sessionRefresher"],["continue","continueChat","continueGenerating","continueResponse"],["deactivateAutoRefresh","deactivateAutoRefresher","deactivateRefresher","deactivateSessionRefresher"],["detectLanguage","getLanguage"],["executeCode","codeExecute"],["exists","isAvailable","isExistent","isPresent"],["exportChat","chatExport","export"],["getFooterDiv","getFooter"],["getHeaderDiv","getHeader"],["getLastPrompt","getLastQuery","getMyLastMsg","getMyLastQuery"],["getContinueGeneratingButton","getContinueButton"],["getScrollToBottomButton","getScrollButton"],["getStopGeneratingButton","getStopButton"],["getTextarea","getTextArea","getChatbar","getChatBar","getChatbox","getChatBox"],["isFullScreen","isFullscreen","isfullscreen"],["isLoaded","isloaded"],["logOut","logout","logOff","logoff","signOut","signout","signOff","signoff"],["minify","codeMinify","minifyCode"],["new","newChat","startNewChat"],["obfuscate","codeObfuscate","obfuscateCode"],["printAllFunctions","showAllFunctions"],["refactor","codeRefactor","refactorCode"],["refreshReply","regenerate","regenerateReply"],["refreshSession","sessionRefresh"],["renderHTML","renderHtml","renderLinks","renderTags"],["reviewCode","codeReview"],["send","sendChat","sendMsg"],["sendInNewChat","sendNewChat"],["sentiment","analyzeSentiment","sentimentAnalysis"],["startNewChat","new","newChat"],["stop","stopChat","stopGenerating","stopResponse"],["suggest","suggestion","recommend"],["toggleAutoRefresh","toggleAutoRefresher","toggleRefresher","toggleSessionRefresher"],["toggleScheme","toggleMode"],["translate","translation","translator"],["unminify","unminifyCode","codeUnminify"],["writeCode","codeWrite"]],cjsFuncSynonyms=[["account","acct"],["activate","turnOn"],["analyze","check","evaluate","review"],["ask","send","submit"],["button","btn"],["continue","resume"],["chats","history"],["chat","conversation","convo"],["clear","delete","remove"],["data","details"],["deactivate","deActivate","turnOff"],["execute","interpret","interpreter","run"],["firefox","ff"],["generating","generation"],["minify","uglify"],["refactor","rewrite"],["regenerate","regen"],["render","parse"],["reply","response"],["sentiment","attitude","emotion","feeling","opinion","perception"],["speak","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(let o in chatgpt){for(let r of cjsFuncAliases)if(r.includes(o))if(r.some(e=>e.includes("."))){let t=r.find(e=>e.includes(".")).split(".")[1];for(let e of r)/^(\w+)/.exec(e)[1]!==o&&(chatgpt[e]=chatgpt[o][t])}else for(let e of r)e!==o&&(chatgpt[e]=chatgpt[o]);do{var newFunctionsCreated=!1;for(let a in chatgpt)if("function"==typeof chatgpt[a]){let o=a.split(/(?=[A-Zs])/);for(let r of o){let e=[].concat(...cjsFuncSynonyms.filter(e=>e.includes(r.toLowerCase())).map(e=>e.filter(e=>e!==r.toLowerCase())));for(let t of e){let e=camelCaser(o.map(e=>e==r?t:e));chatgpt[e]||(chatgpt[e]=chatgpt[a],newFunctionsCreated=!0)}}}}while(newFunctionsCreated)}let consolePrefix="🤖 chatgpt.js >> ",ogError=console.error,ogInfo=console.info;console.error=(...e)=>{e[0].startsWith(consolePrefix)?ogError(...e):ogError(consolePrefix+e[0],...e.slice(1))},console.info=e=>{e.startsWith(consolePrefix)?ogInfo(e):ogInfo(consolePrefix+e)};try{window.chatgpt=chatgpt}catch(e){}try{module.exports=chatgpt}catch(e){}
|
|
13
|
+
`+o,new Promise(r=>{chatgpt.getAccessToken().then(async e=>{var t=await this.fetchData();return"user"==a?t.about_user_message+=o:"chatgpt"==a&&(t.about_model_message+=o),await this.sendRequest("POST",e,t),r()})})):console.error(`Invalid target ${a}. Valid targets are [${e}]`)):console.error("Please provide a valid target!")):console.error("Please provide an instruction")},clear(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(r=>{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),r()})}):console.error(`Invalid target ${o}. Valid targets are [${e}]`)):console.error("Please provide a valid target!")},fetchData(){return new Promise(t=>{chatgpt.getAccessToken().then(async e=>t(await this.sendRequest("GET",e)))})},sendRequest(a,e,n){for(let e=0;e<arguments.length-1;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string`);var t=["POST","GET"];return(a=(a||"").trim().toUpperCase())&&t.includes(a)?e?n&&"object"!=typeof n?console.error(`Invalid body data type. Got ${typeof n}, expected object`):new Promise((t,r)=>{let o=new XMLHttpRequest;o.open(a,chatgpt.endpoints.openAI.instructions,!0),o.setRequestHeader("Accept-Language","en-US"),o.setRequestHeader("Authorization","Bearer "+e),"POST"==a&&o.setRequestHeader("Content-Type","application/json"),o.onload=()=>{var e=JSON.parse(o.responseText);return 422===o.status?r("🤖 chatgpt.js >> Character limit exceeded. Custom instructions can have a maximum length of 1500 characters."):403===o.status&&"content_policy"==e.detail.reason?r("🤖 chatgpt.js >> "+e.detail.description):200!==o.status?r("🤖 chatgpt.js >> Request failed. Cannot contact custom instructions endpoint."):(console.info("Custom instructions successfully contacted with method "+a),t(e||{}))},o.send(JSON.stringify(n)||"")}):console.error("Please provide a valid access token!"):console.error("Valid methods are "+t)},turnOff(){return new Promise(r=>{chatgpt.getAccessToken().then(async e=>{var t=await this.fetchData();return t.enabled=!1,await this.sendRequest("POST",e,t),r()})})},turnOn(){return new Promise(r=>{chatgpt.getAccessToken().then(async e=>{var t=await this.fetchData();return t.enabled=!0,await this.sendRequest("POST",e,t),r()})})},toggle(){return new Promise(t=>{this.fetchData().then(async e=>(await(e.enabled?this.turnOff():this.turnOn()),t()))})}},isDarkMode(){return document.documentElement.classList.toString().includes("dark")},isFullScreen(){return chatgpt.browser.isFullScreen()},async isIdle(t=null){let e={childList:!0,subtree:!0},o="div[data-message-author-role]";var r=t?new Promise(e=>setTimeout(()=>e(!1),t)):null,a=(async()=>(await new Promise(r=>{document.querySelector(o)?r():new MutationObserver((e,t)=>{document.querySelector(o)&&(t.disconnect(),r())}).observe(document.body,e)}),await new Promise(r=>{new MutationObserver((e,t)=>{chatgpt.getStopBtn()&&(t.disconnect(),r())}).observe(document.body,e)}),new Promise(r=>{new MutationObserver((e,t)=>{chatgpt.getStopBtn()||(t.disconnect(),r(!0))}).observe(document.body,e)})))();return r?Promise.race([a,r]):a},async isLoaded(t=null){var e=t?new Promise(e=>setTimeout(()=>e(!1),t)):null,r=new Promise(r=>{chatgpt.getNewChatBtn()?r(!0):new MutationObserver((e,t)=>{chatgpt.getNewChatBtn()&&(t.disconnect(),r(!0))}).observe(document.body,{childList:!0,subtree:!0})});return e?Promise.race([r,e]):r},isLightMode(){return document.documentElement.classList.toString().includes("light")},logout(){window.location.href="https://chat.openai.com/auth/logout"},menu:{elements:[],addedEvent:!1,append(e,t={}){var r=["button","dropdown"];if(!e||"string"!=typeof e)return console.error("🤖 chatgpt.js >> Please supply a valid string element name!");if(e=e.toLowerCase(),!r.includes(e))return console.error(`🤖 chatgpt.js >> Invalid element! Valid elements are [${r}]`);let 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";r=document.createElement("img");r.src=t?.icon&&"string"==typeof t.icon?t.icon:chatgpt.endpoints.assets+"/starters/chrome/extension/icons/icon128.png",r.width=18,o.insertBefore(r,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)})}let a=()=>{var e,t=document.querySelectorAll('a[role="menuitem"]');let r;for(e of t)if("Settings"==e.textContent){r=e.classList;break}let o=t[0].parentNode;chatgpt.menu.elements.forEach(e=>{if(e.setAttribute("class",r),!o.contains(e))try{o.insertBefore(e,o.firstChild)}catch(e){console.error(e)}})};this.elements.push(o);r=document.querySelector('nav button[id*="headless"]');return this.addedEvent||(r?.addEventListener("click",()=>{setTimeout(a,25)}),this.addedEvent=!0),o.id},close(){try{document.querySelector('nav [id*="menu-button"][aria-expanded="true"]').click()}catch(e){console.error(e.message)}},open(){try{document.querySelector('nav [id*="menu-button"][aria-expanded="false"]').click()}catch(e){console.error(e.message)}}},minify(){chatgpt.code.minify()},notify(e,t,r,o){r=r?+r:1.75;let a=document.createElement("div");a.id=Math.floor(1e6*chatgpt.randomFloat())+Date.now(),a.classList.add("chatgpt-notif"),a.innerText=e,document.body.append(a);var e=document.createElement("div"),n=(e.title="Dismiss",e.classList.add("notif-close-btn","no-mobile-tap-outline"),document.createElementNS("http://www.w3.org/2000/svg","svg")),s=(n.setAttribute("height","8px"),n.setAttribute("viewBox","0 0 14 14"),n.setAttribute("fill","none"),n.style.height=n.style.width="8px",document.createElementNS("http://www.w3.org/2000/svg","path"));s.setAttribute("fill-rule","evenodd"),s.setAttribute("clip-rule","evenodd"),s.setAttribute("fill","white"),s.setAttribute("d","M13.7071 1.70711C14.0976 1.31658 14.0976 0.683417 13.7071 0.292893C13.3166 -0.0976312 12.6834 -0.0976312 12.2929 0.292893L7 5.58579L1.70711 0.292893C1.31658 -0.0976312 0.683417 -0.0976312 0.292893 0.292893C-0.0976312 0.683417 -0.0976312 1.31658 0.292893 1.70711L5.58579 7L0.292893 12.2929C-0.0976312 12.6834 -0.0976312 13.3166 0.292893 13.7071C0.683417 14.0976 1.31658 14.0976 1.70711 13.7071L7 8.41421L12.2929 13.7071C12.6834 14.0976 13.3166 14.0976 13.7071 13.7071C14.0976 13.3166 14.0976 12.6834 13.7071 12.2929L8.41421 7L13.7071 1.70711Z"),n.append(s),e.append(n),a.append(e),a.isTop=!t||!/low|bottom/i.test(t),a.isRight=!t||!/left/i.test(t),a.quadrant=(a.isTop?"top":"bottom")+(a.isRight?"Right":"Left");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 {.no-mobile-tap-outline { outline: none ; -webkit-tap-highlight-color: transparent }background-color: black ; padding: 10px 13px 10px 18px ; border-radius: 11px ; border: 1px solid #f5f5f7 ;opacity: 0 ; position: fixed ; z-index: 9999 ; font-size: 1.8rem ; color: white ;-webkit-user-select: none ; -moz-user-select: none ; -ms-user-select: none ; user-select: none ;"+`transform: translateX(${a.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[a.quadrant].push(a.id),localStorage.notifyProps=JSON.stringify(c),a.style.top=a.isTop?23..toString()+"px":"",a.style.bottom=a.isTop?"":23..toString()+"px",a.style.right=a.isRight?27..toString()+"px":"",a.style.left=a.isRight?"":27..toString()+"px";s=c.queue[a.quadrant];if(1<s.length)try{for(var l of s.slice(0,-1)){var d=document.getElementById(l),g=d.style.top?"top":"bottom",u=+/\d+/.exec(d.style[g])[0]+5+d.getBoundingClientRect().height;d.style[g]=u+"px"}}catch(e){}setTimeout(()=>{a.style.opacity=chatgpt.isDarkMode()?.8:.67,a.style.transform="translateX(0)",a.style.transition="transform 0.15s ease, opacity 0.15s ease"},10);e=()=>{a.style.animation="notif-zoom-fade-out 0.35s ease-out",clearTimeout(p)};let p=setTimeout(e,1e3*(r<.35?0:r-.35));return n.onclick=e,a.onanimationend=()=>{a.remove(),(c=JSON.parse(localStorage.notifyProps)).queue[a.quadrant].shift(),localStorage.notifyProps=JSON.stringify(c)},a},obfuscate(){chatgpt.code.obfuscate()},printAllFunctions(){let r={cmdPrompt:["#ff00ff","#00ff00"],objName:["#0611e9","#f9ee16"],methodName:["#005aff","#ffa500"],entryType:["#467e06","#b981f9"],srcMethod:["#ff0000","#00ffff"]};Object.keys(r).forEach(e=>{r[e][1]=r[e][1]||"#"+(16777215^Number("0x1"+r[e][0].replace(/^#/,""))).toString(16).substring(1).toUpperCase()});var e=[];for(let t in this)if("function"==typeof this[t]){var o=!Object.keys(this).find(e=>Object.keys(this[e]).includes(this[t].name));e.push([o?"chatgpt":"other",t])}else if("object"==typeof this[t])for(var a in this[t])"function"==typeof this[t][a]&&e.push([t,a]);e.sort((e,t)=>e[0].localeCompare(t[0])||e[1].localeCompare(t[1]));var n=window.matchMedia("(prefers-color-scheme: dark)").matches,s="font-family: monospace ; font-size: larger ; ";console.log("\n%c🤖 chatgpt.js methods\n","font-family: sans-serif ; font-size: xxx-large ; font-weight: bold");for(let t of e){var i=/chatgpt|other/.test(t[0]),c="chatgpt"==t[0]?this[t[1]].name:"other"!==t[0]?t[0]+"."+t[1]:Object.keys(this).find(e=>Object.keys(this[e]).includes(this[t[1]].name))+"."+this[t[1]].name,l="AsyncFunction"==this[t[1]]?.constructor.name;console.log("%c>> %c"+(i?"":t[0]+".%c")+t[1]+" - https://chatgptjs.org/userguide/"+/(?:.*\.)?(.*)/.exec(c)[1].toLowerCase()+(l?"-async":"")+"\n%c[%c"+("chatgpt"==t[0]&&t[1]==this[t[1]].name||!i?"Function":"Alias of")+"%c: %c"+c+"%c]",s+"font-weight: bold ; color:"+r.cmdPrompt[+n],s+"font-weight: bold ;color:"+r[i?"methodName":"objName"][+n],s+"font-weight: "+(i?"initial":"bold")+";color:"+(i?"initial":r.methodName[+n]),s+"font-weight: "+(i?"bold":"initial")+";color:"+(i?r.entryType[+n]:"initial"),s+"font-weight: "+(i?"initial":"bold")+";color:"+(i?"initial":r.entryType[+n]),s+(i?"font-style: italic":"font-weight: initial")+";color:"+(i?r.srcMethod[+n]:"initial"),s+(i?"font-weight: initial":"font-style: italic")+";color:"+(i?"initial":r.srcMethod[+n]),i?"":s+"color: initial ; font-weight: initial")}},randomFloat(){return(window.crypto||window.msCrypto)?.getRandomValues(new Uint32Array(1))[0]/4294967295||Math.random()},refactor(){chatgpt.code.refactor()},regenerate(){chatgpt.response.regenerate()},renderHTML(s){var i,e=/<([a-z\d]+)\b([^>]*)>([\s\S]*?)<\/\1>/g,c=/(\S+)=['"]?((?:.(?!['"]?\s+\S+=|[>']))+.)['"]?/g,t=s.childNodes;chatgpt.renderHTML.preWrapSet||(s.style.whiteSpace="pre-wrap",chatgpt.renderHTML.preWrapSet=!0,setTimeout(()=>{chatgpt.renderHTML.preWrapSet=!1},100));for(i of t)if(i.nodeType==Node.TEXT_NODE){var l=i.nodeValue,d=Array.from(l.matchAll(e));if(0<d.length){let e=d[0],[t,r,o,a]=e.slice(0,4),n=document.createElement(r);n.textContent=a;Array.from(o.matchAll(c)).forEach(e=>{var t=e[1],e=e[2].replace(/['"]/g,"");n.setAttribute(t,e)});var d=chatgpt.renderHTML(n),g=document.createTextNode(l.substring(0,e.index)),l=document.createTextNode(l.substring(e.index+t.length));s.replaceChild(g,i),s.insertBefore(d,g.nextSibling),s.insertBefore(l,d.nextSibling)}}else i.nodeType==Node.ELEMENT_NODE&&chatgpt.renderHTML(i);return s},async resend(){chatgpt.send(await chatgpt.getChatData("latest","msg","user","latest"))},response:{continue(){try{chatgpt.getContinueBtn().click()}catch(e){console.error(e.message)}},get(){return(window.location.href.startsWith("https://chatgpt.com/c/")?this.getFromDOM:this.getFromAPI).apply(null,arguments)},getFromAPI(e,t){return e=e||"latest",t=t||"latest",chatgpt.getChatData(e,"msg","chatgpt",t)},getFromDOM(e){var t=document.querySelectorAll('div[data-testid*="conversation-turn"]:nth-child(odd)'),r=e.toString().toLowerCase();let o="";return t.length?o=(o=(/last|final/.test(r)?t[t.length-1]:t[(Number.isInteger(e)?e:/^\d+/.test(r)?/^\d+/.exec(r)[0]:(/^(?:1|one|fir)(?:st)?$/.test(r)?1:/^(?:2|tw(?:o|en|el(?:ve|f))|seco)(?:nd|t[yi])?(?:e?th)?$/.test(r)?2:/^(?:3|th(?:ree|ir?))(?:rd|teen|t[yi])?(?:e?th)?$/.test(r)?3:/^(?:4|fou?r)(?:teen|t[yi])?(?:e?th)?$/.test(r)?4:/^(?:5|fi(?:ve|f))(?:teen|t[yi])?(?:e?th)?$/.test(r)?5:/^(?:6|six)(?:teen|t[yi])?(?:e?th)?$/.test(r)?6:/^(?:7|seven)(?:teen|t[yi])?(?:e?th)?$/.test(r)?7:/^(?:8|eight?)(?:teen|t[yi])?(?:e?th)?$/.test(r)?8:/^(?:9|nine?)(?:teen|t[yi])?(?:e?th)?$/.test(r)?9:/^(?:10|ten)(?:th)?$/.test(r)?10:1)*(/(ty|ieth)$/.test(r)?10:1)+(/teen(th)?$/.test(r)?10:0))-1]).textContent).replace(/^ChatGPT(?:ChatGPT)?/,""):console.error("No conversation found!")},getLast(){return chatgpt.getChatData("active","msg","chatgpt","latest")},regenerate(){try{chatgpt.getRegenerateBtn().click()}catch(e){console.error(e.message)}},stopGenerating(){try{chatgpt.getStopBtn().click()}catch(e){console.error(e.message)}}},reviewCode(){chatgpt.code.review()},scrollToBottom(){try{chatgpt.getScrollBtn().click()}catch(e){console.error(e.message)}},send(e,r=""){for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string!`);let o=chatgpt.getChatBox();if(!o)return console.error("Chatbar element not found!");var t=document.createElement("p");t.textContent=e,o.replaceChild(t,o.querySelector("p")),o.dispatchEvent(new Event("input",{bubbles:!0})),setTimeout(function e(){var t=chatgpt.getSendButton();t?.hasAttribute("disabled")?setTimeout(e,222):"click"==r.toLowerCase()||chatgpt.browser.isMobile()?t.click():o.dispatchEvent(new KeyboardEvent("keydown",{key:"Enter",bubbles:!0}))},222)},sendInNewChat(e){if("string"!=typeof e)return console.error("Message must be a string!");try{chatgpt.getNewChatBtn().click()}catch(e){return console.error(e.message)}setTimeout(()=>{chatgpt.send(e)},500)},settings:{scheme:{isDark(){return document.documentElement.classList.contains("dark")},isLight(){return document.documentElement.classList.contains("light")},set(e){var t=["dark","light","system"];if(!e)return console.error("Please specify a scheme value!");if(!t.includes(e))return console.error(`Invalid scheme value. Valid values are [${t}]`);let r=e;"system"==e&&(r=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),localStorage.setItem("theme",e),console.info(`Scheme set to ${e.toUpperCase()}.`),document.documentElement.classList.contains(r)||this.toggle()},toggle(){var[e,t]=this.isDark()?["dark","light"]:["light","dark"];document.documentElement.classList.replace(e,t),document.documentElement.style.colorScheme=t,localStorage.setItem("theme",t)}}},async sentiment(e,t){for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send("What is the sentiment of the following text"+(t?` towards the entity ${t},`:"")+" from strongly negative to strongly positive?\n\n"+e),console.info("Analyzing sentiment..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},setScheme(e){chatgpt.settings.scheme.set(e)},shareChat(s,i="clipboard"){var e=["alert","notify","notification","clipboard","copy"];if(!e.includes(i))return console.error("Invalid method '"+i+"' passed. Valid methods are ["+e+"].");return new Promise(r=>{chatgpt.getAccessToken().then(t=>{var a;a=t,new Promise((t,r)=>{let o=new XMLHttpRequest;chatgpt.getChatData(s).then(e=>{o.open("GET",chatgpt.endpoints.openAI.chat+"/"+e.id,!0),o.setRequestHeader("Content-Type","application/json"),o.setRequestHeader("Authorization","Bearer "+a),o.onload=()=>200!==o.status?r("🤖 chatgpt.js >> Request failed. Cannot retrieve chat node."):t(JSON.parse(o.responseText).current_node),o.send()})}).then(e=>{var a,n;a=t,n=e,new Promise((t,r)=>{let o=new XMLHttpRequest;chatgpt.getChatData(s).then(e=>{o.open("POST",chatgpt.endpoints.openAI.share_create,!0),o.setRequestHeader("Content-Type","application/json"),o.setRequestHeader("Authorization","Bearer "+a),o.onload=()=>200!==o.status?r("🤖 chatgpt.js >> Request failed. Cannot initialize share chat."):t(JSON.parse(o.responseText)),o.send(JSON.stringify({current_node_id:n,conversation_id:e.id,is_anonymous:!0}))})}).then(e=>{var o,a;o=t,a=e,new Promise((e,t)=>{let r=new XMLHttpRequest;r.open("PATCH",chatgpt.endpoints.openAI.share+"/"+a.share_id,!0),r.setRequestHeader("Content-Type","application/json"),r.setRequestHeader("Authorization","Bearer "+o),r.onload=()=>200!==r.status?t("🤖 chatgpt.js >> Request failed. Cannot share chat."):(console.info(`Chat shared at '${a.share_url}'`),e()),r.send(JSON.stringify({share_id:a.share_id,highlighted_message_id:a.highlighted_message_id,title:a.title,is_public:!0,is_visible:a.is_visible,is_anonymous:a.is_anonymous}))}).then(()=>{["copy","clipboard"].includes(i)?navigator.clipboard.writeText(e.share_url):chatgpt.alert("🚀 Share link created!",'"'+e.title+'" is available at: <a target="blank" rel="noopener" href="'+e.share_url+'" >'+e.share_url+"</a>",[function(){window.open(e.share_url,"_blank","noopener")},function(){navigator.clipboard.writeText(e.share_url)}]),r(e.share_url)})})})})})},showFooter(){chatgpt.footer.show()},showHeader(){chatgpt.header.show()},sidebar:{elements:[],observer:{},activateObserver(){if(this.observer instanceof MutationObserver)try{this.observer.disconnect()}catch(e){}if(!this.elements.length)return console.error("🤖 chatgpt.js >> No elements to append!");let t;for(var e of document.querySelectorAll("nav a"))if(/.*chat/.exec(e.text)[0]){t=e.classList,e.parentNode.style.margin="2px 0";break}this.elements.forEach(e=>{e.setAttribute("class",t),e.style.maxHeight=e.style.minHeight="44px",e.style.margin="2px 0"});let r=document.querySelector("nav");if(!r)return console.error("Sidebar element not found!");this.observer=new MutationObserver(e=>{e.forEach(e=>{("childList"==e.type&&e.addedNodes.length||"attributes"==e.type&&"data-chatgptjs"==e.attributeName)&&this.elements.forEach(e=>{if(!r.contains(e))try{r.insertBefore(e,r.querySelector("a").parentNode)}catch(e){console.error(e)}})})}),this.observer.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0})},append(e,t={}){var r=["button","dropdown"];if(!e||"string"!=typeof e)return console.error("🤖 chatgpt.js >> Please supply a valid string element name!");if(e=e.toLowerCase(),!r.includes(e))return console.error(`🤖 chatgpt.js >> Invalid element! Valid elements are [${r}]`);let 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";r=document.createElement("img");r.src=t?.icon&&"string"==typeof t.icon?t.icon:chatgpt.endpoints.assets+"/starters/chrome/extension/icons/icon128.png",r.width=18,o.insertBefore(r,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},exists(){return!!chatgpt.getNewChatLink()},hide(){this.isOn()?this.toggle():console.info("Sidebar already hidden!")},show(){this.isOff()?this.toggle():console.info("Sidebar already shown!")},isOff(){return!this.isOn()},isOn(){var e=chatgpt.sidebar.exists()?document.querySelector('[class*="sidebar"]'):null;return e?chatgpt.browser.isMobile()?"hidden"==document.documentElement.style.overflow:"hidden"!=e.style.visibility&&"0px"!=e.style.width:(console.error("Sidebar element not found!"),!1)},toggle(){var e,t=chatgpt.browser.isMobile(),r=t?()=>!0:e=>e.querySelector('svg path[d^="M8.857"]');for(e of document.querySelectorAll(t?"button":"nav button"))if(r(e))return void e.click();console.error("Sidebar toggle not found!")},async isLoaded(t=5e3){await chatgpt.isLoaded();var e=new Promise(e=>setTimeout(()=>{e(!1)},t)),r=new Promise(r=>{chatgpt.getNewChatLink()?r(!0):new MutationObserver((e,t)=>{chatgpt.getNewChatLink()&&(t.disconnect(),r(!0))}).observe(document.body,{childList:!0,subtree:!0})});return Promise.race([r,e])}},startNewChat(){try{chatgpt.getNewChatBtn().click()}catch(e){console.error(e.message)}},stop(){chatgpt.response.stopGenerating()},async suggest(e,t){if(!e)return console.error("ideaType (1st argument) not supplied(e.g. 'gifts', 'names', 'recipes', etc.)");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send("Suggest some names. "+(t||"")),console.info(`Creating ${e}...`),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},speak(e,t={}){var r,{voice:o=2,pitch:a=2,speed:n=1.1}=t;if("string"!=typeof e)return console.error("Message must be a string!");for(r in t){var s=t[r];if("number"!=typeof s&&!/^\d+$/.test(s))return console.error(`Invalid ${r} index '${s}'. Must be a number!`)}try{var i=speechSynthesis.getVoices(),c=new SpeechSynthesisUtterance;c.text=e,c.voice=i[o],c.pitch=a,c.rate=n,speechSynthesis.speak(c)}catch(e){console.error(e)}},async summarize(e){return e?"string"!=typeof e?console.error("Text argument must be a string!"):(chatgpt.send("Summarize the following text:\n\n"+e),console.info("Summarizing text..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")):console.error("Text (1st) argument not supplied. Pass some text!")},toggleScheme(){chatgpt.settings.scheme.toggle()},async translate(e,t){if(!e)return console.error("Text (1st) argument not supplied. Pass some text!");if(!t)return console.error("outputLang (2nd) argument not supplied. Pass a language!");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string!`);return chatgpt.send("Translate the following text to "+t+". Only reply with the translation.\n\n"+e),console.info("Translating text..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},unminify(){chatgpt.code.unminify()},uuidv4(){let r=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{var t=(r+window.crypto.getRandomValues(new Uint32Array(1))[0]/(Math.pow(2,32)-1)*16)%16|0;return r=Math.floor(r/16),("x"==e?t:3&t|8).toString(16)})},writeCode(){chatgpt.code.write()}},cjsBtnActions=(chatgpt.scheme={...chatgpt.settings.scheme},["click","get"]),cjsTargetTypes=["button","link","div","response"];for(let t of cjsBtnActions)chatgpt[t+"Button"]=function(r){var e=/^[.#]/.test(r)?document.querySelector(r):/send/i.test(r)?document.querySelector('form button[class*="bottom"]'):/scroll/i.test(r)?document.querySelector('button[class*="cursor"]'):(()=>{for(var e of document.querySelectorAll("button"))if(e.textContent.toLowerCase().includes(r.toLowerCase()))return e;for(var t of document.querySelectorAll("nav a"))if(t.textContent.toLowerCase().includes(r.toLowerCase()))return t})();if("click"!=t)return e;e.click()};let cjsFuncAliases=[["actAs","actas","act","become","persona","premadePrompt","preMadePrompt","prePrompt","preprompt","roleplay","rolePlay","rp"],["activateAutoRefresh","activateAutoRefresher","activateRefresher","activateSessionRefresher","autoRefresh","autoRefresher","autoRefreshSession","refresher","sessionRefresher"],["continue","continueChat","continueGenerating","continueResponse"],["deactivateAutoRefresh","deactivateAutoRefresher","deactivateRefresher","deactivateSessionRefresher"],["detectLanguage","getLanguage"],["executeCode","codeExecute"],["exists","isAvailable","isExistent","isPresent"],["exportChat","chatExport","export"],["getFooterDiv","getFooter"],["getHeaderDiv","getHeader"],["getLastPrompt","getLastQuery","getMyLastMsg","getMyLastQuery"],["getContinueButton","getContinueGeneratingButton"],["getScrollToBottomButton","getScrollButton"],["getStopButton","getStopGeneratingButton"],["getTextarea","getTextArea","getChatbar","getChatBar","getChatbox","getChatBox"],["isFullScreen","isFullscreen","isfullscreen"],["isLoaded","isloaded"],["logOut","logout","logOff","logoff","signOut","signout","signOff","signoff"],["minify","codeMinify","minifyCode"],["new","newChat","startNewChat"],["obfuscate","codeObfuscate","obfuscateCode"],["printAllFunctions","showAllFunctions"],["refactor","codeRefactor","refactorCode"],["refreshReply","regenerate","regenerateReply"],["refreshSession","sessionRefresh"],["renderHTML","renderHtml","renderLinks","renderTags"],["reviewCode","codeReview"],["send","sendChat","sendMsg"],["sendInNewChat","sendNewChat"],["sentiment","analyzeSentiment","sentimentAnalysis"],["startNewChat","new","newChat"],["stop","stopChat","stopGenerating","stopResponse"],["suggest","suggestion","recommend"],["toggleAutoRefresh","toggleAutoRefresher","toggleRefresher","toggleSessionRefresher"],["toggleScheme","toggleMode"],["translate","translation","translator"],["unminify","unminifyCode","codeUnminify"],["writeCode","codeWrite"]],cjsFuncSynonyms=[["account","acct"],["activate","turnOn"],["analyze","check","evaluate","review"],["ask","send","submit"],["button","btn"],["continue","resume"],["chats","history"],["chat","conversation","convo"],["clear","delete","remove"],["data","details"],["deactivate","deActivate","turnOff"],["execute","interpret","interpreter","run"],["firefox","ff"],["generating","generation"],["minify","uglify"],["refactor","rewrite"],["regenerate","regen"],["render","parse"],["reply","response"],["sentiment","attitude","emotion","feeling","opinion","perception"],["speak","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(let o in chatgpt){for(let r of cjsFuncAliases)if(r.includes(o))if(r.some(e=>e.includes("."))){let t=r.find(e=>e.includes(".")).split(".")[1];for(let e of r)/^(\w+)/.exec(e)[1]!==o&&(chatgpt[e]=chatgpt[o][t])}else for(let e of r)e!==o&&(chatgpt[e]=chatgpt[o]);do{var newFunctionsCreated=!1;for(let a in chatgpt)if("function"==typeof chatgpt[a]){let o=a.split(/(?=[A-Zs])/);for(let r of o){let e=[].concat(...cjsFuncSynonyms.filter(e=>e.includes(r.toLowerCase())).map(e=>e.filter(e=>e!==r.toLowerCase())));for(let t of e){let e=camelCaser(o.map(e=>e==r?t:e));chatgpt[e]||(chatgpt[e]=chatgpt[a],newFunctionsCreated=!0)}}}}while(newFunctionsCreated)}let consolePrefix="🤖 chatgpt.js >> ",ogError=console.error,ogInfo=console.info;console.error=(...e)=>{e[0].startsWith(consolePrefix)?ogError(...e):ogError(consolePrefix+e[0],...e.slice(1))},console.info=e=>{e.startsWith(consolePrefix)?ogInfo(e):ogInfo(consolePrefix+e)};try{window.chatgpt=chatgpt}catch(e){}try{module.exports=chatgpt}catch(e){}
|
package/docs/README.md
CHANGED
|
@@ -45,8 +45,8 @@
|
|
|
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
|
-

|
|
49
|
+
[](https://github.com/KudoAI/chatgpt.js/tree/v3.3.1/dist/chatgpt.min.js)
|
|
50
50
|
[](https://www.codefactor.io/repository/github/kudoai/chatgpt.js)
|
|
51
51
|
[](https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=kudoai_chatgpt.js)
|
|
52
52
|
[](https://github.com/sindresorhus/awesome-chatgpt#javascript)
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
|
|
85
85
|
```js
|
|
86
86
|
(async () => {
|
|
87
|
-
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.
|
|
87
|
+
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.1/dist/chatgpt.min.js');
|
|
88
88
|
// Your code here...
|
|
89
89
|
})();
|
|
90
90
|
```
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
|
|
94
94
|
```js
|
|
95
95
|
var xhr = new XMLHttpRequest();
|
|
96
|
-
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.
|
|
96
|
+
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.1/dist/chatgpt.min.js');
|
|
97
97
|
xhr.onload = function () {
|
|
98
98
|
if (xhr.status === 200) {
|
|
99
99
|
var chatgptJS = document.createElement('script');
|
|
@@ -115,7 +115,7 @@ function yourCode() {
|
|
|
115
115
|
|
|
116
116
|
```js
|
|
117
117
|
...
|
|
118
|
-
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.
|
|
118
|
+
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.1/dist/chatgpt.min.js
|
|
119
119
|
// ==/UserScript==
|
|
120
120
|
|
|
121
121
|
// Your code here...
|
|
@@ -190,7 +190,7 @@ chatgpt.get('reply', 'last');
|
|
|
190
190
|
|
|
191
191
|
Each call equally fetches the last response. If you think it works, it probably will... so just type it!
|
|
192
192
|
|
|
193
|
-
If it didn't, check out the extended [userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.3.
|
|
193
|
+
If it didn't, check out the extended [userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.3.1/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!
|
|
194
194
|
|
|
195
195
|
<img height=8px width="100%" src="https://media.chatgptjs.org/images/separators/gradient-aqua.png?78210a7">
|
|
196
196
|
|
|
@@ -360,7 +360,7 @@ This library exists thanks to code, translations, issues & ideas from the follow
|
|
|
360
360
|
<div align="center">
|
|
361
361
|
|
|
362
362
|
**[Releases](https://github.com/KudoAI/chatgpt.js/releases)** /
|
|
363
|
-
[Userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.3.
|
|
363
|
+
[Userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.3.1/docs/USERGUIDE.md) /
|
|
364
364
|
[Discuss](https://github.com/KudoAI/chatgpt.js/discussions) /
|
|
365
365
|
<a href="#--------------------------------------------------------------------------------english---------简体中文---------繁體中文---------日本---------한국인---------हिंदी---------नेपाली---------deutsch---------español---------français---------italiano---------nederlands---------português---------việt----">Back to top ↑</a>
|
|
366
366
|
|
package/docs/USERGUIDE.md
CHANGED
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
- [DOM related](#dom-related)
|
|
71
71
|
- [focusChatbar](#focuschatbar)
|
|
72
72
|
- [getChatBox](#getchatbox)
|
|
73
|
-
- [
|
|
73
|
+
- [getContinueButton](#getContinueButton)
|
|
74
74
|
- [getFooterDiv](#getfooterdiv)
|
|
75
75
|
- [getHeaderDiv](#getheaderdiv)
|
|
76
76
|
- [getNewChatButton](#getnewchatbutton)
|
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
|
|
160
160
|
```js
|
|
161
161
|
(async () => {
|
|
162
|
-
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.
|
|
162
|
+
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.1/dist/chatgpt.min.js');
|
|
163
163
|
// Your code here...
|
|
164
164
|
})();
|
|
165
165
|
```
|
|
@@ -168,7 +168,7 @@
|
|
|
168
168
|
|
|
169
169
|
```js
|
|
170
170
|
var xhr = new XMLHttpRequest();
|
|
171
|
-
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.
|
|
171
|
+
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.1/dist/chatgpt.min.js');
|
|
172
172
|
xhr.onload = function () {
|
|
173
173
|
if (xhr.status === 200) {
|
|
174
174
|
var chatgptJS = document.createElement('script');
|
|
@@ -190,7 +190,7 @@ function yourCode() {
|
|
|
190
190
|
|
|
191
191
|
```js
|
|
192
192
|
...
|
|
193
|
-
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.
|
|
193
|
+
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.1/dist/chatgpt.min.js
|
|
194
194
|
// ==/UserScript==
|
|
195
195
|
|
|
196
196
|
// Your code here...
|
|
@@ -243,8 +243,8 @@ Example code:
|
|
|
243
243
|
```js
|
|
244
244
|
(async () => {
|
|
245
245
|
const language = await chatgpt.detectLanguage('我是一個大男孩');
|
|
246
|
-
|
|
247
|
-
/*
|
|
246
|
+
chatgpt.alert(language);
|
|
247
|
+
/* Alerts:
|
|
248
248
|
Chinese (Traditional) */
|
|
249
249
|
})();
|
|
250
250
|
```
|
|
@@ -261,7 +261,7 @@ Example code:
|
|
|
261
261
|
|
|
262
262
|
```js
|
|
263
263
|
(async () => {
|
|
264
|
-
|
|
264
|
+
chatgpt.alert(await chatgpt.executeCode('return 6 + 5')); // logs '11'
|
|
265
265
|
})();
|
|
266
266
|
```
|
|
267
267
|
|
|
@@ -273,7 +273,7 @@ Example code:
|
|
|
273
273
|
|
|
274
274
|
```js
|
|
275
275
|
const randomIP = chatgpt.generateRandomIP();
|
|
276
|
-
|
|
276
|
+
chatgpt.alert(randomIP); // Example output: '161.192.110.125'
|
|
277
277
|
```
|
|
278
278
|
|
|
279
279
|
### get
|
|
@@ -296,7 +296,7 @@ Example code:
|
|
|
296
296
|
|
|
297
297
|
```js
|
|
298
298
|
const userLanguage = chatgpt.getUserLanguage();
|
|
299
|
-
|
|
299
|
+
chatgpt.alert(userLanguage); // Example output: 'en-US'
|
|
300
300
|
```
|
|
301
301
|
|
|
302
302
|
### isFullScreen
|
|
@@ -324,7 +324,7 @@ Example code:
|
|
|
324
324
|
```js
|
|
325
325
|
(async () => {
|
|
326
326
|
await chatgpt.isLoaded();
|
|
327
|
-
|
|
327
|
+
chatgpt.alert('ChatGPT has finished loading.');
|
|
328
328
|
})();
|
|
329
329
|
```
|
|
330
330
|
|
|
@@ -346,7 +346,7 @@ Example code:
|
|
|
346
346
|
|
|
347
347
|
```js
|
|
348
348
|
const randomNumber = chatgpt.randomFloat();
|
|
349
|
-
|
|
349
|
+
chatgpt.alert(randomNumber); // Example output: 0.9472113021060851
|
|
350
350
|
```
|
|
351
351
|
|
|
352
352
|
### renderHTML
|
|
@@ -381,7 +381,7 @@ Example code:
|
|
|
381
381
|
(async () => {
|
|
382
382
|
const text = 'Are you an #OSS supporter? Do you love JavaScript? Then why not contribute to the future of #AI app development? https://chatgpt.js.org (a #100Builders project) is seeking collabs for exactly this! @withBackdrop';
|
|
383
383
|
const sentiment = await chatgpt.sentiment(text, '100 Builders');
|
|
384
|
-
|
|
384
|
+
chatgpt.alert(sentiment);
|
|
385
385
|
|
|
386
386
|
/* Example output:
|
|
387
387
|
The sentiment of the text towards the entity "100 Builders" is strongly positive. The text encourages
|
|
@@ -407,7 +407,7 @@ Example code:
|
|
|
407
407
|
```js
|
|
408
408
|
(async () => {
|
|
409
409
|
const suggestions = await chatgpt.suggest('names', 'baby boy');
|
|
410
|
-
|
|
410
|
+
chatgpt.alert(suggestions);
|
|
411
411
|
|
|
412
412
|
/* Example output:
|
|
413
413
|
1. Liam
|
|
@@ -446,7 +446,7 @@ Example code:
|
|
|
446
446
|
```js
|
|
447
447
|
(async () => {
|
|
448
448
|
const summary = await chatgpt.summarize('A very long text...');
|
|
449
|
-
|
|
449
|
+
chatgpt.alert(summary); // Example output: 'A very short text...'
|
|
450
450
|
})();
|
|
451
451
|
```
|
|
452
452
|
|
|
@@ -465,7 +465,7 @@ Example code:
|
|
|
465
465
|
```js
|
|
466
466
|
(async () => {
|
|
467
467
|
const translation = await chatgpt.translate('Hello, how are you?', 'spanish');
|
|
468
|
-
|
|
468
|
+
chatgpt.alert(translation); // Alerts: 'Hola, ¿cómo estás?'
|
|
469
469
|
})();
|
|
470
470
|
```
|
|
471
471
|
|
|
@@ -475,7 +475,7 @@ Example code:
|
|
|
475
475
|
|
|
476
476
|
```js
|
|
477
477
|
const randomID = chatgpt.uuidv4();
|
|
478
|
-
|
|
478
|
+
chatgpt.alert(randomID); // Example output: '239067d1-bcb8-4fd7-91eb-9ab94619b7b3'
|
|
479
479
|
```
|
|
480
480
|
|
|
481
481
|
## Page theme
|
|
@@ -507,7 +507,7 @@ Returns a boolean value. `true` if the theme is dark mode, `false` otherwise.
|
|
|
507
507
|
Example code:
|
|
508
508
|
|
|
509
509
|
```js
|
|
510
|
-
|
|
510
|
+
chatgpt.alert(chatgpt.settings.scheme.isDark()); // logs `true` or `false`
|
|
511
511
|
```
|
|
512
512
|
|
|
513
513
|
### isLightMode
|
|
@@ -517,7 +517,7 @@ Returns a boolean value. `true` if the theme is light mode, `false` otherwise.
|
|
|
517
517
|
Example code:
|
|
518
518
|
|
|
519
519
|
```js
|
|
520
|
-
|
|
520
|
+
chatgpt.alert(chatgpt.settings.scheme.isDark()); // logs `true` or `false`
|
|
521
521
|
```
|
|
522
522
|
|
|
523
523
|
### toggleScheme
|
|
@@ -555,10 +555,10 @@ function doSomething() { /* Your code */ }
|
|
|
555
555
|
|
|
556
556
|
function doSomethingElse() { /* Your code */ }
|
|
557
557
|
|
|
558
|
-
function sayHello() {
|
|
558
|
+
function sayHello() { chatgpt.alert('Hello!'); }
|
|
559
559
|
|
|
560
560
|
const alertID = chatgpt.alert('Hello, world!', 'The sky is blue.', [doSomething, doSomethingElse], sayHello, 200);
|
|
561
|
-
|
|
561
|
+
chatgpt.alert(alertID); // Example output: '1693237957878'
|
|
562
562
|
```
|
|
563
563
|
|
|
564
564
|
### notify
|
|
@@ -590,7 +590,7 @@ Returns an account access token as a string.
|
|
|
590
590
|
```js
|
|
591
591
|
(async () => {
|
|
592
592
|
const token = await chatgpt.getAccessToken();
|
|
593
|
-
|
|
593
|
+
chatgpt.alert(token); // Example output: 'abcdef[...]'
|
|
594
594
|
})();
|
|
595
595
|
```
|
|
596
596
|
|
|
@@ -607,10 +607,10 @@ Can be the following: `email`, `id`, `image`, `name`, `picture`. If a single det
|
|
|
607
607
|
```js
|
|
608
608
|
(async () => {
|
|
609
609
|
const accountName = await chatgpt.getAccountDetails('name');
|
|
610
|
-
|
|
610
|
+
chatgpt.alert(accountName); // Example output: 'chatgpt.js'
|
|
611
611
|
|
|
612
612
|
const accountData = await chatgpt.getAccountDetails('name', 'email');
|
|
613
|
-
|
|
613
|
+
chatgpt.alert(accountData);
|
|
614
614
|
/* Example output:
|
|
615
615
|
{
|
|
616
616
|
name: 'chatgpt.js',
|
|
@@ -641,7 +641,7 @@ Example code:
|
|
|
641
641
|
```js
|
|
642
642
|
(async () => {
|
|
643
643
|
const response = await chatgpt.askAndGetReply('Hello, ChatGPT');
|
|
644
|
-
|
|
644
|
+
chatgpt.alert(response); // Example output: 'Hello user, I'm ChatGPT!'
|
|
645
645
|
})();
|
|
646
646
|
```
|
|
647
647
|
|
|
@@ -652,7 +652,7 @@ Clears chat history.
|
|
|
652
652
|
Example code:
|
|
653
653
|
|
|
654
654
|
```js
|
|
655
|
-
chatgpt.clearChats().then(() =>
|
|
655
|
+
chatgpt.clearChats().then(() => chatgpt.alert('Chat history cleared!'));
|
|
656
656
|
```
|
|
657
657
|
|
|
658
658
|
### exportChat `async`
|
|
@@ -842,7 +842,7 @@ Example code:
|
|
|
842
842
|
|
|
843
843
|
```js
|
|
844
844
|
const chatInput = chatgpt.getChatInput();
|
|
845
|
-
|
|
845
|
+
chatgpt.alert(chatInput); // Example output: 'Hello from chatgpt.js!'
|
|
846
846
|
```
|
|
847
847
|
|
|
848
848
|
### getLastPrompt `async`
|
|
@@ -852,7 +852,7 @@ Returns the last message sent by the user as a string.
|
|
|
852
852
|
```js
|
|
853
853
|
(async () => {
|
|
854
854
|
const message = await chatgpt.getLastPrompt();
|
|
855
|
-
|
|
855
|
+
chatgpt.alert(message); // Example output: 'Hello from chatgpt.js!'
|
|
856
856
|
})();
|
|
857
857
|
```
|
|
858
858
|
|
|
@@ -863,15 +863,15 @@ Returns the last ChatGPT response as a string.
|
|
|
863
863
|
```js
|
|
864
864
|
(async () => {
|
|
865
865
|
const response = await chatgpt.getLastResponse();
|
|
866
|
-
|
|
866
|
+
chatgpt.alert(response); // Example output: 'I am ChatGPT!'
|
|
867
867
|
})();
|
|
868
868
|
```
|
|
869
869
|
|
|
870
870
|
### getResponse
|
|
871
871
|
|
|
872
|
-
If it's a previously created chat,
|
|
872
|
+
If it's a previously created chat, see [chatgpt.getResponseFromDOM](#getresponsefromdom)
|
|
873
873
|
|
|
874
|
-
If it's a new chat,
|
|
874
|
+
If it's a new chat, see [chatgpt.getResponseFromAPI](#getresponsefromapi-async)
|
|
875
875
|
|
|
876
876
|
### getResponseFromAPI `async`
|
|
877
877
|
|
|
@@ -888,7 +888,7 @@ Example code:
|
|
|
888
888
|
```js
|
|
889
889
|
(async () => {
|
|
890
890
|
const response = chatgpt.getResponseFromAPI();
|
|
891
|
-
|
|
891
|
+
chatgpt.alert(response); // Example output: 'Hello from ChatGPT!'
|
|
892
892
|
})();
|
|
893
893
|
```
|
|
894
894
|
|
|
@@ -909,7 +909,7 @@ fifthResp = chatgpt.getResponseFromDOM(5); // Returns the 5th response
|
|
|
909
909
|
fifthResp = chatgpt.getResponseFromDOM('fifth'); // Also returns the 5th response
|
|
910
910
|
fifthResp = chatgpt.getResponseFromDOM('five'); // Returns the 5th response too
|
|
911
911
|
|
|
912
|
-
|
|
912
|
+
chatgpt.alert(fifthResp); // Example output: 'Hello from ChatGPT!'
|
|
913
913
|
```
|
|
914
914
|
|
|
915
915
|
### isIdle `async`
|
|
@@ -925,7 +925,7 @@ Example code:
|
|
|
925
925
|
```js
|
|
926
926
|
(async () => {
|
|
927
927
|
await chatgpt.code.isIdle();
|
|
928
|
-
|
|
928
|
+
chatgpt.alert('ChatGPT is idle');
|
|
929
929
|
})();
|
|
930
930
|
```
|
|
931
931
|
|
|
@@ -1072,17 +1072,17 @@ Example code:
|
|
|
1072
1072
|
|
|
1073
1073
|
```js
|
|
1074
1074
|
const chatbox = chatgpt.getChatBox();
|
|
1075
|
-
|
|
1075
|
+
chatgpt.alert(chatbox.value); // Example output: 'Hello from chatgpt.js!'
|
|
1076
1076
|
```
|
|
1077
1077
|
|
|
1078
|
-
###
|
|
1078
|
+
### getContinueButton
|
|
1079
1079
|
|
|
1080
1080
|
Returns the 'Continue generating' button as an HTML element.
|
|
1081
1081
|
|
|
1082
1082
|
Example code:
|
|
1083
1083
|
|
|
1084
1084
|
```js
|
|
1085
|
-
const continueBtn = chatgpt.
|
|
1085
|
+
const continueBtn = chatgpt.getContinueButton();
|
|
1086
1086
|
continueBtn.click();
|
|
1087
1087
|
```
|
|
1088
1088
|
|
|
@@ -1252,7 +1252,7 @@ Example code:
|
|
|
1252
1252
|
|
|
1253
1253
|
```js
|
|
1254
1254
|
const timeStamp = chatgpt.autoRefresh.nowTimeStamp();
|
|
1255
|
-
|
|
1255
|
+
chatgpt.alert(timeStamp); // Example output: '1:56:25 PM'
|
|
1256
1256
|
```
|
|
1257
1257
|
|
|
1258
1258
|
## browser `api`
|
|
@@ -1264,7 +1264,7 @@ Returns a boolean value. `true` if system/browser scheme preference is set to li
|
|
|
1264
1264
|
Example code:
|
|
1265
1265
|
|
|
1266
1266
|
```js
|
|
1267
|
-
|
|
1267
|
+
chatgpt.alert(chatgpt.browser.isLightMode()); // logs `true` or `false`
|
|
1268
1268
|
```
|
|
1269
1269
|
|
|
1270
1270
|
### isDarkMode
|
|
@@ -1274,7 +1274,7 @@ Returns a boolean value. `true` if system/browser scheme preference is set to da
|
|
|
1274
1274
|
Example code:
|
|
1275
1275
|
|
|
1276
1276
|
```js
|
|
1277
|
-
|
|
1277
|
+
chatgpt.alert(chatgpt.browser.isDarkMode()); // logs `true` or `false`
|
|
1278
1278
|
```
|
|
1279
1279
|
|
|
1280
1280
|
### isChromium
|
|
@@ -1386,9 +1386,9 @@ Example code:
|
|
|
1386
1386
|
replyBox.style.height = replyBox.scrollHeight + 'px'
|
|
1387
1387
|
prevLength = newLength
|
|
1388
1388
|
}`);
|
|
1389
|
-
|
|
1389
|
+
chatgpt.alert(minifiedCode);
|
|
1390
1390
|
|
|
1391
|
-
/*
|
|
1391
|
+
/* Alerts:
|
|
1392
1392
|
'function autosizeBox(){const n=replyBox.value.length;if(n<prevLength){replyBox.style.height='auto';if(parseInt(getComputedStyle(replyBox).height)<55){replyBox.style.height='2.15rem'}}replyBox.style.height=replyBox.scrollHeight+'px';prevLength=n}' */
|
|
1393
1393
|
})();
|
|
1394
1394
|
```
|
|
@@ -1405,7 +1405,7 @@ Example code:
|
|
|
1405
1405
|
|
|
1406
1406
|
```js
|
|
1407
1407
|
(async () => {
|
|
1408
|
-
|
|
1408
|
+
chatgpt.alert(await chatgpt.code.execute('return 6 + 5')); // logs '11'
|
|
1409
1409
|
})();
|
|
1410
1410
|
```
|
|
1411
1411
|
|
|
@@ -1425,9 +1425,9 @@ Example code:
|
|
|
1425
1425
|
await chatgpt.isIdle();
|
|
1426
1426
|
const response = await chatgpt.getChatData('active', 'msg', 'chatgpt', 'latest'),
|
|
1427
1427
|
scriptCode = chatgpt.code.extract(response);
|
|
1428
|
-
|
|
1428
|
+
chatgpt.alert(scriptCode);
|
|
1429
1429
|
|
|
1430
|
-
/*
|
|
1430
|
+
/* Alerts:
|
|
1431
1431
|
const fs = require('fs');
|
|
1432
1432
|
|
|
1433
1433
|
// Specify the path of the file(s) you want to delete
|
|
@@ -1438,7 +1438,7 @@ Example code:
|
|
|
1438
1438
|
if (err) {
|
|
1439
1439
|
console.error('Error deleting file:', err);
|
|
1440
1440
|
} else {
|
|
1441
|
-
|
|
1441
|
+
chatgpt.alert('File deleted successfully');
|
|
1442
1442
|
}
|
|
1443
1443
|
}); */
|
|
1444
1444
|
})();
|
|
@@ -1458,7 +1458,7 @@ Example code:
|
|
|
1458
1458
|
(async () => {
|
|
1459
1459
|
chatgpt.send('Type me a short code block');
|
|
1460
1460
|
await chatgpt.code.isIdle();
|
|
1461
|
-
|
|
1461
|
+
chatgpt.alert('Code finished generating'); // non-code may still be generating
|
|
1462
1462
|
})();
|
|
1463
1463
|
```
|
|
1464
1464
|
|
|
@@ -1476,9 +1476,9 @@ Example code:
|
|
|
1476
1476
|
(async () => {
|
|
1477
1477
|
const code = `window[elem].addEventListener('mouseover', toggleTooltip)`
|
|
1478
1478
|
const obfuscatedCode = await chatgpt.code.obfuscate(code);
|
|
1479
|
-
|
|
1479
|
+
chatgpt.alert(obfuscatedCode);
|
|
1480
1480
|
|
|
1481
|
-
/*
|
|
1481
|
+
/* Alerts:
|
|
1482
1482
|
'(window[elem])[btoa('YWxlcnRWaWV3')](btoa('bW91c2VyYm94ZXJOYW1l'), btoa('dG9nZ2VkT3V0d2FsbA==')); */
|
|
1483
1483
|
})();
|
|
1484
1484
|
```
|
|
@@ -1504,9 +1504,9 @@ Example code:
|
|
|
1504
1504
|
return false;
|
|
1505
1505
|
}`;
|
|
1506
1506
|
const refactoredCode = await chatgpt.code.refactor(code, 'brevity');
|
|
1507
|
-
|
|
1507
|
+
chatgpt.alert(refactoredCode);
|
|
1508
1508
|
|
|
1509
|
-
/*
|
|
1509
|
+
/* Alerts:
|
|
1510
1510
|
return 6 > 5; */
|
|
1511
1511
|
})();
|
|
1512
1512
|
```
|
|
@@ -1523,7 +1523,7 @@ Example code:
|
|
|
1523
1523
|
|
|
1524
1524
|
```js
|
|
1525
1525
|
(async () => {
|
|
1526
|
-
|
|
1526
|
+
chatgpt.alert(await chatgpt.code.review('btoa("Hello World")'));
|
|
1527
1527
|
|
|
1528
1528
|
/* Example output:
|
|
1529
1529
|
The code appears to be correct. It uses the `btoa` function to encode the string "Hello World" in base64. */
|
|
@@ -1545,9 +1545,9 @@ Example code:
|
|
|
1545
1545
|
const code = `function autosizeBox(){const n=replyBox.value.length;if(n<prevLength){replyBox.style.height='auto';if(parseInt(getComputedStyle(replyBox).height)<55){replyBox.style.height='2.15rem'}}replyBox.style.height=replyBox.scrollHeight+'px';prevLength=n}`;
|
|
1546
1546
|
|
|
1547
1547
|
const minifiedCode = await chatgpt.code.unminify(code);
|
|
1548
|
-
|
|
1548
|
+
chatgpt.alert(minifiedCode);
|
|
1549
1549
|
|
|
1550
|
-
/*
|
|
1550
|
+
/* Alerts:
|
|
1551
1551
|
function autosizeBox() {
|
|
1552
1552
|
const newLength = replyBox.value.length
|
|
1553
1553
|
if (newLength < prevLength) { // if deleting txt
|
|
@@ -1576,9 +1576,9 @@ Example code:
|
|
|
1576
1576
|
```js
|
|
1577
1577
|
(async () => {
|
|
1578
1578
|
const code = await chatgpt.code.write('Repeat a task every 10 seconds', 'javascript');
|
|
1579
|
-
|
|
1579
|
+
chatgpt.alert(code);
|
|
1580
1580
|
|
|
1581
|
-
/*
|
|
1581
|
+
/* Alerts:
|
|
1582
1582
|
setInterval(function() {
|
|
1583
1583
|
// Your task code here
|
|
1584
1584
|
}, 10000); */
|
|
@@ -1672,7 +1672,7 @@ Example code:
|
|
|
1672
1672
|
```js
|
|
1673
1673
|
(async () => {
|
|
1674
1674
|
await chatgpt.history.isLoaded();
|
|
1675
|
-
|
|
1675
|
+
chatgpt.alert('ChatGPT history has finished loading.');
|
|
1676
1676
|
})();
|
|
1677
1677
|
```
|
|
1678
1678
|
|
|
@@ -1788,29 +1788,29 @@ chatgpt.response.continue();
|
|
|
1788
1788
|
|
|
1789
1789
|
### get
|
|
1790
1790
|
|
|
1791
|
-
If it's a previously created chat,
|
|
1791
|
+
If it's a previously created chat, see [chatgpt.getResponseFromDOM](#getresponsefromdom)
|
|
1792
1792
|
|
|
1793
|
-
If it's a new chat,
|
|
1793
|
+
If it's a new chat, see [chatgpt.getResponseFromAPI](#getresponsefromapi-async)
|
|
1794
1794
|
|
|
1795
1795
|
### getFromAPI `async`
|
|
1796
1796
|
|
|
1797
|
-
|
|
1797
|
+
See [chatgpt.getResponseFromAPI](#getresponsefromapi-async)
|
|
1798
1798
|
|
|
1799
1799
|
### getFromDOM
|
|
1800
1800
|
|
|
1801
|
-
|
|
1801
|
+
See [chatgpt.getResponseFromDOM](#getresponsefromdom)
|
|
1802
1802
|
|
|
1803
1803
|
### getLast `async`
|
|
1804
1804
|
|
|
1805
|
-
|
|
1805
|
+
See [chatgpt.getLastResponse](#getlastresponse-async)
|
|
1806
1806
|
|
|
1807
1807
|
### regenerate
|
|
1808
1808
|
|
|
1809
|
-
|
|
1809
|
+
See [chatgpt.regenerate](#regenerate)
|
|
1810
1810
|
|
|
1811
1811
|
### stopGenerating
|
|
1812
1812
|
|
|
1813
|
-
|
|
1813
|
+
See [chatgpt.stop](#stop)
|
|
1814
1814
|
|
|
1815
1815
|
## settings `api`
|
|
1816
1816
|
|
|
@@ -1825,7 +1825,7 @@ Returns a boolean value. `true` if the theme is dark mode, `false` otherwise.
|
|
|
1825
1825
|
Example code:
|
|
1826
1826
|
|
|
1827
1827
|
```js
|
|
1828
|
-
|
|
1828
|
+
chatgpt.alert(chatgpt.settings.scheme.isDark()); // logs `true` or `false`
|
|
1829
1829
|
````
|
|
1830
1830
|
|
|
1831
1831
|
#### isLight
|
|
@@ -1835,7 +1835,7 @@ Returns a boolean value. `true` if the theme is light mode, `false` otherwise.
|
|
|
1835
1835
|
Example code:
|
|
1836
1836
|
|
|
1837
1837
|
```js
|
|
1838
|
-
|
|
1838
|
+
chatgpt.alert(chatgpt.settings.scheme.isLight()); // logs `true` or `false`
|
|
1839
1839
|
````
|
|
1840
1840
|
|
|
1841
1841
|
#### set
|
|
@@ -1906,10 +1906,10 @@ const buttonId = chatgpt.sidebar.append('button', {
|
|
|
1906
1906
|
label: 'I am a button!',
|
|
1907
1907
|
icon: 'https://chat.openai.com/favicon-32x32.png',
|
|
1908
1908
|
onclick: function() {
|
|
1909
|
-
|
|
1909
|
+
chatgpt.alert('Clicked!');
|
|
1910
1910
|
}
|
|
1911
1911
|
});
|
|
1912
|
-
|
|
1912
|
+
chatgpt.alert(buttonId); // Example output: 1693295258727
|
|
1913
1913
|
|
|
1914
1914
|
const dropdownId = chatgpt.sidebar.append('dropdown', {
|
|
1915
1915
|
items: [
|
|
@@ -1917,7 +1917,7 @@ const dropdownId = chatgpt.sidebar.append('dropdown', {
|
|
|
1917
1917
|
{ text: 'Hello there', value: 'hellothere' }
|
|
1918
1918
|
]
|
|
1919
1919
|
});
|
|
1920
|
-
|
|
1920
|
+
chatgpt.alert(dropdownId); // Example output: 1693294795240
|
|
1921
1921
|
```
|
|
1922
1922
|
|
|
1923
1923
|
### exists
|
|
@@ -1998,7 +1998,7 @@ Example code:
|
|
|
1998
1998
|
```js
|
|
1999
1999
|
(async () => {
|
|
2000
2000
|
await chatgpt.sidebar.isLoaded();
|
|
2001
|
-
|
|
2001
|
+
chatgpt.alert('ChatGPT sidebar has finished loading.');
|
|
2002
2002
|
})();
|
|
2003
2003
|
```
|
|
2004
2004
|
|
package/package.json
CHANGED
|
@@ -883,13 +883,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
883
883
|
},
|
|
884
884
|
|
|
885
885
|
getChatInput() { return chatgpt.getChatBox().value; },
|
|
886
|
-
|
|
887
|
-
getContinueGeneratingButton() {
|
|
888
|
-
for (const formBtnSVG of document.querySelectorAll('form button svg')) {
|
|
889
|
-
if (formBtnSVG.querySelector('path[d*="M4.472 2.5a1"]'))
|
|
890
|
-
return formBtnSVG.parentNode.parentNode;
|
|
891
|
-
}},
|
|
892
|
-
|
|
886
|
+
getContinueButton() { return document.querySelector('button:has([d^="M4.47189"])'); },
|
|
893
887
|
getFooterDiv() { return chatgpt.footer.get(); },
|
|
894
888
|
getHeaderDiv() { return chatgpt.header.get(); },
|
|
895
889
|
getLastPrompt() { return chatgpt.getChatData('active', 'msg', 'user', 'latest'); },
|
|
@@ -901,12 +895,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
901
895
|
},
|
|
902
896
|
|
|
903
897
|
getNewChatLink() { return document.querySelector('nav a[href="/"]'); },
|
|
904
|
-
|
|
905
|
-
getRegenerateButton() {
|
|
906
|
-
for (const mainSVG of document.querySelectorAll('main svg')) {
|
|
907
|
-
if (mainSVG.querySelector('path[d^="M3.06957"]')) // regen icon found
|
|
908
|
-
return mainSVG.parentNode;
|
|
909
|
-
}},
|
|
898
|
+
getRegenerateButton() { return document.querySelector('button:has([d^="M3.06957"])'); },
|
|
910
899
|
|
|
911
900
|
getResponse() {
|
|
912
901
|
// * Returns response via DOM by index arg if OpenAI chat page is active, otherwise uses API w/ following args:
|
|
@@ -926,11 +915,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
926
915
|
|| document.querySelector('path[d*="M15.192 8.906a1.143"]')?.parentNode.parentNode; // post-GPT-4o
|
|
927
916
|
},
|
|
928
917
|
|
|
929
|
-
|
|
930
|
-
for (const svg of document.querySelectorAll('form button svg')) {
|
|
931
|
-
if (svg.querySelector('path[d*="2 0 0 1 2"], rect'))
|
|
932
|
-
return svg.parentNode;
|
|
933
|
-
}},
|
|
918
|
+
getStopButton() { return document.querySelector('button:has([d*="2 0 0 1 2"], rect)'); },
|
|
934
919
|
|
|
935
920
|
getUserLanguage() {
|
|
936
921
|
return navigator.languages[0] || navigator.language || navigator.browserLanguage ||
|
|
@@ -1804,7 +1789,7 @@ const chatgpt = { // eslint-disable-line no-redeclare
|
|
|
1804
1789
|
isOff() { return !this.isOn(); },
|
|
1805
1790
|
isOn() {
|
|
1806
1791
|
const sidebar = (() => {
|
|
1807
|
-
return chatgpt.sidebar.exists() ? document.querySelector('
|
|
1792
|
+
return chatgpt.sidebar.exists() ? document.querySelector('[class*="sidebar"]') : null; })();
|
|
1808
1793
|
if (!sidebar) { console.error('Sidebar element not found!'); return false; }
|
|
1809
1794
|
else return chatgpt.browser.isMobile() ?
|
|
1810
1795
|
document.documentElement.style.overflow == 'hidden'
|
|
@@ -1948,9 +1933,9 @@ const cjsFuncAliases = [
|
|
|
1948
1933
|
['getFooterDiv', 'getFooter'],
|
|
1949
1934
|
['getHeaderDiv', 'getHeader'],
|
|
1950
1935
|
['getLastPrompt', 'getLastQuery', 'getMyLastMsg', 'getMyLastQuery'],
|
|
1951
|
-
['
|
|
1936
|
+
['getContinueButton', 'getContinueGeneratingButton'],
|
|
1952
1937
|
['getScrollToBottomButton', 'getScrollButton'],
|
|
1953
|
-
['
|
|
1938
|
+
['getStopButton', 'getStopGeneratingButton'],
|
|
1954
1939
|
['getTextarea', 'getTextArea', 'getChatbar', 'getChatBar', 'getChatbox', 'getChatBox'],
|
|
1955
1940
|
['isFullScreen', 'isFullscreen', 'isfullscreen'],
|
|
1956
1941
|
['isLoaded', 'isloaded'],
|
|
@@ -3,13 +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.9.
|
|
6
|
+
// @version 2024.9.15
|
|
7
7
|
// @license MIT
|
|
8
8
|
// @match *://chatgpt.com/*
|
|
9
9
|
// @match *://chat.openai.com/*
|
|
10
|
-
// @icon https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@3.3.
|
|
11
|
-
// @icon64 https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@3.3.
|
|
12
|
-
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.
|
|
10
|
+
// @icon https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@3.3.1/starters/greasemonkey/media/images/icons/robot/icon48.png
|
|
11
|
+
// @icon64 https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@3.3.1/starters/greasemonkey/media/images/icons/robot/icon64.png
|
|
12
|
+
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.3.1/dist/chatgpt.min.js
|
|
13
13
|
// @grant GM_getValue
|
|
14
14
|
// @grant GM_setValue
|
|
15
15
|
// @noframes
|