// ==UserScript== // @name WebUI 프롬프트 확장? // @namespace http://tampermonkey.net/ // @version 0.1 // @description 챗 GPT에서 탬플릿 매번 작성없이 쓰기? // @author DeTK // @match https://chat.openai.com/chat // @match https://chat.openai.com/chat/* // @icon https://www.google.com/s2/favicons?sz=64&domain=openai.com // @grant GM.setValue // @grant GM.getValue // @license MIT // @downloadURL none // ==/UserScript== (async function () { 'use strict'; while (true) { await sleep(500); if (!document.querySelector("#MakePrompt")) { await init(); } } return; async function init() { document.querySelector("#MakePrompt")?.remove(); const div = document.createElement("div"); div.id = "MakePrompt"; div.style.marginTop = "8px"; const modal = document.createElement("div"); modal.className = "dark hidden bg-gray-900 rounded-md px-2 pb-3 mb-3 overflow-auto h-80"; const ul = document.createElement("ul"); const getHeight = v => { const match = v.value.match(/\r?\n(?!\\)/g); const count = match ? match.length + 1 : 1; return `${24 * count}px`; }; const li1 = document.createElement("li"); li1.className = "text-xl ml-3 pb-3" li1.style = "padding-top: 8px;"; li1.textContent = "토픽"; ul.append(li1); const li2 = document.createElement("li"); li2.className = "flex flex-col w-full py-2 flex-grow md:py-3 md:pl-4 relative border border-black/10 bg-white dark:border-gray-900/50 dark:text-white dark:bg-gray-700 rounded-md shadow-[0_0_10px_rgba(0,0,0,0.10)] dark:shadow-[0_0_15px_rgba(0,0,0,0.10)]"; const textarea = document.createElement("textarea"); textarea.value = await GM.getValue("topic", ""); textarea.style = "overflow-y:hidden; height:24px;"; textarea.style.height = getHeight(textarea); textarea.className = `topic m-0 w-full resize-none border-0 bg-transparent p-0 pl-2 pr-7 focus:ring-0 focus-visible:ring-0 dark:bg-transparent md:pl-0`; for (const eventName of ["keydown", "keyup", "keypress"]) { textarea.addEventListener(eventName, async function (e) { if (8 == e.keyCode || 46 == e.keyCode || (13 == e.keyCode && e.shiftKey)) { this.style.height = getHeight(this); this.scrollTop = 0; } await GM.setValue("topic", this.value); }.bind(textarea)); } textarea.addEventListener("focus", async function (e) { this.parentElement.previousElementSibling.scrollIntoView({ block: "start", inline: "nearest", behavior: "smooth" }); }.bind(textarea)); li2.append(textarea); ul.append(li2); modal.append(ul); div.append(modal); const button1 = document.createElement("button"); button1.textContent = "WebUI 프롬프트 설정"; button1.style.display = "inlineblock"; button1.onclick = (e) => { e.preventDefault(); modal.classList.toggle("hidden"); } button1.className = "btn relative btn-neutral border-0 md:border"; div.append(button1); const button2 = document.createElement("button"); button2.textContent = "검색"; button2.style.display = "inlineblock"; button2.style.marginLeft = "8px"; button2.className = "btn relative btn-neutral border-0 md:border"; button2.onclick = (e) => { // e.preventDefault(); modal.classList.toggle("hidden", true); document.querySelector("form textarea").value = getPromptText(); } div.append(button2); document.querySelector("form > div").appendChild(div) // setTimeout(console.clear, 1000); } function getPromptText() { return `I'll explain the rules for prompt generation 1. Fill in the following format: {prompt}. 2. Use only short sentences or words. 3. Do not change the content of the fixed prompt 4. Use no parentheses other than the ones I used. 5. Please do not omit the category in {prompt}. 6. Answers should be in English 7. Return 4 results. 8. Use the rules below to create a, provide creative image prompts for the topic "${document.querySelector("#MakePrompt .topic").value}". Fixed Prompt - (masterpiece, best quality:1.3), 1girl, solo Style - background - Subject - View - Appearance - Outfit - Pose - Details - Effects - Description - Display the results as Prompt1, Prompt2, Prompt3, Prompt4, etc.`; } function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } // Your code here... })();