ChatGPT output HTML direct

ChatGPT直接輸出HTML

08.03.2023 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         ChatGPT output HTML direct
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  ChatGPT直接輸出HTML
// @description:en  ChatGPT output HTML direct
// @author       cat-no-war
// @match        https://chat.openai.com/chat
// @icon         https://www.google.com/s2/favicons?sz=64&domain=openai.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    setInterval(function(){
        var codes= document.querySelectorAll("code:not([add_frame])")
        for(let i=0;i<codes.length;i++){
            let code=codes[i];
            //wait completed
            let pre=code.closest("pre");
            if(pre==null){
                 code.setAttribute("add_frame",true);
                continue;
            }
            let codeParentIndex = Array.prototype.indexOf.call(pre.parentElement.children, pre);
            let codeParentLength=pre.parentElement.children.length;
            if(codeParentIndex==codeParentLength-1)continue;
            code.setAttribute("add_frame",true);
            let newFrame=document.createElement("iframe");
            newFrame.style.width="100%";
            newFrame.style.height="512px";
            let lang=code.parentElement.parentElement.children[0].children[0].innerText
            if(lang=="html" || lang=="php"){
                newFrame.src = "data:text/html;charset=utf-8," +  encodeURIComponent(code.innerText);
                code.parentElement.parentElement.parentElement.appendChild(newFrame);
            }
        }
    }, 500);
})();