chatgpt.js is a powerful JavaScript library that allows for super easy interaction w/ the ChatGPT DOM.
Note To always import the latest version (not recommended in production!) replace the versioned jsDelivr URL with:
https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js/chatgpt.min.js
(async () => {
await import('https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.9.3/dist/chatgpt.min.js');
// Your code here...
})();
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.9.3/dist/chatgpt.min.js');
xhr.onload = function () {
if (xhr.status === 200) {
var chatgptJS = document.createElement('script');
chatgptJS.textContent = xhr.responseText;
document.head.append(chatgptJS);
yourCode(); // runs your code
}
};
xhr.send();
function yourCode() {
// Your code here...
}
Note To use a starter template: kudoai/chatgpt.js-greasemonkey-starter
...
// @require https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@2.9.3/dist/chatgpt.min.js
// ==/UserScript==
// Your code here...
Note To use a starter template: kudoai/chatgpt.js-chrome-starter
Since Google does not allow remote code, importing chatgpt.js locally is required:
Save https://raw.githubusercontent.com/KudoAI/chatgpt.js/main/chatgpt.js to a subdirectory (lib
in this example)
Add ES6 export statement to end of lib/chatgpt.js
...
export { chatgpt }
manifest.json
, add lib/chatgpt.js
as a web accessible resource "web_accessible_resources": [{
"matches": ["<all_urls>"],
"resources": ["lib/chatgpt.js"]
}],
chatgpt.js
(foreground/background alike), import it like so:(async () => {
const { chatgpt } = await import(chrome.runtime.getURL('lib/chatgpt.js'));
// Your code here...
})();
To download chatgpt.js for local customization, run the following command in your project's root:
npm install @kudoai/chatgpt.js
After installation, navigate to node_modules/@kudoai/chatgpt.js
to find the library source.
chatgpt.js was written w/ ultra flexibility in mind.
For example:
chatgpt.getLastResponse();
chatgpt.getLastReply();
chatgpt.response.getLast();
chatgpt.get('reply', 'last');
Each call equally fetches the last response. If you think it works, it probably will... so just type it!
If it didn't, check out the extended userguide, or simply submit an issue or PR and it will be integrated, ezpz!
https://github.com/KudoAI/chatgpt.js/assets/10906554/f53c740f-d5e0-49b6-ae02-3b3140b0f8a4
Auto-clear your ChatGPT query history for maximum privacy.
Install / Readme / Discuss
Display ChatGPT answers in Brave Search sidebar (powered by GPT-4o!)
Install / Readme / Discuss
Automatically continue generating multiple ChatGPT responses.
Install / Readme / Discuss
Keeps ChatGPT sessions fresh to eliminate network errors + Cloudflare checks.
Install / Readme / Discuss
Display ChatGPT answers in DuckDuckGo sidebar (powered by GPT-4o!)
Install / Readme / Discuss
Display ChatGPT answers in Google Search sidebar (powered by GPT-4o!)
Install / Readme / Discuss
Use ChatGPT in Thunderbird to enhance you emails, even with a free account!
Install / Readme / Support
If you've made something w/ chatgpt.js you want to share, email showcase@chatgptjs.org or just open a pull request!
This library exists thanks to code, translations, issues & ideas from the following contributors:
chatgpt.js is funded in part by:
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。