chatGPT-copy

copy chatGPT content

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         chatGPT-copy
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  copy chatGPT content
// @author       mclwh
// @match        https://www.tampermonkey.net/scripts.php?ext=dhdg&updated=true&version=4.18.1
// @match        https://chat.openai.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant        GM_log
// @license     ISC
// ==/UserScript==

function createIcon(mode="init"){
    const list = document.querySelectorAll(".markdown")
    const len = list.length
    const newlist = mode == "init"?list:[list[len-1]]
    Array.from(newlist).forEach(i=>{
        if(!i.parentElement.className.match("lichen-copy")){
            const el = document.createElement('div')
            el.innerText = "copy"
            el.style.cssText = `padding:5px 10px;
                    color:white;
                    background:pink;
                    position:absolute;
                    font-size:12px;
                    border-radius:5px;
                    top:-40px;
                    right:0px;
                    cursor: pointer;
                    `
            el.onclick = function(){
                const input = document.createElement("input")
                input.value = i.innerText
                document.body.appendChild(input)
                input.select()
                document.execCommand("copy")
                document.body.removeChild(input)
                el.style.background = "#aaa"
                setTimeout(()=>{
                    el.style.background = "pink"
                },1000)
            }
            i.parentElement.appendChild(el)
            i.parentElement.classList.add("lichen-copy")
            i.parentElement.style.position = "relative"
        }
    })
}


(function() {
    'use strict';

    // Your code here...
    setTimeout(()=>{
        createIcon()
        document.getElementsByTagName("textarea")[0].addEventListener("keydown",function(e){
            if(!e.shiftKey && e.code == "Enter"){
                setTimeout(()=>{

                    createIcon("create")
                },500)
            }
        })
        document.getElementsByTagName("textarea")[0].parentElement.getElementsByTagName("button")[0].addEventListener("click",function(){
            setTimeout(()=>{
                createIcon("create")
            },500)
        })
    },2000)

})();