1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

        chatgpt.jsChatGPT 的強(qiáng)大客戶端 JavaScript 庫(kù)

        聯(lián)合創(chuàng)作 · 2023-09-22 01:17

        chatgpt.js 是一個(gè)功能強(qiáng)大的 JavaScript 庫(kù),可輕松與 ChatGPT DOM 進(jìn)行交互。

        • 功能豐富
        • 面向?qū)ο?/li>
        • 易于使用
        • 輕量級(jí)(但性能最優(yōu))

        導(dǎo)入庫(kù)

        ES6:

        (async () => {
            await import('https://code.chatgptjs.org/chatgpt-latest.min.js');    
            // 這里是你的代碼
        })();
        

        ES5:

        var xhr = new XMLHttpRequest()
        xhr.open('GET', 'https://code.chatgptjs.org/chatgpt-latest.min.js')
        xhr.onload = function() {
            if (xhr.status === 200) {
                var chatgptJS = document.createElement('script')
                chatgptJS.textContent = xhr.responseText
                document.head.appendChild(chatgptJS)
                yourCode() // 運(yùn)行你的代碼
            }
        }
        xhr.send()
        
        function yourCode() {
            // 這里是你的代碼
        }
        

        Greasemonkey:

        筆記 使用入門模板: kudoai/chatgpt.js-greasemonkey-starter

        諸如 Greasy Fork 之類的用戶腳本存儲(chǔ)庫(kù)維護(hù)著預(yù)先批準(zhǔn)的 CDN 的白名單(例如來(lái)自 cdn.jsdelivr.net 的特定于提交的引用),因此導(dǎo)入 URL 相當(dāng)長(zhǎng)以保持對(duì)這些站點(diǎn)的可發(fā)布性:

        ...
        // @require https://cdn.jsdelivr.net/gh/kudoai/chatgpt.js@24a755998291094d0cd3b2bd395dff7c6756bbf9/dist/chatgpt-1.12.0.min.js
        // ==/UserScript==
        
        // 這里是你的代碼
        

        如果你不打算發(fā)布到這些存儲(chǔ)庫(kù),則可以使用更簡(jiǎn)單的 https://code.chatgptjs.org/chatgpt-latest.min.js 來(lái)導(dǎo)入最新的縮小版本。

        Chrome:

        筆記 使用入門模板: kudoai/chatgpt.js-chrome-starter

        由于 Google 最終將逐步淘汰 Manifest V2,遠(yuǎn)程代碼將不再被允許,因此在本地導(dǎo)入 chatgpt.js 是理想的:

        1.  https://raw.githubusercontent.com/kudoai/chatgpt.js/main/chatgpt.js 保存到子目錄 (本例中為 lib)

        2. 將 ES6 導(dǎo)出語(yǔ)句添加到 lib/chatgpt.js 的末尾

        ...
        export { chatgpt }
        
        1. 在項(xiàng)目的 (V3) manifest.json 中,添加 lib/chatgpt.js 作為 Web 可訪問資源
            "web_accessible_resources": [{
                "matches": ["<all_urls>"],
                "resources": ["lib/chatgpt.js"]
            }],
        
        1. 在需要 chatgpt.js (前景/背景相似) 的腳本中, 像這樣導(dǎo)入它:
        (async () => {
            const { chatgpt } = await import(chrome.runtime.getURL('lib/chatgpt.js'));
            // 這里是你的代碼
        })();

        用法

        chatgpt.js 的編寫考慮到了超級(jí)靈活性。

        例如:

        chatgpt.getLastResponse()
        chatgpt.getLastReply()
        chatgpt.response.getLast()
        chatgpt.get('reply', 'last')
        每個(gè)調(diào)用都會(huì)同樣獲取最后一個(gè)回應(yīng)。如果您認(rèn)為它有效,那么它可能就是有效的……所以只需輸入它!(誰(shuí)有時(shí)間看文檔?)

        如果它不起作用,只需提交 issue  PR,它將被集成,簡(jiǎn)單易行!

        瀏覽 22
        點(diǎn)贊
        評(píng)論
        收藏
        分享

        手機(jī)掃一掃分享

        編輯 分享
        舉報(bào)
        評(píng)論
        圖片
        表情
        推薦
        點(diǎn)贊
        評(píng)論
        收藏
        分享

        手機(jī)掃一掃分享

        編輯 分享
        舉報(bào)
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            无遮挡打光屁屁打屁股网站 | 看黄网站大全 | 成人精品h | 91在线红桃视频 | 日韩午夜精品无码 | 自拍 欧美 日韩 | 俺来俺去 | 在线看一区二区三区 | 国产黄片一区二区三区 | 国产成人无码免费视频在线看芈萝 |