@kudoai/chatgpt.js 2.9.3 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -13
- package/chatgpt.js +93 -100
- package/dist/chatgpt.min.js +1 -1
- package/docs/README.md +28 -13
- package/docs/USERGUIDE.md +80 -53
- package/package.json +6 -6
- package/starters/chrome/LICENSE.md +2 -2
- package/starters/chrome/docs/README.md +2 -2
- package/starters/chrome/docs/SECURITY.md +2 -2
- package/starters/chrome/extension/lib/chatgpt.js +93 -100
- package/starters/chrome/extension/manifest.json +1 -1
- package/starters/chrome/extension/popup/index.html +1 -1
- package/starters/greasemonkey/LICENSE.md +2 -2
- package/starters/greasemonkey/chatgpt.js-greasemonkey-starter.user.js +4 -4
- package/starters/greasemonkey/docs/SECURITY.md +2 -2
package/dist/chatgpt.min.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* User guide: https://chatgptjs.org/userguide
|
|
5
5
|
* Latest minified release: https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js/chatgpt.min.js
|
|
6
6
|
*/
|
|
7
|
-
const endpoints={assets:"https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@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)<d)&&(g||((g=document.createElement("style")).id="chatgpt-modal-style",g.setAttribute("last-updated",d.toString()),document.head.append(g)),g.innerText=".chatgpt-modal {position: fixed ; top: 0 ; left: 0 ; width: 100% ; height: 100% ;background-color: rgba(67, 70, 72, 0) ;transition: background-color 0.05s ease ;display: flex ; justify-content: center ; align-items: center ; z-index: 9999 }.chatgpt-modal > div {opacity: 0 ; transform: translateX(-2px) translateY(5px) ; max-width: 75vw ; word-wrap: break-word ;transition: opacity 0.1s cubic-bezier(.165,.84,.44,1), transform 0.2s cubic-bezier(.165,.84,.44,1) ;"+`background-color: ${"dark"==a?"black":"white"} ;`+("dark"!=a?"border: 1px solid rgba(0, 0, 0, 0.3) ;":"")+"padding: 20px ; margin: 12px 23px ; border-radius: 15px ; box-shadow: 0 30px 60px rgba(0, 0, 0, .12) ; -webkit-user-select: none ; -moz-user-select: none ; -ms-user-select: none ; user-select: none ; }.chatgpt-modal h2 { margin-bottom: 9px }"+`.chatgpt-modal a { color: ${"dark"==a?"#00cfff":"#1e9ebb"}}`+".chatgpt-modal.animated > div { opacity: 1 ; transform: translateX(0) translateY(0) }@keyframes alert-zoom-fade-out { 0% { opacity: 1 ; transform: scale(1) }50% { opacity: 0.25 ; transform: scale(1.05) }100% { opacity: 0 ; transform: scale(1.35) }}.modal-buttons { display: flex ; justify-content: flex-end ; margin: 20px -5px -3px 0 ;"+(s?"flex-direction: column-reverse":"")+"}.chatgpt-modal button {"+`margin-left: ${s?0:10}px ; padding: ${s?15:4}px 18px ; border-radius: 15px ;`+(s?"margin-top: 5px ; margin-bottom: 3px ;":"")+`border: 1px solid ${"dark"==a?"white":"black"}}`+".primary-modal-btn {"+`border: 1px solid ${"dark"==a?"white":"black"} ;`+`background: ${"dark"==a?"white":"black"} ;`+`color: ${"dark"==a?"black":"white"}}`+".chatgpt-modal button:hover { color: #3d5d71 ; border-color: #6d9cb9 ;background-color: "+("dark"==a?"#00cfff":"#9cdaff")+";box-shadow: 2px 1px "+("dark"==a?"54px #00cfff":"30px #9cdaff")+"}.modal-close-btn {cursor: pointer ; width: 20px ; height: 20px ; float: right ; position: relative ; right: -2px }.modal-close-btn svg { margin: 5px 5px }"+`.modal-close-btn:hover { background-color: #f2f2f2${"dark"==a?"00":""}}`+".chatgpt-modal .checkbox-group { display: flex ; margin-top: -18px }.chatgpt-modal .checkbox-group label {font-size: .7rem ; margin: -.04rem 0 0px .3rem ;"+`color: ${"dark"==a?"#e1e1e1":"#1e1e1e"}}`+'.chatgpt-modal input[type="checkbox"] { transform: scale(0.7) ;'+`border: 1px solid ${"dark"==a?"white":"black"}}`+'.chatgpt-modal input[type="checkbox"]:checked {'+`border: 1px solid ${"dark"==a?"white":"black"} ;`+'background-color: black ; position: inherit }.chatgpt-modal input[type="checkbox"]:focus { outline: none ; box-shadow: none }'),l.innerText=e||"",u.innerText=t||"",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<h.length){const e=document.getElementById(h[0]);setTimeout(()=>{e.style.display="",setTimeout(()=>{e.classList.add("animated")},100)},500)}},50)});return i.id},askAndGetReply:async function(e){return chatgpt.send(e),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},autoRefresh:{activate:function(e){if(this.isActive)console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already active!");else{const n=this,o=(this.toggle.refreshFrame(),t=>{var e=Math.max(2,Math.floor(21*chatgpt.randomFloat()-10));n.isActive=setTimeout(()=>{var e=document.querySelector('script[src*="_ssgManifest.js"]');document.querySelector("#refresh-frame").src=e.src+"?"+Date.now(),console.log("↻ ChatGPT >> ["+n.nowTimeStamp()+"] ChatGPT session refreshed"),o(t)},1e3*(t+e))});o(e?parseInt(e,10):30),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh activated"),navigator.userAgent.includes("Chrome")&&void 0!==document.hidden&&document.addEventListener("visibilitychange",this.toggle.beacons)}},deactivate:function(){this.isActive?(this.toggle.refreshFrame(),document.removeEventListener("visibilitychange",this.toggle.beacons),clearTimeout(this.isActive),this.isActive=null,console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh de-activated")):console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already inactive!")},nowTimeStamp:function(){var e=new Date,t=e.getHours()%12||12;let n=e.getMinutes(),o=e.getSeconds();n<10&&(n="0"+n),o<10&&(o="0"+o);e=e.getHours()<12?"AM":"PM";return t+":"+n+":"+o+" "+e},toggle:{beacons:function(){chatgpt.autoRefresh.beaconID?(clearInterval(chatgpt.autoRefresh.beaconID),chatgpt.autoRefresh.beaconID=null,console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacons de-activated")):(chatgpt.autoRefresh.beaconID=setInterval(()=>{navigator.sendBeacon("https://httpbin.org/post",new Uint8Array),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacon sent")},9e4),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacons activated"))},refreshFrame:function(){let e=document.querySelector("#refresh-frame");e?e.remove():(e=Object.assign(document.createElement("iframe"),{id:"refresh-frame",style:"display: none"}),document.head.prepend(e))}}},browser:{isLightMode:function(){return window.matchMedia?.("(prefers-color-scheme: light)")?.matches},isDarkMode:function(){return window.matchMedia?.("(prefers-color-scheme: dark)")?.matches},isChromium:function(){return navigator.userAgent.includes("Chrome")},isFirefox:function(){return navigator.userAgent.includes("Firefox")},isFullScreen:function(){var e=navigator.userAgent;return e.includes("Chrome")?window.matchMedia("(display-mode: fullscreen)").matches:e.includes("Firefox")?window.fullScreen:/MSIE|rv:/.test(e)?document.msFullscreenElement:document.webkitIsFullScreen},isMobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}},clearChats:async function(e){var t=["api","dom"];if((e=(e||"dom").trim().toLowerCase())&&!t.includes(e))return console.error(`Method argument must be one of: [${t}]`);if("dom"!=e)return new Promise((n,o)=>{chatgpt.getAccessToken().then(e=>{const t=new XMLHttpRequest;t.open("PATCH",endpoints.openAI.chats,!0),t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("Authorization","Bearer "+e),t.onload=()=>{if(200!==t.status)return o("🤖 chatgpt.js >> Request failed. Cannot clear chats.");console.info("Chats successfully cleared"),n()},t.send(JSON.stringify({is_visible:!1}))}).catch(e=>o(new Error(e.message)))});t=t=>new Promise(e=>setTimeout(e,t));try{chatgpt.menu.open(),await t(10);document.querySelector('a[role="menuitem"] svg path[d*="M12.003 10.5a1.5"]').parentNode.parentNode.click(),await t(333);var n=document.querySelectorAll("[id*=radix] button");return n[n.length-1].click(),await t(10),document.querySelector('button[class*="danger"').click(),console.info("Chats successfully cleared.")}catch(e){console.error(e.message),0==arguments.length&&(console.info("Using backend API method instead."),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<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send("Refactor the following code for "+(t||"brevity")+":\n\n"+e),console.info("Refactoring code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))},review:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Review the following code for me:\n\n"+e),console.info("Reviewing code..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")):console.error("Code argument not supplied. Pass some code!")},unminify:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Unminify the following code.:\n\n"+e),console.info("Unminifying code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},write:async function(e,t){if(!e)return console.error("Prompt (1st) argument not supplied. Pass a prompt!");if(!t)return console.error("outputLang (2nd) argument not supplied. Pass a language!");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send(e+"\n\nWrite this as code in "+t),console.info("Writing code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))}},continue:function(){chatgpt.response.continue()},detectLanguage:async function(e){return e?"string"!=typeof e?console.error("Text argument must be a string!"):(chatgpt.send("Detect the language of the following text:\n\n"+e+"\n\nOnly respond with the name of the language"),console.info("Reviewing text..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")):console.error("Text argument not supplied. Pass some text!")},executeCode:function(){chatgpt.code.execute()},exportChat:async function(e,t){e=e?Number.isInteger(e)||/^\d+$/.test(e)?parseInt(e,10):e:"active",t=t.toLowerCase()||"html",console.info("Generating transcript...");let o="",n;if(/te?xt/.test(t)){var r=new Date,a=r.getDate().toString().padStart(2,"0"),s=(r.getMonth()+1).toString().padStart(2,"0"),i=r.getFullYear(),c=r.getHours().toString().padStart(2,"0"),r=r.getMinutes().toString().padStart(2,"0");if(n=`ChatGPT_${a}-${s}-${i}_${c}-${r}.txt`,"active"==e&&/\/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(window.location.href)){a=document.querySelectorAll("main > div > div > div > div > div > div[class*=group]");if(0===a.length)return console.error("Chat is empty!");const l=[];let n=!0;a.forEach(e=>{var t=n?"USER":"CHATGPT",e=(n=!n,Array.from(e.childNodes).map(e=>e.innerText).join("\n\n").replace("Copy code",""));l.push(t+": "+e)}),o=l.join("\n\n")}else for(const u of await chatgpt.getChatData(e,"msg","both","all"))o=(o+=`USER: ${u.user}
|
|
7
|
+
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)<d)&&(g||((g=document.createElement("style")).id="chatgpt-modal-style",g.setAttribute("last-updated",d.toString()),document.head.append(g)),g.innerText=".chatgpt-modal {position: fixed ; top: 0 ; left: 0 ; width: 100% ; height: 100% ;background-color: rgba(67, 70, 72, 0) ;transition: background-color 0.05s ease ;display: flex ; justify-content: center ; align-items: center ; z-index: 9999 }.chatgpt-modal > div {opacity: 0 ; transform: translateX(-2px) translateY(5px) ; max-width: 75vw ; word-wrap: break-word ;transition: opacity 0.1s cubic-bezier(.165,.84,.44,1), transform 0.2s cubic-bezier(.165,.84,.44,1) ;"+`background-color: ${"dark"==a?"black":"white"} ;`+("dark"!=a?"border: 1px solid rgba(0, 0, 0, 0.3) ;":"")+"padding: 20px ; margin: 12px 23px ; border-radius: 15px ; box-shadow: 0 30px 60px rgba(0, 0, 0, .12) ; -webkit-user-select: none ; -moz-user-select: none ; -ms-user-select: none ; user-select: none ; }.chatgpt-modal h2 { margin-bottom: 9px }"+`.chatgpt-modal a { color: ${"dark"==a?"#00cfff":"#1e9ebb"}}`+".chatgpt-modal.animated > div { opacity: 1 ; transform: translateX(0) translateY(0) }@keyframes alert-zoom-fade-out { 0% { opacity: 1 ; transform: scale(1) }50% { opacity: 0.25 ; transform: scale(1.05) }100% { opacity: 0 ; transform: scale(1.35) }}.modal-buttons { display: flex ; justify-content: flex-end ; margin: 20px -5px -3px 0 ;"+(s?"flex-direction: column-reverse":"")+"}.chatgpt-modal button {"+`margin-left: ${s?0:10}px ; padding: ${s?15:4}px 18px ; border-radius: 15px ;`+(s?"margin-top: 5px ; margin-bottom: 3px ;":"")+`border: 1px solid ${"dark"==a?"white":"black"}}`+".primary-modal-btn {"+`border: 1px solid ${"dark"==a?"white":"black"} ;`+`background: ${"dark"==a?"white":"black"} ;`+`color: ${"dark"==a?"black":"white"}}`+".chatgpt-modal button:hover { color: #3d5d71 ; border-color: #6d9cb9 ;background-color: "+("dark"==a?"#00cfff":"#9cdaff")+";box-shadow: 2px 1px "+("dark"==a?"54px #00cfff":"30px #9cdaff")+"}.modal-close-btn {cursor: pointer ; width: 20px ; height: 20px ; float: right ; position: relative ; right: -2px }.modal-close-btn svg { margin: 5px 5px }"+`.modal-close-btn:hover { background-color: #f2f2f2${"dark"==a?"00":""}}`+".chatgpt-modal .checkbox-group { display: flex ; margin-top: -18px }.chatgpt-modal .checkbox-group label {font-size: .7rem ; margin: -.04rem 0 0px .3rem ;"+`color: ${"dark"==a?"#e1e1e1":"#1e1e1e"}}`+'.chatgpt-modal input[type="checkbox"] { transform: scale(0.7) ;'+`border: 1px solid ${"dark"==a?"white":"black"}}`+'.chatgpt-modal input[type="checkbox"]:checked {'+`border: 1px solid ${"dark"==a?"white":"black"} ;`+'background-color: black ; position: inherit }.chatgpt-modal input[type="checkbox"]:focus { outline: none ; box-shadow: none }'),l.innerText=e||"",u.innerText=t||"",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<h.length){const e=document.getElementById(h[0]);setTimeout(()=>{e.style.display="",setTimeout(()=>{e.classList.add("animated")},100)},500)}},50)});return i.id},askAndGetReply:async function(e){return chatgpt.send(e),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")},autoRefresh:{activate:function(e){if(this.isActive)console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already active!");else{const n=this,o=(this.toggle.refreshFrame(),t=>{var e=Math.max(2,Math.floor(21*chatgpt.randomFloat()-10));n.isActive=setTimeout(()=>{var e=document.querySelector('script[src*="_ssgManifest.js"]');document.querySelector("#refresh-frame").src=e.src+"?"+Date.now(),console.log("↻ ChatGPT >> ["+n.nowTimeStamp()+"] ChatGPT session refreshed"),o(t)},1e3*(t+e))});o(e?parseInt(e,10):30),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh activated"),navigator.userAgent.includes("Chrome")&&void 0!==document.hidden&&document.addEventListener("visibilitychange",this.toggle.beacons)}},deactivate:function(){this.isActive?(this.toggle.refreshFrame(),document.removeEventListener("visibilitychange",this.toggle.beacons),clearTimeout(this.isActive),this.isActive=null,console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh de-activated")):console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Auto refresh already inactive!")},nowTimeStamp:function(){var e=new Date,t=e.getHours()%12||12;let n=e.getMinutes(),o=e.getSeconds();n<10&&(n="0"+n),o<10&&(o="0"+o);e=e.getHours()<12?"AM":"PM";return t+":"+n+":"+o+" "+e},toggle:{beacons:function(){chatgpt.autoRefresh.beaconID?(clearInterval(chatgpt.autoRefresh.beaconID),chatgpt.autoRefresh.beaconID=null,console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacons de-activated")):(chatgpt.autoRefresh.beaconID=setInterval(()=>{navigator.sendBeacon("https://httpbin.org/post",new Uint8Array),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacon sent")},9e4),console.log("↻ ChatGPT >> ["+chatgpt.autoRefresh.nowTimeStamp()+"] Beacons activated"))},refreshFrame:function(){let e=document.querySelector("#refresh-frame");e?e.remove():(e=Object.assign(document.createElement("iframe"),{id:"refresh-frame",style:"display: none"}),document.head.prepend(e))}}},browser:{isLightMode:function(){return window.matchMedia?.("(prefers-color-scheme: light)")?.matches},isDarkMode:function(){return window.matchMedia?.("(prefers-color-scheme: dark)")?.matches},isChromium:function(){return navigator.userAgent.includes("Chrome")},isFirefox:function(){return navigator.userAgent.includes("Firefox")},isFullScreen:function(){var e=navigator.userAgent;return e.includes("Chrome")?window.matchMedia("(display-mode: fullscreen)").matches:e.includes("Firefox")?window.fullScreen:/MSIE|rv:/.test(e)?document.msFullscreenElement:document.webkitIsFullScreen},isMobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}},clearChats:async function(e){var t=["api","dom"];if((e=(e||"dom").trim().toLowerCase())&&!t.includes(e))return console.error(`Method argument must be one of: [${t}]`);if("dom"!=e)return new Promise((n,o)=>{chatgpt.getAccessToken().then(e=>{const t=new XMLHttpRequest;t.open("PATCH",endpoints.openAI.chats,!0),t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("Authorization","Bearer "+e),t.onload=()=>{if(200!==t.status)return o("🤖 chatgpt.js >> Request failed. Cannot clear chats.");console.info("Chats successfully cleared"),n()},t.send(JSON.stringify({is_visible:!1}))}).catch(e=>o(new Error(e.message)))});t=t=>new Promise(e=>setTimeout(e,t));try{chatgpt.menu.open(),await t(10);document.querySelector('a[role="menuitem"] svg path[d*="M12.003 10.5a1.5"]').parentNode.parentNode.click(),await t(333);var n=document.querySelectorAll("[id*=radix] button");return n[n.length-1].click(),await t(10),document.querySelector('button[class*="danger"').click(),console.info("Chats successfully cleared.")}catch(e){console.error(e.message),0==arguments.length&&(console.info("Using backend API method instead."),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<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send("Refactor the following code for "+(t||"brevity")+":\n\n"+e),console.info("Refactoring code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))},review:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Review the following code for me:\n\n"+e),console.info("Reviewing code..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")):console.error("Code argument not supplied. Pass some code!")},unminify:async function(e){return e?"string"!=typeof e?console.error("Code argument must be a string!"):(chatgpt.send("Unminify the following code.:\n\n"+e),console.info("Unminifying code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))):console.error("Code argument not supplied. Pass some code!")},write:async function(e,t){if(!e)return console.error("Prompt (1st) argument not supplied. Pass a prompt!");if(!t)return console.error("outputLang (2nd) argument not supplied. Pass a language!");for(let e=0;e<arguments.length;e++)if("string"!=typeof arguments[e])return console.error(`Argument ${e+1} must be a string.`);return chatgpt.send(e+"\n\nWrite this as code in "+t),console.info("Writing code..."),await chatgpt.isIdle(),chatgpt.code.extract(await chatgpt.getChatData("active","msg","chatgpt","latest"))}},continue:function(){chatgpt.response.continue()},detectLanguage:async function(e){return e?"string"!=typeof e?console.error("Text argument must be a string!"):(chatgpt.send("Detect the language of the following text:\n\n"+e+"\n\nOnly respond with the name of the language"),console.info("Reviewing text..."),await chatgpt.isIdle(),chatgpt.getChatData("active","msg","chatgpt","latest")):console.error("Text argument not supplied. Pass some text!")},executeCode:function(){chatgpt.code.execute()},exportChat:async function(e,t){e=e?Number.isInteger(e)||/^\d+$/.test(e)?parseInt(e,10):e:"active",t=t.toLowerCase()||"html",console.info("Generating transcript...");let o="",n;if(/te?xt/.test(t)){var r=new Date,a=r.getDate().toString().padStart(2,"0"),s=(r.getMonth()+1).toString().padStart(2,"0"),i=r.getFullYear(),c=r.getHours().toString().padStart(2,"0"),r=r.getMinutes().toString().padStart(2,"0");if(n=`ChatGPT_${a}-${s}-${i}_${c}-${r}.txt`,"active"==e&&/\/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(window.location.href)){a=document.querySelectorAll("main > div > div > div > div > div > div[class*=group]");if(0===a.length)return console.error("Chat is empty!");const l=[];let n=!0;a.forEach(e=>{var t=n?"USER":"CHATGPT",e=(n=!n,Array.from(e.childNodes).map(e=>e.innerText).join("\n\n").replace("Copy code",""));l.push(t+": "+e)}),o=l.join("\n\n")}else for(const u of await chatgpt.getChatData(e,"msg","both","all"))o=(o+=`USER: ${u.user}
|
|
8
8
|
|
|
9
9
|
`)+`CHATGPT: ${u.chatgpt}
|
|
10
10
|
|
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.0.0/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)
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
|
|
64
64
|
</div>
|
|
65
65
|
|
|
66
|
-
<span style="color: white">chatgpt.js</span> is a <span style="color: white">powerful</span> JavaScript library that allows for <span style="color: white">super easy</span> interaction w/ the ChatGPT DOM.
|
|
66
|
+
<span style="color: white"><b>chatgpt.js</b></span> is a <span style="color: white">powerful</span> JavaScript library that allows for <span style="color: white">super easy</span> interaction w/ the ChatGPT DOM.
|
|
67
67
|
|
|
68
68
|
- Feature-rich
|
|
69
69
|
- Object-oriented
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
|
|
85
85
|
```js
|
|
86
86
|
(async () => {
|
|
87
|
-
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@
|
|
87
|
+
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.0/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@
|
|
96
|
+
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.0/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@
|
|
118
|
+
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.0/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/
|
|
193
|
+
If it didn't, check out the extended [userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.0.0/docs/USERGUIDE.md), or simply submit an [issue](https://github.com/KudoAI/chatgpt.js/issues) or [PR](https://github.com/KudoAI/chatgpt.js/pulls) and it will be integrated, ezpz!
|
|
194
194
|
|
|
195
195
|
<img height=8px width="100%" src="https://media.chatgptjs.org/images/separators/gradient-aqua.png?78210a7">
|
|
196
196
|
|
|
@@ -204,6 +204,13 @@ https://github.com/KudoAI/chatgpt.js/assets/10906554/f53c740f-d5e0-49b6-ae02-3b3
|
|
|
204
204
|
|
|
205
205
|
#
|
|
206
206
|
|
|
207
|
+
### <img src="https://amazongpt.kudoai.com/assets/images/icons/amazongpt/black-gold-teal/icon48.png" width=20> [AmazonGPT](https://amazongpt.kudoai.com)
|
|
208
|
+
|
|
209
|
+
> Add AI to Amazon shopping.
|
|
210
|
+
<br>[Install](https://greasyfork.org/scripts/500663-amazongpt) /
|
|
211
|
+
[Readme](https://amazongpt.kudoai.com/#readme) /
|
|
212
|
+
[Discuss](https://amazongpt.kudoai.com/discussions)
|
|
213
|
+
|
|
207
214
|
### <picture><source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://media.autoclearchatgpt.com/images/icons/openai/white/icon48.png?cece513"><img width=21 src="https://media.autoclearchatgpt.com/images/icons/openai/black/icon48.png?cece513"></picture> [Autoclear ChatGPT History](https://autoclearchatgpt.com) <a href="https://github.com/awesome-scripts/awesome-userscripts#chatgpt" target="_blank" rel="noopener"><img src="https://media.autoclearchatgpt.com/images/badges/awesome/badge.svg?2c0d9fc" style="margin:0 0 -2px 5px"></a>
|
|
208
215
|
|
|
209
216
|
> Auto-clear your ChatGPT query history for maximum privacy.
|
|
@@ -213,7 +220,7 @@ https://github.com/KudoAI/chatgpt.js/assets/10906554/f53c740f-d5e0-49b6-ae02-3b3
|
|
|
213
220
|
|
|
214
221
|
### <img width=24 src="https://media.bravegpt.com/images/icons/bravegpt/icon48.png?0a9e287"> [BraveGPT](https://bravegpt.com) <a href="https://www.producthunt.com/posts/bravegpt?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-bravegpt" target="_blank" rel="noopener"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=385630&theme=light" style="width: 112px; height: 24px; margin:0 0 -4px 5px;" width="112" height="24" /></a>
|
|
215
222
|
|
|
216
|
-
>
|
|
223
|
+
> Adds AI answers to Brave Search (powered by GPT-4o!)
|
|
217
224
|
<br>[Install](https://docs.bravegpt.com/#-installation) /
|
|
218
225
|
[Readme](https://docs.bravegpt.com/#readme) /
|
|
219
226
|
[Discuss](https://github.bravegpt.com/discussions)
|
|
@@ -225,6 +232,13 @@ https://github.com/KudoAI/chatgpt.js/assets/10906554/f53c740f-d5e0-49b6-ae02-3b3
|
|
|
225
232
|
[Readme](https://docs.chatgptautocontinue.com/#readme) /
|
|
226
233
|
[Discuss](https://github.chatgptautocontinue.com/discussions)
|
|
227
234
|
|
|
235
|
+
### <picture><source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://cdn.jsdelivr.net/gh/adamlui/chatgpt-auto-talk@eb7f285/assets/images/icons/openai/white/icon64.png"><img width=21 src="https://cdn.jsdelivr.net/gh/adamlui/chatgpt-auto-talk@eb7f285/assets/images/icons/openai/black/icon64.png"></picture> [ChatGPT Auto-Talk 📣](https://github.com/adamlui/chatgpt-auto-talk)
|
|
236
|
+
|
|
237
|
+
> Auto-play ChatGPT responses.
|
|
238
|
+
<br>[Install](https://greasyfork.org/scripts/500940-chatgpt-auto-talk) /
|
|
239
|
+
[Readme](https://github.com/adamlui/chatgpt-auto-talk#readme) /
|
|
240
|
+
[Discuss](https://github.com/adamlui/chatgpt-auto-talk/discussions)
|
|
241
|
+
|
|
228
242
|
### <picture><source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://media.chatgptautorefresh.com/images/icons/openai/white/icon48.png?a45cf1e"><img width=21 src="https://media.chatgptautorefresh.com/images/icons/openai/black/icon48.png?a45cf1e"></picture> [ChatGPT Auto Refresh ↻](https://chatgptautorefresh.com) <a href="https://github.com/awesome-scripts/awesome-userscripts#chatgpt" target="_blank" rel="noopener"><img src="https://media.chatgptautorefresh.com/images/badges/awesome/badge.svg?1080f44" style="margin:0 0 -2px 5px"></a>
|
|
229
243
|
|
|
230
244
|
> Keeps ChatGPT sessions fresh to eliminate network errors + Cloudflare checks.
|
|
@@ -234,19 +248,19 @@ https://github.com/KudoAI/chatgpt.js/assets/10906554/f53c740f-d5e0-49b6-ae02-3b3
|
|
|
234
248
|
|
|
235
249
|
### <img width=23 src="https://media.ddgpt.com/images/icons/duckduckgpt/icon48.png?af89302"> [DuckDuckGPT](https://duckduckgpt.com) <a href="https://www.producthunt.com/posts/duckduckgpt?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-duckduckgpt" target="_blank" rel="noopener"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=379261&theme=light" style="width: 112px; height: 24px; margin:0 0 -4px 5px;" width="112" height="24" /></a>
|
|
236
250
|
|
|
237
|
-
>
|
|
251
|
+
> Adds AI answers to DuckDuckGo (powered by GPT-4o!)
|
|
238
252
|
<br>[Install](https://docs.ddgpt.com/#-installation) /
|
|
239
253
|
[Readme](https://docs.ddgpt.com/#readme) /
|
|
240
254
|
[Discuss](https://github.ddgpt.com/discussions)
|
|
241
255
|
|
|
242
256
|
### <picture><source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://media.googlegpt.io/images/icons/googlegpt/white/icon32.png?8652a6e"><img width=21 src="https://media.googlegpt.io/images/icons/googlegpt/black/icon32.png?8652a6e"></picture> [GoogleGPT](https://googlegpt.io) <a href="https://github.com/awesome-scripts/awesome-userscripts#chatgpt" target="_blank" rel="noopener"><img src="https://media.googlegpt.io/images/badges/awesome/badge.svg?699c63d" style="margin:0 0 -2px 5px"></a>
|
|
243
257
|
|
|
244
|
-
>
|
|
245
|
-
<br>[Install](https://greasyfork.
|
|
258
|
+
> Adds AI answers to Google Search (powered by Google Gemma + GPT-4o!)
|
|
259
|
+
<br>[Install](https://greasyfork.googlegpt.io) /
|
|
246
260
|
[Readme](https://docs.googlegpt.io/#readme) /
|
|
247
261
|
[Discuss](https://github.googlegpt.io/discussions)
|
|
248
262
|
|
|
249
|
-
### <img width=23 src="https://media.chatgptjs.org/images/icons/platforms/thunderbird/icon32.png?313a9c5"> [ThunderAI](https://micz.it/thunderdbird-addon-thunderai/)
|
|
263
|
+
### <img width=23 src="https://media.chatgptjs.org/images/icons/platforms/thunderbird/icon32.png?313a9c5"> [ThunderAI](https://micz.it/thunderdbird-addon-thunderai/) <a href="https://addons.thunderbird.net/thunderbird/addon/thunderai/reviews"><picture><source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://media.chatgptjs.org/images/badges/5-star/blue-stars.png?0943672"><img width=92 alt="[Rated 5-stars]" src="https://media.chatgptjs.org/images/badges/5-star/yellow-stars-in-white-pill.png?0943672"></picture></a>
|
|
250
264
|
|
|
251
265
|
> Use ChatGPT in Thunderbird to enhance you emails, even with a free account!
|
|
252
266
|
<br>[Install](https://addons.thunderbird.net/thunderbird/addon/thunderai/) /
|
|
@@ -310,6 +324,7 @@ This library exists thanks to code, translations, issues & ideas from the follow
|
|
|
310
324
|
[](https://github.com/Luwa-Tech)
|
|
311
325
|
[](https://github.com/micz)
|
|
312
326
|
[](https://github.com/imranaalam)
|
|
327
|
+
[](https://github.com/grayfallstown)
|
|
313
328
|
[](https://github.com/dependabot)
|
|
314
329
|
<a href="https://chatgpt.com"><picture><source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://images.weserv.nl/?url=https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@main/media/images/icons/platforms/chatgpt/black-on-white/icon189.png?h=46&w=46&mask=circle&maxage=7d"><img src="https://images.weserv.nl/?url=https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@main/media/images/icons/platforms/chatgpt/white-on-black/icon189.png?h=46&w=46&mask=circle&maxage=7d" title="ChatGPT"></picture></a>
|
|
315
330
|
<a href="https://poe.com"><picture><source type="image/png" media="(prefers-color-scheme: dark)" srcset="https://images.weserv.nl/?url=https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@main/media/images/icons/platforms/poe/w-purple-blue-stripes/black-on-white/icon175.png?h=46&w=46&mask=circle&maxage=7d"><img src="https://images.weserv.nl/?url=https://cdn.jsdelivr.net/gh/KudoAI/chatgpt.js@main/media/images/icons/platforms/poe/w-purple-blue-stripes/white-on-black/icon175.png?h=46&w=46&mask=circle&maxage=7d" title="Poe"></picture></a>
|
|
@@ -343,7 +358,7 @@ This library exists thanks to code, translations, issues & ideas from the follow
|
|
|
343
358
|
<div align="center">
|
|
344
359
|
|
|
345
360
|
**[Releases](https://github.com/KudoAI/chatgpt.js/releases)** /
|
|
346
|
-
[Userguide](https://github.com/KudoAI/chatgpt.js/blob/
|
|
361
|
+
[Userguide](https://github.com/KudoAI/chatgpt.js/blob/v3.0.0/docs/USERGUIDE.md) /
|
|
347
362
|
[Discuss](https://github.com/KudoAI/chatgpt.js/discussions) /
|
|
348
363
|
<a href="#--------------------------------------------------------------------------------english---------简体中文---------繁體中文---------日本---------한국인---------हिंदी---------नेपाली---------deutsch---------español---------français---------italiano---------nederlands---------português---------việt----">Back to top ↑</a>
|
|
349
364
|
|
package/docs/USERGUIDE.md
CHANGED
|
@@ -23,11 +23,8 @@
|
|
|
23
23
|
- [generateRandomIP](#generaterandomip)
|
|
24
24
|
- [get](#get)
|
|
25
25
|
- [getUserLanguage](#getuserlanguage)
|
|
26
|
-
- [isChromium](#ischromium)
|
|
27
|
-
- [isFirefox](#isfirefox)
|
|
28
26
|
- [isFullScreen](#isfullscreen)
|
|
29
27
|
- [isLoaded `async`](#isloaded-async)
|
|
30
|
-
- [isMobileDevice](#ismobiledevice)
|
|
31
28
|
- [printAllFunctions](#printallfunctions)
|
|
32
29
|
- [randomFloat](#randomfloat)
|
|
33
30
|
- [renderHTML](#renderhtml)
|
|
@@ -71,6 +68,7 @@
|
|
|
71
68
|
- [startNewChat](#startnewchat)
|
|
72
69
|
- [stop](#stop)
|
|
73
70
|
- [DOM related](#dom-related)
|
|
71
|
+
- [focusChatbar](#focuschatbar)
|
|
74
72
|
- [getChatBox](#getchatbox)
|
|
75
73
|
- [getContinueGeneratingButton](#getcontinuegeneratingbutton)
|
|
76
74
|
- [getFooterDiv](#getfooterdiv)
|
|
@@ -93,14 +91,18 @@
|
|
|
93
91
|
- [browser `api`](#browser-api)
|
|
94
92
|
- [isLightMode](#islightmode-1)
|
|
95
93
|
- [isDarkMode](#isdarkmode-1)
|
|
96
|
-
- [isChromium](#ischromium
|
|
97
|
-
- [
|
|
94
|
+
- [isChromium](#ischromium)
|
|
95
|
+
- [isChrome](#ischrome)
|
|
96
|
+
- [isEdge](#isedge)
|
|
97
|
+
- [isBrave](#isbrave)
|
|
98
|
+
- [isFirefox](#isfirefox)
|
|
98
99
|
- [isFullScreen](#isfullscreen-1)
|
|
99
100
|
- [isMobile](#ismobile)
|
|
100
101
|
- [code `api`](#code-api)
|
|
101
102
|
- [minify `async`](#minify-async)
|
|
102
103
|
- [execute `async`](#execute-async)
|
|
103
104
|
- [extract](#extract)
|
|
105
|
+
- [isIdle `async`](#isidle-async-1)
|
|
104
106
|
- [obfuscate `async`](#obfuscate-async)
|
|
105
107
|
- [refactor `async`](#refactor-async)
|
|
106
108
|
- [review `async`](#review-async)
|
|
@@ -148,7 +150,7 @@
|
|
|
148
150
|
|
|
149
151
|
```js
|
|
150
152
|
(async () => {
|
|
151
|
-
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@
|
|
153
|
+
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.0/dist/chatgpt.min.js');
|
|
152
154
|
// Your code here...
|
|
153
155
|
})();
|
|
154
156
|
```
|
|
@@ -157,7 +159,7 @@
|
|
|
157
159
|
|
|
158
160
|
```js
|
|
159
161
|
var xhr = new XMLHttpRequest();
|
|
160
|
-
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@
|
|
162
|
+
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.0/dist/chatgpt.min.js');
|
|
161
163
|
xhr.onload = function () {
|
|
162
164
|
if (xhr.status === 200) {
|
|
163
165
|
var chatgptJS = document.createElement('script');
|
|
@@ -179,7 +181,7 @@ function yourCode() {
|
|
|
179
181
|
|
|
180
182
|
```js
|
|
181
183
|
...
|
|
182
|
-
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@
|
|
184
|
+
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.0.0/dist/chatgpt.min.js
|
|
183
185
|
// ==/UserScript==
|
|
184
186
|
|
|
185
187
|
// Your code here...
|
|
@@ -288,30 +290,6 @@ const userLanguage = chatgpt.getUserLanguage();
|
|
|
288
290
|
console.log(userLanguage); // Example output: 'en-US'
|
|
289
291
|
```
|
|
290
292
|
|
|
291
|
-
### isChromium
|
|
292
|
-
|
|
293
|
-
Returns a boolean value. `true` if the browser is Chromium and `false` otherwise.
|
|
294
|
-
|
|
295
|
-
Example code:
|
|
296
|
-
|
|
297
|
-
```js
|
|
298
|
-
if (chatgpt.isChromium()) {
|
|
299
|
-
// Do something
|
|
300
|
-
}
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
### isFirefox
|
|
304
|
-
|
|
305
|
-
Returns a boolean value. `true` if the browser is Firefox and `false` otherwise.
|
|
306
|
-
|
|
307
|
-
Example code:
|
|
308
|
-
|
|
309
|
-
```js
|
|
310
|
-
if (chatgpt.isFirefox()) {
|
|
311
|
-
// Do something
|
|
312
|
-
}
|
|
313
|
-
```
|
|
314
|
-
|
|
315
293
|
### isFullScreen
|
|
316
294
|
|
|
317
295
|
Returns a boolean value. `true` if the website is fullscreen and `false` otherwise.
|
|
@@ -337,18 +315,6 @@ Example code:
|
|
|
337
315
|
})();
|
|
338
316
|
```
|
|
339
317
|
|
|
340
|
-
### isMobileDevice
|
|
341
|
-
|
|
342
|
-
Returns a boolean value. `true` if the user device is mobile and `false` otherwise.
|
|
343
|
-
|
|
344
|
-
Example code:
|
|
345
|
-
|
|
346
|
-
```js
|
|
347
|
-
if (chatgpt.isMobileDevice()) {
|
|
348
|
-
// Do something
|
|
349
|
-
}
|
|
350
|
-
```
|
|
351
|
-
|
|
352
318
|
### printAllFunctions
|
|
353
319
|
|
|
354
320
|
Prints all the library functions to the console.
|
|
@@ -668,11 +634,13 @@ Example code:
|
|
|
668
634
|
|
|
669
635
|
### clearChats `async`
|
|
670
636
|
|
|
671
|
-
|
|
637
|
+
Clears chat history.
|
|
672
638
|
|
|
673
|
-
|
|
639
|
+
Example code:
|
|
674
640
|
|
|
675
|
-
|
|
641
|
+
```js
|
|
642
|
+
chatgpt.clearChats().then(() => console.log('Chat history cleared!'));
|
|
643
|
+
```
|
|
676
644
|
|
|
677
645
|
### exportChat `async`
|
|
678
646
|
|
|
@@ -933,15 +901,14 @@ console.log(fifthResp); // Example output: 'Hello from ChatGPT!'
|
|
|
933
901
|
|
|
934
902
|
### isIdle `async`
|
|
935
903
|
|
|
936
|
-
|
|
904
|
+
Resolves a promise when ChatGPT has finished generating a response.
|
|
937
905
|
|
|
938
906
|
Example code:
|
|
939
907
|
|
|
940
908
|
```js
|
|
941
909
|
(async () => {
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
}
|
|
910
|
+
await chatgpt.code.isIdle();
|
|
911
|
+
console.log('ChatGPT is idle');
|
|
945
912
|
})();
|
|
946
913
|
```
|
|
947
914
|
|
|
@@ -1070,6 +1037,16 @@ chatgpt.stop();
|
|
|
1070
1037
|
|
|
1071
1038
|
## DOM related
|
|
1072
1039
|
|
|
1040
|
+
### focusChatbar
|
|
1041
|
+
|
|
1042
|
+
Focuses the chatbar.
|
|
1043
|
+
|
|
1044
|
+
Example code:
|
|
1045
|
+
|
|
1046
|
+
```js
|
|
1047
|
+
chatgpt.focusChatbar();
|
|
1048
|
+
```
|
|
1049
|
+
|
|
1073
1050
|
### getChatBox
|
|
1074
1051
|
|
|
1075
1052
|
Returns the chat input as an HTML element.
|
|
@@ -1122,7 +1099,7 @@ Example code:
|
|
|
1122
1099
|
|
|
1123
1100
|
```js
|
|
1124
1101
|
const newChatBtn = chatgpt.getNewChatButton();
|
|
1125
|
-
newChatBtn.
|
|
1102
|
+
newChatBtn.style.display = 'none'; // hide New Chat button
|
|
1126
1103
|
```
|
|
1127
1104
|
|
|
1128
1105
|
### getNewChatLink
|
|
@@ -1133,7 +1110,7 @@ Example code:
|
|
|
1133
1110
|
|
|
1134
1111
|
```js
|
|
1135
1112
|
const newChatLink = chatgpt.getNewChatLink();
|
|
1136
|
-
newChatLink.
|
|
1113
|
+
newChatLink.style.display = 'none'; // hide New Chat link
|
|
1137
1114
|
```
|
|
1138
1115
|
|
|
1139
1116
|
### getRegenerateButton
|
|
@@ -1295,6 +1272,42 @@ if (chatgpt.browser.isChromium()) {
|
|
|
1295
1272
|
}
|
|
1296
1273
|
```
|
|
1297
1274
|
|
|
1275
|
+
### isChrome
|
|
1276
|
+
|
|
1277
|
+
Returns a boolean value. `true` if the browser is Chrome and `false` otherwise.
|
|
1278
|
+
|
|
1279
|
+
Example code:
|
|
1280
|
+
|
|
1281
|
+
```js
|
|
1282
|
+
if (chatgpt.browser.isChrome()) {
|
|
1283
|
+
// Do something
|
|
1284
|
+
}
|
|
1285
|
+
```
|
|
1286
|
+
|
|
1287
|
+
### isEdge
|
|
1288
|
+
|
|
1289
|
+
Returns a boolean value. `true` if the browser is Edge and `false` otherwise.
|
|
1290
|
+
|
|
1291
|
+
Example code:
|
|
1292
|
+
|
|
1293
|
+
```js
|
|
1294
|
+
if (chatgpt.browser.isEdge()) {
|
|
1295
|
+
// Do something
|
|
1296
|
+
}
|
|
1297
|
+
```
|
|
1298
|
+
|
|
1299
|
+
### isBrave
|
|
1300
|
+
|
|
1301
|
+
Returns a boolean value. `true` if the browser is Brave and `false` otherwise.
|
|
1302
|
+
|
|
1303
|
+
Example code:
|
|
1304
|
+
|
|
1305
|
+
```js
|
|
1306
|
+
if (chatgpt.browser.isBrave()) {
|
|
1307
|
+
// Do something
|
|
1308
|
+
}
|
|
1309
|
+
```
|
|
1310
|
+
|
|
1298
1311
|
### isFirefox
|
|
1299
1312
|
|
|
1300
1313
|
Returns a boolean value. `true` if the browser is Firefox and `false` otherwise.
|
|
@@ -1414,6 +1427,20 @@ Example code:
|
|
|
1414
1427
|
})();
|
|
1415
1428
|
```
|
|
1416
1429
|
|
|
1430
|
+
### isIdle `async`
|
|
1431
|
+
|
|
1432
|
+
Resolves a promise when code has finished generating.
|
|
1433
|
+
|
|
1434
|
+
Example code:
|
|
1435
|
+
|
|
1436
|
+
```js
|
|
1437
|
+
(async () => {
|
|
1438
|
+
chatgpt.send('Type me a short code block');
|
|
1439
|
+
await chatgpt.code.isIdle();
|
|
1440
|
+
console.log('Code finished generating'); // non-code may still be generating
|
|
1441
|
+
})();
|
|
1442
|
+
```
|
|
1443
|
+
|
|
1417
1444
|
### obfuscate `async`
|
|
1418
1445
|
|
|
1419
1446
|
Asks ChatGPT to obfuscate the given code.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kudoai/chatgpt.js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Client-side JavaScript library for ChatGPT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "KudoAI & contributors",
|
|
@@ -64,11 +64,11 @@
|
|
|
64
64
|
"url": "https://github.com/sponsors/KudoAI"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@adamlui/minify.js": "^1.
|
|
68
|
-
"@adamlui/scss-to-css": "^1.10.
|
|
67
|
+
"@adamlui/minify.js": "^1.8.1",
|
|
68
|
+
"@adamlui/scss-to-css": "^1.10.3",
|
|
69
69
|
"docsify-cli": "^4.4.4",
|
|
70
|
-
"eslint": "^9.
|
|
71
|
-
"eslint-plugin-json
|
|
72
|
-
"husky": "^9.0
|
|
70
|
+
"eslint": "^9.5.0",
|
|
71
|
+
"eslint-plugin-json": "^4.0.0",
|
|
72
|
+
"husky": "^9.1.0"
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<h6>
|
|
3
3
|
<picture>
|
|
4
|
-
<source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://media.chatgptjs.org/images/icons/earth-americas-white-icon32.svg">
|
|
5
|
-
<img height=14 src="https://media.chatgptjs.org/images/icons/earth-americas-icon32.svg">
|
|
4
|
+
<source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://media.chatgptjs.org/images/icons/earth-americas-white-icon32.svg?main">
|
|
5
|
+
<img height=14 src="https://media.chatgptjs.org/images/icons/earth-americas-icon32.svg?main">
|
|
6
6
|
</picture>
|
|
7
7
|
English |
|
|
8
8
|
<a href="docs/zh-cn/LICENSE.md">简体中文</a> |
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<h6>
|
|
3
3
|
<picture>
|
|
4
|
-
<source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://media.chatgptjs.org/images/icons/earth-americas-white-icon32.svg">
|
|
5
|
-
<img height=14 src="https://media.chatgptjs.org/images/icons/earth-americas-icon32.svg">
|
|
4
|
+
<source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://media.chatgptjs.org/images/icons/earth-americas-white-icon32.svg?main">
|
|
5
|
+
<img height=14 src="https://media.chatgptjs.org/images/icons/earth-americas-icon32.svg?main">
|
|
6
6
|
</picture>
|
|
7
7
|
English |
|
|
8
8
|
<a href="zh-cn#readme">简体中文</a> |
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<div align="right">
|
|
2
2
|
<h6>
|
|
3
3
|
<picture>
|
|
4
|
-
<source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://media.chatgptjs.org/images/icons/earth-americas-white-icon32.svg">
|
|
5
|
-
<img height=14 src="https://media.chatgptjs.org/images/icons/earth-americas-icon32.svg">
|
|
4
|
+
<source type="image/svg+xml" media="(prefers-color-scheme: dark)" srcset="https://media.chatgptjs.org/images/icons/earth-americas-white-icon32.svg?main">
|
|
5
|
+
<img height=14 src="https://media.chatgptjs.org/images/icons/earth-americas-icon32.svg?main">
|
|
6
6
|
</picture>
|
|
7
7
|
English |
|
|
8
8
|
<a href="https://github.com/KudoAI/chatgpt.js-chrome-starter/blob/main/docs/zh-cn/SECURITY.md">简体中文</a> |
|