From b4b390d49bb0a98f8fc373efc8f8a8e6d7c98299 Mon Sep 17 00:00:00 2001 From: "adamlui@protonmail.com" Date: Fri, 19 Jul 2024 02:13:34 -0700 Subject: [PATCH] Built chatgpt.js 3.0.0 --- dist/chatgpt.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/chatgpt.min.js b/dist/chatgpt.min.js index 12a24edb5..114642cf5 100644 --- a/dist/chatgpt.min.js +++ b/dist/chatgpt.min.js @@ -4,7 +4,7 @@ * User guide: https://chatgptjs.org/userguide * Latest minified release: https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js/chatgpt.min.js */ -const endpoints={assets:"https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@a62e2c8069c85aef07794f1b3a17c93b6296f7cb",openAI:{session:"https://chatgpt.com/api/auth/session",chats:"https://chatgpt.com/backend-api/conversations",chat:"https://chatgpt.com/backend-api/conversation",share_create:"https://chatgpt.com/backend-api/share/create",share:"https://chatgpt.com/backend-api/share",instructions:"https://chatgpt.com/backend-api/user_system_messages"}},chatgpt=(localStorage.alertQueue=JSON.stringify([]),localStorage.notifyProps=JSON.stringify({queue:{topRight:[],bottomRight:[],bottomLeft:[],topLeft:[]}}),{openAIaccessToken:{},actAs:function(s){return new Promise((o,r)=>{const a=new XMLHttpRequest;a.open("GET","https://raw.githubusercontent.com/KudoAI/chat-prompts/main/dist/personas.min.json",!0),a.send(),a.onload=()=>{if(200!==a.status)return r("🤖 chatgpt.js >> Request failed. Cannot retrieve prompts data.");var e=JSON.parse(a.responseText).personas;if(s){var t=e.find(e=>e.title.toLowerCase()==s.toLowerCase());if(!t)return r(`🤖 chatgpt.js >> Persona '${s}' was not found!`);chatgpt.send(t.prompt,"click"),console.info(`Loading ${s} persona...`),chatgpt.isIdle().then(()=>{console.info("Persona activated!")})}else{console.log("\n%c🤖 chatgpt.js personas\n","font-family: sans-serif ; font-size: xxx-large ; font-weight: bold");for(const n of e)console.log("%c"+n.title,"font-family: monospace ; font-size: larger ;")}return o()}})},activateDarkMode:function(){document.documentElement.classList.replace("light","dark"),document.documentElement.style.colorScheme="dark",localStorage.setItem("theme","dark")},activateLightMode:function(){document.documentElement.classList.replace("dark","light"),document.documentElement.style.colorScheme="light",localStorage.setItem("theme","light")},alert:function(e,t,n,o,r){const a=chatgpt.isDarkMode()?"dark":"light",s=chatgpt.browser.isMobile(),i=document.createElement("div"),c=(i.id=Math.floor(1e6*chatgpt.randomFloat())+Date.now(),i.classList.add("chatgpt-modal"),document.createElement("div")),l=document.createElement("h2"),u=document.createElement("p");var d=20231203;let g=document.querySelector("#chatgpt-modal-style");(!g||parseInt(g.getAttribute("last-updated"),10) div {opacity: 0 ; transform: translateX(-2px) translateY(5px) ; max-width: 75vw ; word-wrap: break-word ;transition: opacity 0.1s cubic-bezier(.165,.84,.44,1), transform 0.2s cubic-bezier(.165,.84,.44,1) ;"+`background-color: ${"dark"==a?"black":"white"} ;`+("dark"!=a?"border: 1px solid rgba(0, 0, 0, 0.3) ;":"")+"padding: 20px ; margin: 12px 23px ; border-radius: 15px ; box-shadow: 0 30px 60px rgba(0, 0, 0, .12) ; -webkit-user-select: none ; -moz-user-select: none ; -ms-user-select: none ; user-select: none ; }.chatgpt-modal h2 { margin-bottom: 9px }"+`.chatgpt-modal a { color: ${"dark"==a?"#00cfff":"#1e9ebb"}}`+".chatgpt-modal.animated > div { opacity: 1 ; transform: translateX(0) translateY(0) }@keyframes alert-zoom-fade-out { 0% { opacity: 1 ; transform: scale(1) }50% { opacity: 0.25 ; transform: scale(1.05) }100% { opacity: 0 ; transform: scale(1.35) }}.modal-buttons { display: flex ; justify-content: flex-end ; margin: 20px -5px -3px 0 ;"+(s?"flex-direction: column-reverse":"")+"}.chatgpt-modal button {"+`margin-left: ${s?0:10}px ; padding: ${s?15:4}px 18px ; border-radius: 15px ;`+(s?"margin-top: 5px ; margin-bottom: 3px ;":"")+`border: 1px solid ${"dark"==a?"white":"black"}}`+".primary-modal-btn {"+`border: 1px solid ${"dark"==a?"white":"black"} ;`+`background: ${"dark"==a?"white":"black"} ;`+`color: ${"dark"==a?"black":"white"}}`+".chatgpt-modal button:hover { color: #3d5d71 ; border-color: #6d9cb9 ;background-color: "+("dark"==a?"#00cfff":"#9cdaff")+";box-shadow: 2px 1px "+("dark"==a?"54px #00cfff":"30px #9cdaff")+"}.modal-close-btn {cursor: pointer ; width: 20px ; height: 20px ; float: right ; position: relative ; right: -2px }.modal-close-btn svg { margin: 5px 5px }"+`.modal-close-btn:hover { background-color: #f2f2f2${"dark"==a?"00":""}}`+".chatgpt-modal .checkbox-group { display: flex ; margin-top: -18px }.chatgpt-modal .checkbox-group label {font-size: .7rem ; margin: -.04rem 0 0px .3rem ;"+`color: ${"dark"==a?"#e1e1e1":"#1e1e1e"}}`+'.chatgpt-modal input[type="checkbox"] { transform: scale(0.7) ;'+`border: 1px solid ${"dark"==a?"white":"black"}}`+'.chatgpt-modal input[type="checkbox"]:checked {'+`border: 1px solid ${"dark"==a?"white":"black"} ;`+'background-color: black ; position: inherit }.chatgpt-modal input[type="checkbox"]:focus { outline: none ; box-shadow: none }'),l.innerText=e||"",u.innerText=t||"",chatgpt.renderHTML(u);const p=document.createElement("div");p.classList.add("modal-buttons"),n&&(n=Array.isArray(n)?n:[n]).forEach(e=>{var t=document.createElement("button");t.textContent=e.name.replace(/[_-]\w/g,e=>e.slice(1).toUpperCase()).replace(/([A-Z])/g," $1").replace(/^\w/,e=>e.toUpperCase()),t.addEventListener("click",()=>{w(),e()}),p.insertBefore(t,p.firstChild)});d=document.createElement("button"),d.textContent=n?"Dismiss":"OK",p.insertBefore(d,p.firstChild),p.lastChild.classList.add("primary-modal-btn"),e=document.createElement("div");if(o){e.classList.add("checkbox-group");const b=o,v=document.createElement("input");v.type="checkbox",v.addEventListener("change",b);t=document.createElement("label");t.addEventListener("click",()=>{v.checked=!v.checked,b()}),t.textContent=b.name.charAt(0).toUpperCase()+b.name.slice(1).replace(/([A-Z])/g,(e,t)=>" "+t.toLowerCase()).replace(/\b(\w+)nt\b/gi,"$1n't").trim(),e.append(v),e.append(t)}n=document.createElement("div"),n.title="Close",n.classList.add("modal-close-btn"),o=document.createElementNS("http://www.w3.org/2000/svg","svg"),o.setAttribute("height","10px"),o.setAttribute("viewBox","0 0 14 14"),o.setAttribute("fill","none"),t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("fill-rule","evenodd"),t.setAttribute("clip-rule","evenodd"),t.setAttribute("fill",chatgpt.isDarkMode()?"white":"black"),t.setAttribute("d","M13.7071 1.70711C14.0976 1.31658 14.0976 0.683417 13.7071 0.292893C13.3166 -0.0976312 12.6834 -0.0976312 12.2929 0.292893L7 5.58579L1.70711 0.292893C1.31658 -0.0976312 0.683417 -0.0976312 0.292893 0.292893C-0.0976312 0.683417 -0.0976312 1.31658 0.292893 1.70711L5.58579 7L0.292893 12.2929C-0.0976312 12.6834 -0.0976312 13.3166 0.292893 13.7071C0.683417 14.0976 1.31658 14.0976 1.70711 13.7071L7 8.41421L12.2929 13.7071C12.6834 14.0976 13.3166 14.0976 13.7071 13.7071C14.0976 13.3166 14.0976 12.6834 13.7071 12.2929L8.41421 7L13.7071 1.70711Z"),o.append(t),n.append(o),[n,l,u,p,e].forEach(e=>{c.append(e)}),c.style.width=`${r||458}px`,i.append(c),document.body.append(i);let h=JSON.parse(localStorage.alertQueue);h.push(i.id),localStorage.alertQueue=JSON.stringify(h),i.style.display="none",1===h.length&&(i.style.display="",setTimeout(()=>{i.style.backgroundColor=`rgba(67, 70, 72, ${"dark"==a?.62:0})`,i.classList.add("animated")},100));const f=e=>{(e.target==e.currentTarget||e.target instanceof SVGPathElement)&&w()},m=e=>{if([13,27].includes(e.keyCode))for(const n of h){var t=document.getElementById(n);if(t&&"none"!==t.style.display)return void(27===e.keyCode?w():13===e.keyCode&&(t=t.querySelector(".modal-buttons").lastChild)&&(t.click(),e.preventDefault()))}},y=[i,n,o,d],w=(y.forEach(e=>{e.addEventListener("click",f)}),document.addEventListener("keydown",m),()=>{i.style.backgroundColor="transparent",c.style.animation="alert-zoom-fade-out 0.075s ease-out",setTimeout(()=>{if(i.remove(),(h=JSON.parse(localStorage.alertQueue)).shift(),localStorage.alertQueue=JSON.stringify(h),y.forEach(e=>{e.removeEventListener("click",f)}),document.removeEventListener("keydown",m),0{e.style.display="",setTimeout(()=>{e.classList.add("animated")},100)},500)}},50)});return i.id},askAndGetReply:async function(e){return chatgpt.send(e),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},autoRefresh:{activate:function(e){if(this.isActive)console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already active!");else{const n=this,o=(this.toggle.refreshFrame(),t=>{var e=Math.max(2,Math.floor(21*chatgpt.randomFloat()-10));n.isActive=setTimeout(()=>{var e=document.querySelector('script[src*="_ssgManifest.js"]');document.querySelector("#refresh-frame").src=e.src+"?"+Date.now(),console.log("↻ ChatGPT >> ["+n.nowTimeStamp()+"] ChatGPT session refreshed"),o(t)},1e3*(t+e))});o(e?parseInt(e,10):30),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh activated"),navigator.userAgent.includes("Chrome")&&void 0!==document.hidden&&document.addEventListener("visibilitychange",this.toggle.beacons)}},deactivate:function(){this.isActive?(this.toggle.refreshFrame(),document.removeEventListener("visibilitychange",this.toggle.beacons),clearTimeout(this.isActive),this.isActive=null,console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh de-activated")):console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already inactive!")},nowTimeStamp:function(){var e=new Date,t=e.getHours()%12||12;let n=e.getMinutes(),o=e.getSeconds();n<10&&(n="0"+n),o<10&&(o="0"+o);e=e.getHours()<12?"AM":"PM";return t+":"+n+":"+o+" "+e},toggle:{beacons:function(){chatgpt.autoRefresh.beaconID?(clearInterval(chatgpt.autoRefresh.beaconID),chatgpt.autoRefresh.beaconID=null,console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacons de-activated")):(chatgpt.autoRefresh.beaconID=setInterval(()=>{navigator.sendBeacon("https://httpbin.org/post",new Uint8Array),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacon sent")},9e4),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacons activated"))},refreshFrame:function(){let e=document.querySelector("#refresh-frame");e?e.remove():(e=Object.assign(document.createElement("iframe"),{id:"refresh-frame",style:"display: none"}),document.head.prepend(e))}}},browser:{isLightMode:function(){return window.matchMedia?.("(prefers-color-scheme: light)")?.matches},isDarkMode:function(){return window.matchMedia?.("(prefers-color-scheme: dark)")?.matches},isChromium:function(){return navigator.userAgent.includes("Chrome")},isFirefox:function(){return navigator.userAgent.includes("Firefox")},isFullScreen:function(){var e=navigator.userAgent;return e.includes("Chrome")?window.matchMedia("(display-mode: fullscreen)").matches:e.includes("Firefox")?window.fullScreen:/MSIE|rv:/.test(e)?document.msFullscreenElement:document.webkitIsFullScreen},isMobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}},clearChats:async function(e){var t=["api","dom"];if((e=(e||"dom").trim().toLowerCase())&&!t.includes(e))return console.error(`Method argument must be one of: [${t}]`);if("dom"!=e)return new Promise((n,o)=>{chatgpt.getAccessToken().then(e=>{const t=new XMLHttpRequest;t.open("PATCH",endpoints.openAI.chats,!0),t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("Authorization","Bearer "+e),t.onload=()=>{if(200!==t.status)return o("🤖 chatgpt.js >> Request failed. Cannot clear chats.");console.info("Chats successfully cleared"),n()},t.send(JSON.stringify({is_visible:!1}))}).catch(e=>o(new Error(e.message)))});t=t=>new Promise(e=>setTimeout(e,t));try{chatgpt.menu.open(),await t(10);document.querySelector('a[role="menuitem"] svg path[d*="M12.003 10.5a1.5"]').parentNode.parentNode.click(),await t(333);var n=document.querySelectorAll("[id*=radix] button");return n[n.length-1].click(),await t(10),document.querySelector('button[class*="danger"').click(),console.info("Chats successfully cleared.")}catch(e){console.error(e.message),0==arguments.length&&(console.info("Using backend API method instead."),chatgpt.clearChats("api"))}},code:{execute:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Display the output as if you were terminal:\n\n"+e),console.info("Executing code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},extract:function(e){var t=e.match(/(?<=```.*\n)[\s\S]*?(?=```)/g);return t?t[t.length-1]:e},minify:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Minify the following code:\n\n"+e),console.info("Minifying code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},obfuscate:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Obfuscate the following code:\n\n"+e),console.info("Obfuscating code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},refactor:async function(e,t){if(!e)return console.error("Code (1st) argument not supplied. Pass some code!");for(let e=0;e div > div > div > div > div > div[class*=group]");if(0===a.length)return console.error("Chat is empty!");const l=[];let n=!0;a.forEach(e=>{var t=n?"USER":"CHATGPT",e=(n=!n,Array.from(e.childNodes).map(e=>e.innerText).join("\n\n").replace("Copy code",""));l.push(t+": "+e)}),o=l.join("\n\n")}else for(const u of await chatgpt.getChatData(e,"msg","both","all"))o=(o+=`USER: ${u.user} +const endpoints={assets:"https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@b25f2885500f7958e766c5e471689f6541c18c18",openAI:{session:"https://chatgpt.com/api/auth/session",chats:"https://chatgpt.com/backend-api/conversations",chat:"https://chatgpt.com/backend-api/conversation",share_create:"https://chatgpt.com/backend-api/share/create",share:"https://chatgpt.com/backend-api/share",instructions:"https://chatgpt.com/backend-api/user_system_messages"}},chatgpt=(localStorage.alertQueue=JSON.stringify([]),localStorage.notifyProps=JSON.stringify({queue:{topRight:[],bottomRight:[],bottomLeft:[],topLeft:[]}}),{openAIaccessToken:{},actAs:function(s){return new Promise((o,r)=>{const a=new XMLHttpRequest;a.open("GET","https://raw.githubusercontent.com/KudoAI/chat-prompts/main/dist/personas.min.json",!0),a.send(),a.onload=()=>{if(200!==a.status)return r("🤖 chatgpt.js >> Request failed. Cannot retrieve prompts data.");var e=JSON.parse(a.responseText).personas;if(s){var t=e.find(e=>e.title.toLowerCase()==s.toLowerCase());if(!t)return r(`🤖 chatgpt.js >> Persona '${s}' was not found!`);chatgpt.send(t.prompt,"click"),console.info(`Loading ${s} persona...`),chatgpt.isIdle().then(()=>{console.info("Persona activated!")})}else{console.log("\n%c🤖 chatgpt.js personas\n","font-family: sans-serif ; font-size: xxx-large ; font-weight: bold");for(const n of e)console.log("%c"+n.title,"font-family: monospace ; font-size: larger ;")}return o()}})},activateDarkMode:function(){document.documentElement.classList.replace("light","dark"),document.documentElement.style.colorScheme="dark",localStorage.setItem("theme","dark")},activateLightMode:function(){document.documentElement.classList.replace("dark","light"),document.documentElement.style.colorScheme="light",localStorage.setItem("theme","light")},alert:function(e,t,n,o,r){const a=chatgpt.isDarkMode()?"dark":"light",s=chatgpt.browser.isMobile(),i=document.createElement("div"),c=(i.id=Math.floor(1e6*chatgpt.randomFloat())+Date.now(),i.classList.add("chatgpt-modal"),document.createElement("div")),l=document.createElement("h2"),u=document.createElement("p");var d=20231203;let g=document.querySelector("#chatgpt-modal-style");(!g||parseInt(g.getAttribute("last-updated"),10) div {opacity: 0 ; transform: translateX(-2px) translateY(5px) ; max-width: 75vw ; word-wrap: break-word ;transition: opacity 0.1s cubic-bezier(.165,.84,.44,1), transform 0.2s cubic-bezier(.165,.84,.44,1) ;"+`background-color: ${"dark"==a?"black":"white"} ;`+("dark"!=a?"border: 1px solid rgba(0, 0, 0, 0.3) ;":"")+"padding: 20px ; margin: 12px 23px ; border-radius: 15px ; box-shadow: 0 30px 60px rgba(0, 0, 0, .12) ; -webkit-user-select: none ; -moz-user-select: none ; -ms-user-select: none ; user-select: none ; }.chatgpt-modal h2 { margin-bottom: 9px }"+`.chatgpt-modal a { color: ${"dark"==a?"#00cfff":"#1e9ebb"}}`+".chatgpt-modal.animated > div { opacity: 1 ; transform: translateX(0) translateY(0) }@keyframes alert-zoom-fade-out { 0% { opacity: 1 ; transform: scale(1) }50% { opacity: 0.25 ; transform: scale(1.05) }100% { opacity: 0 ; transform: scale(1.35) }}.modal-buttons { display: flex ; justify-content: flex-end ; margin: 20px -5px -3px 0 ;"+(s?"flex-direction: column-reverse":"")+"}.chatgpt-modal button {"+`margin-left: ${s?0:10}px ; padding: ${s?15:4}px 18px ; border-radius: 15px ;`+(s?"margin-top: 5px ; margin-bottom: 3px ;":"")+`border: 1px solid ${"dark"==a?"white":"black"}}`+".primary-modal-btn {"+`border: 1px solid ${"dark"==a?"white":"black"} ;`+`background: ${"dark"==a?"white":"black"} ;`+`color: ${"dark"==a?"black":"white"}}`+".chatgpt-modal button:hover { color: #3d5d71 ; border-color: #6d9cb9 ;background-color: "+("dark"==a?"#00cfff":"#9cdaff")+";box-shadow: 2px 1px "+("dark"==a?"54px #00cfff":"30px #9cdaff")+"}.modal-close-btn {cursor: pointer ; width: 20px ; height: 20px ; float: right ; position: relative ; right: -2px }.modal-close-btn svg { margin: 5px 5px }"+`.modal-close-btn:hover { background-color: #f2f2f2${"dark"==a?"00":""}}`+".chatgpt-modal .checkbox-group { display: flex ; margin-top: -18px }.chatgpt-modal .checkbox-group label {font-size: .7rem ; margin: -.04rem 0 0px .3rem ;"+`color: ${"dark"==a?"#e1e1e1":"#1e1e1e"}}`+'.chatgpt-modal input[type="checkbox"] { transform: scale(0.7) ;'+`border: 1px solid ${"dark"==a?"white":"black"}}`+'.chatgpt-modal input[type="checkbox"]:checked {'+`border: 1px solid ${"dark"==a?"white":"black"} ;`+'background-color: black ; position: inherit }.chatgpt-modal input[type="checkbox"]:focus { outline: none ; box-shadow: none }'),l.innerText=e||"",u.innerText=t||"",chatgpt.renderHTML(u);const p=document.createElement("div");p.classList.add("modal-buttons"),n&&(n=Array.isArray(n)?n:[n]).forEach(e=>{var t=document.createElement("button");t.textContent=e.name.replace(/[_-]\w/g,e=>e.slice(1).toUpperCase()).replace(/([A-Z])/g," $1").replace(/^\w/,e=>e.toUpperCase()),t.addEventListener("click",()=>{w(),e()}),p.insertBefore(t,p.firstChild)});d=document.createElement("button"),d.textContent=n?"Dismiss":"OK",p.insertBefore(d,p.firstChild),p.lastChild.classList.add("primary-modal-btn"),e=document.createElement("div");if(o){e.classList.add("checkbox-group");const b=o,v=document.createElement("input");v.type="checkbox",v.addEventListener("change",b);t=document.createElement("label");t.addEventListener("click",()=>{v.checked=!v.checked,b()}),t.textContent=b.name.charAt(0).toUpperCase()+b.name.slice(1).replace(/([A-Z])/g,(e,t)=>" "+t.toLowerCase()).replace(/\b(\w+)nt\b/gi,"$1n't").trim(),e.append(v),e.append(t)}n=document.createElement("div"),n.title="Close",n.classList.add("modal-close-btn"),o=document.createElementNS("http://www.w3.org/2000/svg","svg"),o.setAttribute("height","10px"),o.setAttribute("viewBox","0 0 14 14"),o.setAttribute("fill","none"),t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("fill-rule","evenodd"),t.setAttribute("clip-rule","evenodd"),t.setAttribute("fill",chatgpt.isDarkMode()?"white":"black"),t.setAttribute("d","M13.7071 1.70711C14.0976 1.31658 14.0976 0.683417 13.7071 0.292893C13.3166 -0.0976312 12.6834 -0.0976312 12.2929 0.292893L7 5.58579L1.70711 0.292893C1.31658 -0.0976312 0.683417 -0.0976312 0.292893 0.292893C-0.0976312 0.683417 -0.0976312 1.31658 0.292893 1.70711L5.58579 7L0.292893 12.2929C-0.0976312 12.6834 -0.0976312 13.3166 0.292893 13.7071C0.683417 14.0976 1.31658 14.0976 1.70711 13.7071L7 8.41421L12.2929 13.7071C12.6834 14.0976 13.3166 14.0976 13.7071 13.7071C14.0976 13.3166 14.0976 12.6834 13.7071 12.2929L8.41421 7L13.7071 1.70711Z"),o.append(t),n.append(o),[n,l,u,p,e].forEach(e=>{c.append(e)}),c.style.width=`${r||458}px`,i.append(c),document.body.append(i);let h=JSON.parse(localStorage.alertQueue);h.push(i.id),localStorage.alertQueue=JSON.stringify(h),i.style.display="none",1===h.length&&(i.style.display="",setTimeout(()=>{i.style.backgroundColor=`rgba(67, 70, 72, ${"dark"==a?.62:0})`,i.classList.add("animated")},100));const f=e=>{(e.target==e.currentTarget||e.target instanceof SVGPathElement)&&w()},m=e=>{if([13,27].includes(e.keyCode))for(const n of h){var t=document.getElementById(n);if(t&&"none"!==t.style.display)return void(27===e.keyCode?w():13===e.keyCode&&(t=t.querySelector(".modal-buttons").lastChild)&&(t.click(),e.preventDefault()))}},y=[i,n,o,d],w=(y.forEach(e=>{e.addEventListener("click",f)}),document.addEventListener("keydown",m),()=>{i.style.backgroundColor="transparent",c.style.animation="alert-zoom-fade-out 0.075s ease-out",setTimeout(()=>{if(i.remove(),(h=JSON.parse(localStorage.alertQueue)).shift(),localStorage.alertQueue=JSON.stringify(h),y.forEach(e=>{e.removeEventListener("click",f)}),document.removeEventListener("keydown",m),0{e.style.display="",setTimeout(()=>{e.classList.add("animated")},100)},500)}},50)});return i.id},askAndGetReply:async function(e){return chatgpt.send(e),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},autoRefresh:{activate:function(e){if(this.isActive)console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already active!");else{const n=this,o=(this.toggle.refreshFrame(),t=>{var e=Math.max(2,Math.floor(21*chatgpt.randomFloat()-10));n.isActive=setTimeout(()=>{var e=document.querySelector('script[src*="_ssgManifest.js"]');document.querySelector("#refresh-frame").src=e.src+"?"+Date.now(),console.log("↻ ChatGPT >> ["+n.nowTimeStamp()+"] ChatGPT session refreshed"),o(t)},1e3*(t+e))});o(e?parseInt(e,10):30),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh activated"),navigator.userAgent.includes("Chrome")&&void 0!==document.hidden&&document.addEventListener("visibilitychange",this.toggle.beacons)}},deactivate:function(){this.isActive?(this.toggle.refreshFrame(),document.removeEventListener("visibilitychange",this.toggle.beacons),clearTimeout(this.isActive),this.isActive=null,console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh de-activated")):console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already inactive!")},nowTimeStamp:function(){var e=new Date,t=e.getHours()%12||12;let n=e.getMinutes(),o=e.getSeconds();n<10&&(n="0"+n),o<10&&(o="0"+o);e=e.getHours()<12?"AM":"PM";return t+":"+n+":"+o+" "+e},toggle:{beacons:function(){chatgpt.autoRefresh.beaconID?(clearInterval(chatgpt.autoRefresh.beaconID),chatgpt.autoRefresh.beaconID=null,console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacons de-activated")):(chatgpt.autoRefresh.beaconID=setInterval(()=>{navigator.sendBeacon("https://httpbin.org/post",new Uint8Array),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacon sent")},9e4),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacons activated"))},refreshFrame:function(){let e=document.querySelector("#refresh-frame");e?e.remove():(e=Object.assign(document.createElement("iframe"),{id:"refresh-frame",style:"display: none"}),document.head.prepend(e))}}},browser:{isLightMode:function(){return window.matchMedia?.("(prefers-color-scheme: light)")?.matches},isDarkMode:function(){return window.matchMedia?.("(prefers-color-scheme: dark)")?.matches},isChromium:function(){return navigator.userAgent.includes("Chrome")},isFirefox:function(){return navigator.userAgent.includes("Firefox")},isFullScreen:function(){var e=navigator.userAgent;return e.includes("Chrome")?window.matchMedia("(display-mode: fullscreen)").matches:e.includes("Firefox")?window.fullScreen:/MSIE|rv:/.test(e)?document.msFullscreenElement:document.webkitIsFullScreen},isMobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}},clearChats:async function(e){var t=["api","dom"];if((e=(e||"dom").trim().toLowerCase())&&!t.includes(e))return console.error(`Method argument must be one of: [${t}]`);if("dom"!=e)return new Promise((n,o)=>{chatgpt.getAccessToken().then(e=>{const t=new XMLHttpRequest;t.open("PATCH",endpoints.openAI.chats,!0),t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("Authorization","Bearer "+e),t.onload=()=>{if(200!==t.status)return o("🤖 chatgpt.js >> Request failed. Cannot clear chats.");console.info("Chats successfully cleared"),n()},t.send(JSON.stringify({is_visible:!1}))}).catch(e=>o(new Error(e.message)))});t=t=>new Promise(e=>setTimeout(e,t));try{chatgpt.menu.open(),await t(10);document.querySelector('a[role="menuitem"] svg path[d*="M12.003 10.5a1.5"]').parentNode.parentNode.click(),await t(333);var n=document.querySelectorAll("[id*=radix] button");return n[n.length-1].click(),await t(10),document.querySelector('button[class*="danger"').click(),console.info("Chats successfully cleared.")}catch(e){console.error(e.message),0==arguments.length&&(console.info("Using backend API method instead."),chatgpt.clearChats("api"))}},code:{execute:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Display the output as if you were terminal:\n\n"+e),console.info("Executing code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},extract:function(e){var t=e.match(/(?<=```.*\n)[\s\S]*?(?=```)/g);return t?t[t.length-1]:e},minify:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Minify the following code:\n\n"+e),console.info("Minifying code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},obfuscate:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Obfuscate the following code:\n\n"+e),console.info("Obfuscating code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},refactor:async function(e,t){if(!e)return console.error("Code (1st) argument not supplied. Pass some code!");for(let e=0;e div > div > div > div > div > div[class*=group]");if(0===a.length)return console.error("Chat is empty!");const l=[];let n=!0;a.forEach(e=>{var t=n?"USER":"CHATGPT",e=(n=!n,Array.from(e.childNodes).map(e=>e.innerText).join("\n\n").replace("Copy code",""));l.push(t+": "+e)}),o=l.join("\n\n")}else for(const u of await chatgpt.getChatData(e,"msg","both","all"))o=(o+=`USER: ${u.user} `)+`CHATGPT: ${u.chatgpt}