(function premiumUi() { const ready = (fn) => { if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", fn, { once: true }); } else { fn(); } }; ready(() => { document.documentElement.classList.add("premium-ui"); syncActivePanelState(); ensureReferenceWorkspace(); ensureDashboardRail(); enhanceMetricCards(); bindReplicaBindings(); updateReplicaBindings(); updateDashboardRail(); addRevealStagger(); bindSpotlights(); bindPanelPulse(); observeDynamicCards(); window.setInterval(updateDashboardRail, 1800); window.setInterval(updateReplicaBindings, 1200); }); function addRevealStagger(root = document) { const groups = [ ".overviewCard", ".configRail", ".workspaceHeader", ".panel.active", ".card[data-panel]", ".statsGrid .stat", ".chartBlock", ".premiumConfigCard", ]; let index = 0; root.querySelectorAll(groups.join(",")).forEach((el) => { if (el.dataset.premiumReveal === "1") return; el.dataset.premiumReveal = "1"; el.style.setProperty("--stagger", String(Math.min(index, 12))); el.classList.add("premiumReveal"); index += 1; }); } function bindSpotlights(root = document) { const selector = [ ".header", ".overviewCard", ".card", ".panel", ".workspaceHeader", ".chartBlock", ".stat", ".reservationItem", ".btn", ".tabBtn", ".premiumConfigCard", ".premiumField", ].join(","); root.querySelectorAll(selector).forEach((el) => { if (el.dataset.premiumSpotlight === "1") return; el.dataset.premiumSpotlight = "1"; let raf = 0; let lastEvent = null; const update = () => { raf = 0; if (!lastEvent) return; const rect = el.getBoundingClientRect(); const x = ((lastEvent.clientX - rect.left) / Math.max(rect.width, 1)) * 100; const y = ((lastEvent.clientY - rect.top) / Math.max(rect.height, 1)) * 100; el.style.setProperty("--mx", `${Math.max(0, Math.min(100, x)).toFixed(2)}%`); el.style.setProperty("--my", `${Math.max(0, Math.min(100, y)).toFixed(2)}%`); }; el.addEventListener("pointermove", (event) => { if (window.matchMedia && window.matchMedia("(pointer: coarse)").matches) return; lastEvent = event; if (!raf) raf = requestAnimationFrame(update); }, { passive: true }); el.addEventListener("pointerleave", () => { lastEvent = null; if (raf) cancelAnimationFrame(raf); raf = 0; el.style.removeProperty("--mx"); el.style.removeProperty("--my"); }, { passive: true }); }); } function bindPanelPulse() { document.querySelectorAll(".tabBtn[data-target]").forEach((btn) => { if (btn.dataset.premiumTabBound === "1") return; btn.dataset.premiumTabBound = "1"; btn.addEventListener("click", () => { syncActivePanelState(btn.dataset.target); window.requestAnimationFrame(() => { const target = btn.dataset.target; const panel = findPanelByTarget(target); if (!panel) return; panel.classList.remove("isPremiumPulse"); void panel.offsetWidth; panel.classList.add("isPremiumPulse"); setTimeout(() => panel.classList.remove("isPremiumPulse"), 620); addRevealStagger(panel); bindSpotlights(panel); }); }); }); } function findPanelByTarget(target) { if (!target) return null; try { if (window.CSS && typeof window.CSS.escape === "function") { return document.querySelector(`.panel[data-panel="${window.CSS.escape(target)}"]`); } } catch (_) {} return Array.from(document.querySelectorAll(".panel[data-panel]")) .find((panel) => panel.dataset.panel === target) || null; } function syncActivePanelState(target) { const activeTarget = target || document.querySelector(".tabBtn.active[data-target]")?.dataset.target || "device"; document.documentElement.dataset.premiumPanel = activeTarget; if (activeTarget === "device") { const workspace = document.querySelector(".configWorkspace"); if (workspace) workspace.scrollTop = 0; } } function ensureReferenceWorkspace() { const workspace = document.querySelector(".configWorkspace"); if (!workspace || workspace.querySelector(".premiumReplica")) return; const replica = document.createElement("div"); replica.className = "premiumReplica"; replica.innerHTML = `
▣设备配置
⌘运行参数
▽筛选设置
▣高价值福袋预约
♙养号设置
`; const panels = workspace.querySelector(".panels"); workspace.insertBefore(replica, panels || null); workspace.scrollTop = 0; } function enhanceMetricCards() { const specs = [ ["运行", "run"], ["设备", "device"], ["福袋", "gift"], ["日志", "log"], ]; document.querySelectorAll(".overviewCard").forEach((card, index) => { if (card.querySelector(".premiumMetricIcon")) return; const [label, tone] = specs[index] || ["状态", "default"]; const icon = document.createElement("span"); icon.className = "premiumMetricIcon"; icon.dataset.tone = tone; icon.textContent = label.slice(0, 1); card.appendChild(icon); }); } function bindReplicaBindings() { document.querySelectorAll("[data-premium-click]").forEach((btn) => { if (btn.dataset.premiumClickBound === "1") return; btn.dataset.premiumClickBound = "1"; btn.addEventListener("click", () => { const target = document.querySelector(btn.dataset.premiumClick); if (target) target.click(); }); }); document.querySelectorAll("[data-premium-bind]").forEach((mirror) => { if (mirror.dataset.premiumBindBound === "1") return; mirror.dataset.premiumBindBound = "1"; const applyToTarget = () => { const target = document.querySelector(mirror.dataset.premiumBind); if (!target) return; if (target.type === "checkbox") { target.checked = Boolean(mirror.checked); } else { target.value = mirror.value; } target.dispatchEvent(new Event("input", { bubbles: true })); target.dispatchEvent(new Event("change", { bubbles: true })); }; mirror.addEventListener("input", applyToTarget); mirror.addEventListener("change", applyToTarget); }); } function updateReplicaBindings() { document.querySelectorAll("[data-premium-bind]").forEach((mirror) => { const target = document.querySelector(mirror.dataset.premiumBind); if (!target || mirror === document.activeElement) return; if (mirror.type === "checkbox" && target.type !== "checkbox") return; if (mirror.tagName === "SELECT" && target.tagName === "SELECT") { const source = Array.from(target.options).map((option) => ({ value: option.value, text: option.textContent, })); const current = Array.from(mirror.options).map((option) => `${option.value}\n${option.textContent}`).join("\n"); const next = source.map((option) => `${option.value}\n${option.text}`).join("\n"); if (current !== next) { mirror.innerHTML = ""; source.forEach((option) => { const el = document.createElement("option"); el.value = option.value; el.textContent = option.text; mirror.appendChild(el); }); } } if (target.type === "checkbox") { mirror.checked = Boolean(target.checked); } else if ("value" in target) { mirror.value = target.value; } mirror.disabled = Boolean(target.disabled); }); } function ensureDashboardRail() { const overview = document.querySelector(".overview"); if (!overview || overview.querySelector(".premiumDashboard")) return; const rail = document.createElement("div"); rail.className = "premiumDashboard"; rail.innerHTML = `
收益趋势
近7天按小时
设备状态
0
最新日志
`; overview.appendChild(rail); rail.querySelectorAll("[data-premium-jump]").forEach((btn) => { btn.addEventListener("click", () => { const target = btn.dataset.premiumJump; const tab = document.querySelector(`.tabBtn[data-target="${target}"]`); if (tab) tab.click(); }); }); } function updateDashboardRail() { const deviceTable = document.getElementById("premiumDeviceTable"); const latestLogs = document.getElementById("premiumLatestLogs"); if (!deviceTable || !latestLogs) return; const deviceSelect = document.getElementById("device"); const selectedDevice = deviceSelect?.selectedOptions?.[0]?.textContent?.trim() || deviceSelect?.value || "自动选择"; const runState = textOf("topRunState") || "等待启动"; const adbState = textOf("topAdbState") || textOf("adbStatus") || "ADB 状态待检测"; const runMeta = textOf("topRunMeta") || "-"; const deviceCount = document.getElementById("premiumDeviceCount"); if (deviceCount) deviceCount.textContent = (textOf("topDeviceState").match(/\d+/) || ["1"])[0]; deviceTable.innerHTML = ""; [ ["设备名称", "状态摘要", "状态"], ["当前设备", selectedDevice, runState], ["连接状态", adbState, "在线"], ["运行信息", runMeta, "同步"], ["策略队列", "预约 / 福袋 / 养号", "就绪"], ["日志链路", "运行日志 + 行为日志", "正常"], ].forEach((row, index) => { const item = document.createElement("div"); item.className = index === 0 ? "premiumDeviceRow premiumDeviceHead" : "premiumDeviceRow"; item.innerHTML = `${escapeSmall(row[0])}${escapeSmall(row[1])}${escapeSmall(row[2])}`; deviceTable.appendChild(item); }); latestLogs.innerHTML = ""; const lines = String(document.getElementById("runLog")?.textContent || "") .split(/\r?\n/) .map((line) => line.trim()) .filter(Boolean) .slice(-6) .reverse(); const shown = lines.length ? lines : ["等待运行日志写入"]; shown.forEach((line) => { const item = document.createElement("div"); item.className = "premiumLogRow"; item.textContent = line.length > 110 ? `${line.slice(0, 110)}...` : line; latestLogs.appendChild(item); }); } function textOf(id) { return String(document.getElementById(id)?.textContent || "").trim(); } function escapeSmall(value) { return String(value ?? "") .replace(/&/g, "&") .replace(//g, ">") .replace(/"/g, """); } function observeDynamicCards() { if (!("MutationObserver" in window)) return; const observer = new MutationObserver((records) => { let shouldRefresh = false; for (const record of records) { if (record.addedNodes && record.addedNodes.length) { shouldRefresh = true; break; } } if (!shouldRefresh) return; addRevealStagger(); bindSpotlights(); }); observer.observe(document.body, { childList: true, subtree: true }); } })();