Zee Hub

AI สร้างสคริปต์ พร้อมใช้งาน
Zee Hub สร้างโค้ดให้ใช้งานได้จริง กดคัดลอกแล้วนำไปรันได้ทันที

}

function addMsg(role, html){ var d = document.createElement("div"); d.className = "msg " + (role==="user"?"user":"bot"); d.innerHTML = (role==="user"?"":'

Z
') + '
'+html+'
'; chat.appendChild(d); chat.scrollTop = chat.scrollHeight; return d.querySelector(".bub"); }

function hero(){ chat.innerHTML = ""; var h = document.createElement("div"); h.className = "hero"; h.innerHTML = '

สวัสดี ฉันคือ Zee Hub

บอกฉันว่าอยากได้สคริปต์อะไร แล้วฉันจะเขียนโค้ดที่ใช้งานได้จริงให้ พร้อมปุ่มคัดลอก

'; SUGG.forEach(function(s){ var b = document.createElement("button"); b.className = "chip"; b.textContent = s; b.onclick = function(){ inp.value = s; go(); }; h.querySelector(".chips").appendChild(b); }); chat.appendChild(h); }

async function go(){ var q = inp.value.trim(); if(!q || busy) return; if(!sample){ try{ sample = await claude.use("sample"); }catch(e){} } var h = chat.querySelector(".hero"); if(h) chat.innerHTML = ""; inp.value = ""; inp.style.height = "auto"; addMsg("user", esc(q).replace(/\n/g,"
")); if(!sample){ addMsg("bot", 'ตอนนี้ยังเชื่อมต่อ AI ไม่ได้ กรุณาเปิดหน้านี้ผ่านลิงก์ที่แชร์ในแอป Claude แล้วลองใหม่'); return; } history.push({role:"user", content:q}); busy = true; sendBtn.disabled = true; var bub = addMsg("bot", '

'); var msgs = history.slice(-12).map(function(m,i,a){ return i===0 ? {role:m.role, content: (m.role==="user" ? SYS+"\n\n—\n\n" : "")+m.content} : m; }); if(msgs[0].role!=="user") msgs.shift(); try{ var res = await sample(msgs, {cache:false, modelTier:"complex", onText:function(o){ bub.innerHTML = render(o.text); chat.scrollTop = chat.scrollHeight; }}); bub.innerHTML = render(res.text, true); history.push({role:"assistant", content:res.text}); }catch(e){ var m = e && e.code==="rate_limited" ? "ใช้งานถี่เกินไป รอสักครู่แล้วลองใหม่" : e && e.code==="not_granted" ? "ต้องอนุญาตให้ใช้ AI ก่อนจึงจะสร้างสคริปต์ได้" : "เกิดข้อผิดพลาด ลองใหม่อีกครั้ง"; var partial = e && e.text ? render(e.text) : ""; bub.innerHTML = partial + '

'+m+'

'; history.pop(); } busy = false; sendBtn.disabled = false; inp.focus(); chat.scrollTop = chat.scrollHeight; }

chat.addEventListener("click", async function(ev){ var b = ev.target.closest("button[data-act]"); if(!b) return; var code = codeStore[+b.dataset.id]; if(b.dataset.act==="copy"){ var ok = false; try{ await navigator.clipboard.writeText(code); ok = true; }catch(e){ try{ var t = document.createElement("textarea"); t.value = code; document.body.appendChild(t); t.select(); ok = document.execCommand("copy"); t.remove(); }catch(e2){} } b.textContent = ok ? "คัดลอกแล้ว ✓" : "คัดลอกไม่ได้"; b.classList.toggle("ok", ok); setTimeout(function(){ b.textContent = "คัดลอก"; b.classList.remove("ok"); }, 1800); } else if(b.dataset.act==="save" && downloads){ try{ await downloads.save({filename:"zee-hub-script."+(EXT[b.dataset.lang]||"txt"), data:code}); }catch(e){} } });

sendBtn.onclick = go; inp.addEventListener("keydown", function(e){ if(e.key==="Enter" && !e.shiftKey && !e.isComposing){ e.preventDefault(); go(); }}); inp.addEventListener("input", function(){ inp.style.height = "auto"; inp.style.height = Math.min(inp.scrollHeight,140)+"px"; }); document.getElementById("clear").onclick = function(){ if(busy) return; history = []; codeStore = []; hero(); };

hero(); try{ claude.use("downloads").then(function(d){ downloads = d; }).catch(function(){}); }catch(e){} try{ claude.use("sample").then(function(s){ sample = s; }).catch(function(){}); }catch(e){} })();

Built with LogoFlowershow