export function logTo(target, title, payload) { const el = typeof target === "string" ? document.querySelector(target) : target; if (!el) return; const stamp = new Date().toLocaleTimeString("zh-CN", { hour12: false }); const entry = { time: stamp, event: title, ...payload, }; el.textContent = `${JSON.stringify(entry, null, 2)}\n\n${el.textContent}`.trim(); } export function setText(selector, value) { const el = document.querySelector(selector); if (el) el.textContent = value; } export function escapeHtml(value) { return String(value) .replaceAll("&", "&") .replaceAll("<", "<") .replaceAll(">", ">") .replaceAll('"', """); }