🤖 A powerful client-side JavaScript library for ChatGPT
💡 About
chatgpt.js is a powerful JavaScript library that allows for super easy interaction w/ the ChatGPT DOM.
Feature-rich
Object-oriented
Easy-to-use
Lightweight (yet optimally performant)
⚡ Importing the library
ES6:
(async()=>{awaitimport('https://code.chatgptjs.org/chatgpt-latest.min.js');// Your code here...})();
ES5:
varxhr=newXMLHttpRequest();xhr.open('GET','https://code.chatgptjs.org/chatgpt-latest.min.js');xhr.onload=function(){if(xhr.status===200){varchatgptJS=document.createElement('script');chatgptJS.textContent=xhr.responseText;document.head.append(chatgptJS);yourCode();// runs your code}};xhr.send();functionyourCode(){// Your code here...}
Userscript repositories like Greasy Fork maintain a whitelist of pre-approved CDNs (such as commit-specific references from cdn.jsdelivr.net) so the import URL is substantially lengthier to preserve publishability to these sites:
...
// @require https://cdn.jsdelivr.net/gh/kudoai/chatgpt.js@3ff1d910a62b989e02da86c8c4dd3ce14232216e/dist/chatgpt-2.6.3.min.js// ==/UserScript==// Your code here...
If you don't plan on publishing to these repos, the simpler https://code.chatgptjs.org/chatgpt-latest.min.js can be used instead to import the latest minified release.