OurWorldOfText Gradient Menu

a gradient tool for ourworldoftext!

สคริปต์นี้ไม่ควรถูกติดตั้งโดยตรง มันเป็นคลังสำหรับสคริปต์อื่น ๆ เพื่อบรรจุด้วยคำสั่งเมทา // @require https://update.greasyfork.org/scripts/585839/1868978/OurWorldOfText%20Gradient%20Menu.js

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         OurWorldOfText Gradient Menu
// @namespace    http://tm.net
// @version      2.0
// @match        *ourworldoftext.com/*
// @grant        none
// ==/UserScript==

(function() { 'use strict'; var sgM = false, tCl = [], bCl = [], uTx = true, uBg = true, idxT = 0, idxB = 0, fwdT = true, fwdB = true, tMode = "Normal", bMode = "Normal", bgDisabled = true, tBlendType = "Reverse", bBlendType = "Reverse", isPinned = false;
    function mixMulti(arr, steps) { let res = []; if (!arr.length) return res; if (arr.length === 1) { let c = parseInt(arr.slice(1,7),16); for(let i=0;i<steps;i++) res.push(c); return res; } let segs = arr.length - 1, stepSeg = steps / segs; for (let i = 0; i < steps; i++) { let idx = Math.min(Math.floor(i / stepSeg), segs - 1), f = (i - (idx * stepSeg)) / stepSeg, s = arr[idx], e = arr[idx+1], r1 = parseInt(s.slice(1,3),16), g1 = parseInt(s.slice(3,5),16), b1 = parseInt(s.slice(5,7),16), r2 = parseInt(e.slice(1,3),16), g2 = parseInt(e.slice(3,5),16), b2 = parseInt(e.slice(5,7),16); res.push((Math.round(r1+f*(r2-r1))<<16) + (Math.round(g1+f*(g2-g1))<<8) + Math.round(b1+f*(b2-b1))); } return res; }
    function makeCircleMulti(arr, steps) { let res = [], mid = Math.floor(steps / 2), colors = mixMulti(arr, mid + 1); for(let i=0; i<steps; i++) res.push(i <= mid ? colors[i] : colors[steps - 1 - i]); return res; }
    function makePatternArrMulti(arr, steps, block) { let res = []; if (!arr.length) return res; let decs = arr.map(c => (parseInt(c.slice(1,3),16)<<16) + (parseInt(c.slice(3,5),16)<<8) + parseInt(c.slice(5,7),16)), idx = 0, cnt = 0; for(let i=0; i<steps; i++) { res.push(decs[idx]); cnt++; if(cnt >= block){ cnt = 0; idx = (idx + 1) % decs.length; } } return res; }
    function rd(h) { let r = []; for(let i=0; i<h; i++) r.push(Math.floor(Math.random()*16777216)); return r; }
    function nn(v) { return !v || v.trim().toLowerCase() === "none"; }
    function makeRandomPairsBlend(colors, totalSteps, stepSize) { let res = []; if(colors.length < 2) { let fallback = mixMulti(colors, totalSteps); while(fallback.length < totalSteps) fallback.push(fallback||0); return fallback.slice(0, totalSteps); } while(res.length < totalSteps) { let c1 = colors[Math.floor(Math.random() * colors.length)], c2 = colors[Math.floor(Math.random() * colors.length)]; res = res.concat(mixMulti([c1, c2], stepSize)); } return res.slice(0, totalSteps); }
    var _writeChar = writeChar; writeChar = function(t, f) { if (sgM) { if (tMode === "Random" && window.YourWorld && YourWorld.Color !== undefined) YourWorld.Color = Math.floor(Math.random()*16777216); else if (uTx && tCl.length > 0 && window.YourWorld && YourWorld.Color !== undefined) YourWorld.Color = tCl[idxT]; if (bgDisabled) { if(window.YourWorld && YourWorld.BgColor !== undefined) YourWorld.BgColor = -1; if(typeof charBgColor !== 'undefined') charBgColor = -1; if(typeof currentBgColor !== 'undefined') currentBgColor = -1; } else if (bMode === "Random") { let rB = Math.floor(Math.random()*16777216); if(window.YourWorld && YourWorld.BgColor !== undefined) YourWorld.BgColor = rB; if(typeof charBgColor !== 'undefined') charBgColor = rB; } else if (uBg && bCl.length > 0) { let tB = bCl[idxB]; if(window.YourWorld && YourWorld.BgColor !== undefined) YourWorld.BgColor = tB; if(typeof charBgColor !== 'undefined') charBgColor = tB; if(typeof currentBgColor !== 'undefined') currentBgColor = tB; } if (tMode === "Pattern" || tMode === "Circle") { idxT++; if(idxT >= tCl.length) idxT = 0; } else if (tMode !== "Random" && tCl.length > 1) { if(tBlendType === "Cut") { idxT++; if(idxT >= tCl.length) idxT = 0; } else { if(fwdT){ idxT++; if(idxT >= tCl.length){ fwdT = false; idxT = Math.max(0,tCl.length-2); } } else { idxT--; if(idxT < 0){ fwdT = true; idxT = Math.min(tCl.length-1,1); } } } } if (bMode === "Pattern") { idxB++; if(idxB >= bCl.length) idxB = 0; } else if (bMode !== "Random" && bCl.length > 1) { if(bBlendType === "Cut") { idxB++; if(idxB >= bCl.length) idxB = 0; } else { if(fwdB){ idxB++; if(idxB >= bCl.length){ fwdB = false; idxB = Math.max(0,bCl.length-2); } } else { idxB--; if(idxB < 0){ fwdB = true; idxB = Math.min(bCl.length-1,1); } } } } } _writeChar(t, f); };
    function setSt(v,t,b,tm,bm,bgD,trB,brB) { sgM = v; tCl = t; bCl = b; tMode = tm; bMode = bm; bgDisabled = bgD; tBlendType = trB; bBlendType = brB; uTx = tm === "Random" || t.length > 0; uBg = !bgD && (bm === "Random" || b.length > 0); idxT = 0; idxB = 0; fwdT = true; fwdB = true; }
    function addScrollStyle() { let s = document.createElement('style'); s.innerText = "#ow-gui::-webkit-scrollbar { width: 10px; } #ow-gui::-webkit-scrollbar-track { background: #1a1a24; border-radius: 10px; } #ow-gui::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #b28aff 0%, #00a2ff 100%); border-radius: 10px; } .ow-gradient-heading { font-weight: 900 !important; margin-bottom: 8px; font-size: 14px; background: linear-gradient(90deg, #fdafff 0%, #ffd57a 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; display: inline-block; }"; document.head.appendChild(s); }
    function pop() { let o = document.getElementById('ow-gui'); if (o) o.remove(); addScrollStyle(); isPinned = false; let m = document.createElement('div'); m.id = 'ow-gui'; m.style = "position:fixed; top:50%; left:50%; transform:translate(-50%,-50%); z-index:100000; background-color:rgba(0,0,0,0.55); border:4px solid #444; font-family:sans-serif; width:365px; box-shadow: 5px 5px 15px rgba(0,0,0,0.5); max-height:85vh; overflow-y:auto; color:#ffffff; border-radius:8px; resize:both; min-width:300px; min-height:200px;";
        let tabs = document.createElement('div'); tabs.style = "display:flex; background-color:#222; padding:5px 5px 0 5px; border-top-left-radius:4px; border-top-right-radius:4px; align-items:center; position:relative; user-select:none;"; let liveTab = document.createElement('div'); liveTab.innerText = '✨ Live Type'; liveTab.style = "padding:5px 12px; cursor:pointer; font-weight:bold; background-color:rgba(0,0,0,0.55); color:#fff; margin-right:2px; border-top-left-radius:4px; border-top-right-radius:4px;"; let pasteTab = document.createElement('div'); pasteTab.innerText = '📋 Auto Paste'; pasteTab.style = "padding:5px 12px; cursor:pointer; font-weight:bold; background-color:#444; color:#aaa; border-top-left-radius:4px; border-top-right-radius:4px;"; let dragZone = document.createElement('div'); dragZone.style = "flex:1; height:32px; cursor:move;"; tabs.appendChild(liveTab); tabs.appendChild(pasteTab); tabs.appendChild(dragZone);
        let headerActions = document.createElement('div'); headerActions.style = "position:absolute; right:8px; top:50%; transform:translateY(-50%); display:flex; align-items:center; gap:8px;"; let pinBtn = document.createElement('span'); pinBtn.innerText = '📌'; pinBtn.style = "cursor:pointer; opacity:0.5; font-size:14px; user-select:none; transition:opacity 0.2s;"; pinBtn.onclick = function(e) { e.stopPropagation(); isPinned = !isPinned; pinBtn.style.opacity = isPinned ? "1" : "0.5"; pinBtn.style.textShadow = isPinned ? "0 0 4px #8a8aff" : "none"; }; let closeBtn = document.createElement('span'); closeBtn.innerText = '❌'; closeBtn.style = "cursor:pointer; font-size:12px; user-select:none; padding:2px;"; closeBtn.onclick = function(e) { e.stopPropagation(); cleanup(); }; headerActions.appendChild(pinBtn); headerActions.appendChild(closeBtn); tabs.appendChild(headerActions); m.appendChild(tabs);
        let bd = document.createElement('div'); bd.style.padding = '15px 20px'; m.appendChild(bd); let tl = document.createElement('div'); tl.innerText = 'Configure Parameters:'; tl.style = "font-weight:bold; margin-bottom:15px; font-size:16px; color:#fff;"; bd.appendChild(tl);
        function createBaseRow(l, d, i) { let row = document.createElement('div'); row.style = "margin-bottom:10px; display:flex; align-items:center;"; let lbl = document.createElement('label'); lbl.innerText = l; lbl.style = "width:125px; font-weight:bold; color:#fff;"; let inp = document.createElement('input'); inp.id = i; inp.value = d; inp.style = "flex:1; background:#222; color:#fff; border:1px solid #555; padding:3px; border-radius:4px; min-width:30px;"; row.appendChild(lbl); row.appendChild(inp); return row; }
        let savedM = localStorage.getItem('ow_grad_m') || '15', savedBM = localStorage.getItem('ow_grad_bm_steps') || '15', savedPaste = localStorage.getItem('ow_grad_paste') || 'WELCOME TO MY WORLD', savedTMode = localStorage.getItem('ow_grad_t_mode') || 'Normal', savedCMode = localStorage.getItem('ow_grad_c_mode') || 'Normal', savedBgKill = localStorage.getItem('ow_grad_bg_kill') !== 'false', savedTBlend = localStorage.getItem('ow_grad_t_blend') || 'Reverse', savedCBlend = localStorage.getItem('ow_grad_c_blend') || 'Reverse', savedTPreset = localStorage.getItem('ow_grad_t_preset') || 'Select', savedCPreset = localStorage.getItem('ow_grad_c_preset') || 'Select';
        let stepsRow = createBaseRow('Text Width Steps:', savedM, 'g-m'); let bgStepsRow = createBaseRow('Cell Width Steps:', savedBM, 'g-bm-steps'); let pasteRow = createBaseRow('Paste Text:', savedPaste, 'g-paste-text'); pasteRow.style.display = 'none'; bd.appendChild(stepsRow); bd.appendChild(bgStepsRow); bd.appendChild(pasteRow);
        let rawTSteps = localStorage.getItem('ow_grad_t_pat_len'), rawCSteps = localStorage.getItem('ow_grad_c_pat_len');
        let tPatRow = createBaseRow('Text Pattern Steps:', (rawTSteps !== null ? rawTSteps : savedM), 'g-t-pat-len'); tPatRow.style.display = 'none'; bd.appendChild(tPatRow);
        let cPatRow = createBaseRow('Cell Pattern Steps:', (rawCSteps !== null ? rawCSteps : savedBM), 'g-c-pat-len'); cPatRow.style.display = 'none'; bd.appendChild(cPatRow);
function createColorRow(labelText, defaultColor, container, classTag) { let row = document.createElement('div'); row.className = classTag; row.style = "margin-bottom:8px; display:flex; align-items:center;"; let lbl = document.createElement('label'); lbl.innerText = labelText; lbl.style = "width:70px; font-weight:bold; color:#fff;"; lbl.className = 'color-row-label'; let txtInp = document.createElement('input'); txtInp.type = 'text'; txtInp.value = defaultColor; txtInp.style = "width:75px; background:#222; color:#fff; border:1px solid #555; padding:3px; margin-right:6px; font-family:monospace; border-radius:4px; text-transform:lowercase; min-width:50px;"; let inp = document.createElement('input'); inp.type = 'color'; inp.value = defaultColor; inp.style = "flex:1; height:24px; cursor:pointer; background:none; border:none; min-width:20px;"; txtInp.oninput = function() { if(/^#[0-9a-fA-F]{6}$/.test(txtInp.value)) inp.value = txtInp.value; }; inp.oninput = function() { txtInp.value = inp.value; }; let randBtn = document.createElement('button'); randBtn.innerText = '?'; randBtn.style = "margin-left:5px; cursor:pointer; font-weight:bold; padding:2px 6px; background:#444; color:#fff; border:1px solid #666; border-radius:4px;"; randBtn.onclick = function() { let hex = '#' + Math.floor(Math.random() * 16777215).toString(16).padStart(6, '0'); inp.value = hex; txtInp.value = hex; }; row.appendChild(lbl); row.appendChild(txtInp); row.appendChild(inp); row.appendChild(randBtn); if (container.children.length >= 1) { let remBtn = document.createElement('button'); remBtn.innerText = 'X'; remBtn.style = "margin-left:5px; cursor:pointer; color:#ff4d4d; font-weight:bold; padding:2px 6px; background:#331a1a; border:1px solid #ff4d4d; border-radius:3px;"; remBtn.onclick = function() { row.remove(); renameLabels(container); }; row.appendChild(remBtn); } container.appendChild(row); }function renameLabels(container) { let items = container.getElementsByClassName('color-row-label'); for(let i=0; i<items.length; i++) items[i].innerText = 'Color ' + (i+1) + ':'; }function makeSelectRow(lblTxt, id, modeList, defaultVal) { let row = document.createElement('div'); row.style = "margin-bottom:10px; display:flex; align-items:center;"; let lbl = document.createElement('label'); lbl.innerText = lblTxt; lbl.style = "width:125px; font-weight:bold; color:#fff;"; let sel = document.createElement('select'); sel.id = id; sel.style = "flex:1; padding:3px; background:#222; color:#fff; border:1px solid #555; border-radius:4px; min-width:50px;"; modeList.forEach(function(mName){ let e = document.createElement('option'); e.value = mName; e.innerText = mName; if(mName === defaultVal) e.selected = true; sel.appendChild(e); }); row.appendChild(lbl); row.appendChild(sel); return { r: row, b: sel }; }var applyPresetMacro = function(presetValue, container, classTag) { if (presetValue === 'Select') return; container.innerHTML = ''; let colorList = []; if (presetValue === 'Rainbow') { colorList = ['#ff0000', '#ff7f00', '#ffff00', '#00ff00', '#0000ff', '#4b0082', '#9400d3']; } else if (presetValue === 'Monochrome') { colorList = ['#ffffff', '#e0e0e0', '#9e9e9e', '#424242', '#000000']; } else if (presetValue === 'Sunset') { colorList = ['#fdafff', '#febcd3', '#fec2bd', '#fecb9b', '#ffd57a']; } else if (presetValue === 'RGB') { colorList = ['#ff0000', '#0000ff', '#00ff33']; } colorList.forEach((col, idx) => createColorRow('Color '+(idx+1)+':', col, container, classTag)); };function handleClearDefault(container) { container.innerHTML = ''; }let secT = document.createElement('div'); secT.style = "border-bottom:1px solid #444; margin-bottom:12px; padding-bottom:8px;"; let lblT = document.createElement('div'); lblT.innerText = 'Text Settings:'; lblT.className = "ow-gradient-heading"; secT.appendChild(lblT); let tColorsBox = document.createElement('div'); secT.appendChild(tColorsBox); let savedTColors = JSON.parse(localStorage.getItem('ow_grad_t_colors') || '["#ffffff", "#ffffff"]'); if(savedTColors.length) savedTColors.forEach((col, idx) => createColorRow('Color '+(idx+1)+':', col, tColorsBox, 't-color-item'));var handleInvertAction = function(container, classTag) { let rows = container.getElementsByClassName(classTag), colorVals = []; for (let i = 0; i < rows.length; i++) { let colInp = rows[i].querySelector('input[type="color"]'); if (colInp) colorVals.push(colInp.value); } colorVals.reverse(); container.innerHTML = ''; colorVals.forEach((val, idx) => createColorRow('Color ' + (idx + 1) + ':', val, container, classTag)); };let revBtnT = document.createElement('button'); revBtnT.innerText = '🔄 Reverse Order'; revBtnT.style = "margin-bottom:6px; cursor:pointer; font-weight:bold; padding:4px 10px; display:block; width:100%; border-radius:4px; border:1px solid #555; background:#333; color:#fff;"; revBtnT.onclick = function() { handleInvertAction(tColorsBox, 't-color-item'); }; secT.appendChild(revBtnT); let addBtnT = document.createElement('button'); addBtnT.innerText = '+ Add Color'; addBtnT.style = "margin-bottom:6px; cursor:pointer; font-weight:bold; padding:4px 10px; display:block; width:100%; border-radius:4px; border:1px dashed #555; background:#222; color:#ccc;"; addBtnT.onclick = function() { createColorRow('Color X:', '#ffffff', tColorsBox, 't-color-item'); renameLabels(tColorsBox); }; secT.appendChild(addBtnT);let defBtnT = document.createElement('button'); defBtnT.innerText = 'Reset To Default'; defBtnT.style = "margin-bottom:10px; cursor:pointer; font-weight:bold; padding:4px 10px; display:block; width:100%; border-radius:4px; border:2px solid #ff4d4d; background:#2a1111; color:#ff4d4d;"; defBtnT.onclick = function() { handleClearDefault(tColorsBox); }; secT.appendChild(defBtnT);let tPresetSel = makeSelectRow('Gradient Preset:', 'g-t-preset', ['Select', 'Rainbow', 'Monochrome', 'Sunset', 'RGB'], savedTPreset); secT.appendChild(tPresetSel.r); let tSel = makeSelectRow('Gradient Type:', 'g-t-mode', ['Normal', 'Pattern', 'Circle', 'Random'], savedTMode); secT.appendChild(tSel.r);let tBlendSel = makeSelectRow('Blend Type:', 'g-t-blend', ['Smooth', 'Reverse', 'Cut', 'Random'], savedTBlend); secT.appendChild(tBlendSel.r); bd.appendChild(secT);let secC = document.createElement('div'); let lblC = document.createElement('div'); lblC.innerText = 'Cell Background Settings:'; lblC.className = "ow-gradient-heading"; secC.appendChild(lblC); let cColorsBox = document.createElement('div'); secC.appendChild(cColorsBox); let savedCColors = JSON.parse(localStorage.getItem('ow_grad_c_colors') || '["#ffffff", "#ffffff"]'); if(savedCColors.length) savedCColors.forEach((col, idx) => createColorRow('Color '+(idx+1)+':', col, cColorsBox, 'c-color-item'));let revBtnC = document.createElement('button'); revBtnC.innerText = '🔄 Reverse Order'; revBtnC.style = "margin-bottom:6px; cursor:pointer; font-weight:bold; padding:4px 10px; display:block; width:100%; border-radius:4px; border:1px solid #555; background:#333; color:#fff;"; revBtnC.onclick = function() { handleInvertAction(cColorsBox, 'c-color-item'); }; secC.appendChild(revBtnC); let addBtnC = document.createElement('button'); addBtnC.innerText = '+ Add Color'; addBtnC.style = "margin-bottom:6px; cursor:pointer; font-weight:bold; padding:4px 10px; display:block; width:100%; border-radius:4px; border:1px dashed #555; background:#222; color:#ccc;"; addBtnC.onclick = function() { createColorRow('Color X:', '#ffffff', cColorsBox, 'c-color-item'); renameLabels(cColorsBox); }; secC.appendChild(addBtnC);let defBtnC = document.createElement('button'); defBtnC.innerText = 'Reset To Default'; defBtnC.style = "margin-bottom:10px; cursor:pointer; font-weight:bold; padding:4px 10px; display:block; width:100%; border-radius:4px; border:2px solid #ff4d4d; background:#2a1111; color:#ff4d4d;"; defBtnC.onclick = function() { handleClearDefault(cColorsBox); }; secC.appendChild(defBtnC);let cPresetSel = makeSelectRow('Gradient Preset:', 'g-c-preset', ['Select', 'Rainbow', 'Monochrome', 'Sunset', 'RGB'], savedCPreset); secC.appendChild(cPresetSel.r); let cSel = makeSelectRow('Gradient Type:', 'g-c-mode', ['Normal', 'Pattern', 'Random'], savedCMode); secC.appendChild(cSel.r);let cBlendSel = makeSelectRow('Blend Type:', 'g-c-blend', ['Smooth', 'Reverse', 'Cut', 'Random'], savedCBlend); secC.appendChild(cBlendSel.r);let killRow = document.createElement('div'); killRow.style.removeAttribute = true; killRow.style.marginBottom = '8px'; let killBox = document.createElement('input'); killBox.type = 'checkbox'; killBox.id = 'g-bg-kill'; killBox.checked = savedBgKill; let killLbl = document.createElement('label'); killLbl.innerText = ' ❌ Disable Background'; killLbl.style.fontWeight = 'bold'; killLbl.style.color = '#fff'; killRow.appendChild(killBox); killRow.appendChild(killLbl); secC.appendChild(killRow); bd.appendChild(secC);var isPasteModeTab = false; function syncVis() { stepsRow.style.display = isPasteModeTab ? 'none' : 'flex'; bgStepsRow.style.display = isPasteModeTab ? 'none' : 'flex'; }tPresetSel.b.onchange = function() { applyPresetMacro(tPresetSel.b.value, tColorsBox, 't-color-item'); }; cPresetSel.b.onchange = function() { applyPresetMacro(cPresetSel.b.value, cColorsBox, 'c-color-item'); };liveTab.onclick = function() { isPasteModeTab = false; liveTab.style.backgroundColor = 'rgba(0,0,0,0.55)'; liveTab.style.color = '#fff'; pasteTab.style.backgroundColor = '#444'; pasteTab.style.color = '#aaa'; pasteRow.style.display = 'none'; syncVis(); }; pasteTab.onclick = function() { isPasteModeTab = true; pasteTab.style.backgroundColor = 'rgba(0,0,0,0.55)'; pasteTab.style.color = '#fff'; liveTab.style.backgroundColor = '#444'; liveTab.style.color = '#aaa'; pasteRow.style.display = 'flex'; syncVis(); }; syncVis();let ac = document.createElement('div'); ac.style = "margin-top:15px; display:flex; align-items:center; font-weight:bold;"; let go = document.createElement('button'); go.innerText = 'Execute'; go.style = "padding:6px 22px; margin-right:12px; cursor:pointer; background:#a7f199; color:#000; font-weight:bold; border:none; border-radius:4px;"; let cc = document.createElement('a'); cc.innerText = 'cancel'; cc.href = '#'; cc.style = "color:#ff4d4d; text-decoration:underline; margin-left:6px;"; ac.appendChild(go); ac.appendChild(document.createTextNode(' or ')); ac.appendChild(cc); bd.appendChild(ac); document.body.appendChild(m);let oX = 0, oY = 0; dragZone.onmousedown = function(e) { e.preventDefault(); let box = m.getBoundingClientRect(); oX = e.clientX - box.left; oY = e.clientY - box.top; m.style.transform = "none"; m.style.top = box.top + "px"; m.style.left = box.left + "px"; document.onmouseup = function() { document.onmouseup = null; document.onmousemove = null; }; document.onmousemove = function(e) { e.preventDefault(); m.style.left = (e.clientX - oX) + "px"; m.style.top = (e.clientY - oY) + "px"; }; };cc.onclick = function(e) { e.preventDefault(); cleanup(); }; function cleanup() { document.removeEventListener('mousedown', outClick); m.remove(); } function outClick(e) { if (!isPinned && !m.contains(e.target) && !e.target.closest('#menu') && !e.target.closest('.menu')) cleanup(); } setTimeout(function() { document.addEventListener('mousedown', outClick); }, 50);go.onclick = function() { let stepsVal = document.getElementById('g-m').value, bgStepsVal = document.getElementById('g-bm-steps').value, pasteVal = document.getElementById('g-paste-text').value, tm = tSel.b.value, bm = cSel.b.value, killBg = killBox.checked, trB = tBlendType = tBlendSel.b.value, brB = bBlendType = cBlendSel.b.value, tPr = tPresetSel.b.value, cPr = cPresetSel.b.value; let stepsNum = parseInt(stepsVal); if (isNaN(stepsNum) || stepsNum <= 0) stepsNum = 15; let bgStepsNum = parseInt(bgStepsVal); if (isNaN(bgStepsNum) || bgStepsNum <= 0) bgStepsNum = 15; let tPatWidth = stepsNum, cPatWidth = bgStepsNum; let tInps = tColorsBox.getElementsByTagName('input'), tColors = []; for(let i=0; i<tInps.length; i++) { if(tInps[i].type === 'color') tColors.push(tInps[i].value); } let cInps = cColorsBox.getElementsByTagName('input'), cColors = []; for(let i=0; i<cInps.length; i++) { if(cInps[i].type === 'color') cColors.push(cInps[i].value); } localStorage.setItem('ow_grad_m', stepsVal); localStorage.setItem('ow_grad_bm_steps', bgStepsVal); localStorage.setItem('ow_grad_paste', pasteVal); localStorage.setItem('ow_grad_t_pat_len', tPatWidth); localStorage.setItem('ow_grad_c_pat_len', cPatWidth); localStorage.setItem('ow_grad_t_mode', tm); localStorage.setItem('ow_grad_c_mode', bm); localStorage.setItem('ow_grad_bg_kill', killBg); localStorage.setItem('ow_grad_t_blend', trB); localStorage.setItem('ow_grad_c_blend', brB); localStorage.setItem('ow_grad_t_colors', JSON.stringify(tColors)); localStorage.setItem('ow_grad_c_colors', JSON.stringify(cColors)); let uT = tm === "Random" || tm === "Pattern" || tm === "Circle" || tColors.length > 0, uB = !killBg && (bm === "Random" || bm === "Pattern" || cColors.length > 0); if (isPasteModeTab) { let tx = pasteVal; if (!tx || (!uT && !uB && !killBg)) { cleanup(); return; } let pt = []; if(tm === "Random") pt = rd(tx.length); else if(tm === "Pattern") pt = makePatternArrMulti(tColors, tx.length, tPatWidth); else if(tm === "Circle") pt = makeCircleMulti(tColors, tx.length); else if(uT) { if(trB === "Random") { pt = makeRandomPairsBlend(tColors, tx.length, stepsNum); } else if(trB === "Smooth" && tColors.length > 1) { let smoothColors = [].concat(tColors, [tColors[0]]); let raw = mixMulti(smoothColors, stepsNum), loop = []; while(loop.length < tx.length) loop = loop.concat(raw); pt = loop.slice(0, tx.length); } else if(trB === "Reverse") { let raw = mixMulti(tColors, stepsNum), loop = []; while(loop.length < tx.length) { loop = loop.concat(raw); loop = loop.concat([...raw].reverse()); } pt = loop.slice(0, tx.length); } else { let raw = mixMulti(tColors, stepsNum), loop = []; while(loop.length < tx.length) loop = loop.concat(raw); pt = loop.slice(0, tx.length); } }let pb = []; if(killBg) pb = []; else if(bm === "Random") pb = rd(tx.length); else if(bm === "Pattern") pb = makePatternArrMulti(cColors, tx.length, cPatWidth); else if(uB) { if(brB === "Random") { pb = makeRandomPairsBlend(cColors, tx.length, bgStepsNum); } else if(brB === "Smooth" && cColors.length > 1) { let smoothColors = [].concat(cColors, [cColors[0]]); let raw = mixMulti(smoothColors, bgStepsNum), loop = []; while(loop.length < tx.length) loop = loop.concat(raw); pb = loop.slice(0, tx.length); } else if(brB === "Reverse") { let raw = mixMulti(cColors, bgStepsNum), loop = []; while(loop.length < tx.length) { loop = loop.concat(raw); loop = loop.concat([...raw].reverse()); } pb = loop.slice(0, tx.length); } else { let raw = mixMulti(cColors, bgStepsNum), loop = []; while(loop.length < tx.length) loop = loop.concat(raw); pb = loop.slice(0, tx.length); } }let wE = typeof _writeChar !== 'undefined' ? _writeChar : writeChar, i = 0; function tw() { if (i >= tx.length) return; if (uT && window.YourWorld && YourWorld.Color !== undefined) YourWorld.Color = pt[i]; if (killBg) { if (window.YourWorld && YourWorld.BgColor !== undefined) YourWorld.BgColor = -1; } else if (uB && window.YourWorld && YourWorld.BgColor !== undefined) { YourWorld.BgColor = pb[i]; if (typeof charBgColor !== 'undefined') charBgColor = pb[i]; } wE(tx[i], true); let ev = new KeyboardEvent('keydown', { key: 'ArrowRight', keyCode: 39, code: 'ArrowRight', bubbles: true }); document.dispatchEvent(ev); if (window.OWOT && OWOT.cursor && OWOT.cursor.moveRight) OWOT.cursor.moveRight(); i++; setTimeout(tw, 70); } tw(); } else { if (!uT && !uB && !killBg) { cleanup(); return; } let bLen = 100; let finalTColors = []; if(tm === "Normal" && trB === "Smooth" && tColors.length > 1) finalTColors = [].concat(tColors, [tColors[0]]); else finalTColors = tColors; let finalCColors = []; if(bm === "Normal" && brB === "Smooth" && cColors.length > 1) finalCColors = [].concat(cColors, [cColors[0]]); else finalCColors = cColors; let tC = [], bC = [];if (tm === "Pattern") tC = makePatternArrMulti(tColors, bLen, tPatWidth); else if (tm === "Normal" && trB === "Random") tC = makeRandomPairsBlend(tColors, bLen, stepsNum); else tC = tm === "Random" ? [] : (tm === "Circle" ? makeCircleMulti(tColors, stepsNum) : (uT ? mixMulti(finalTColors, stepsNum) : []));if (!killBg) { if (bm === "Pattern") bC = makePatternArrMulti(cColors, bLen, cPatWidth); else if (bm === "Normal" && brB === "Random") bC = makeRandomPairsBlend(cColors, bLen, bgStepsNum); else bC = bm === "Random" ? [] : (bm === "Circle" ? makeCircleMulti(cColors, bgStepsNum) : (uB ? mixMulti(finalCColors, bgStepsNum) : [])); }setSt(true, tC, bC, tm, bm, killBg, trB, brB); } if(!isPinned) cleanup(); }; }initMod(); function initMod() { if (window.menu && menu.addOption) { menu.addOption('✨ Gradient Menu', function() { pop(); }); console.log("Suite Activated!"); } else { setTimeout(initMod, 200); } }})();