450 lines
21 KiB
JavaScript
450 lines
21 KiB
JavaScript
(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();
|
|
enhanceMetricCards();
|
|
addRevealStagger();
|
|
bindSpotlights();
|
|
bindPanelPulse();
|
|
observeDynamicCards();
|
|
});
|
|
|
|
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 = `
|
|
<section class="premiumConfigCard">
|
|
<div class="premiumConfigHead">
|
|
<div><span class="premiumSectionIcon">▣</span><b>设备配置</b></div>
|
|
<label class="premiumSwitch"><input type="checkbox" checked><span></span>启用</label>
|
|
</div>
|
|
<div class="premiumGrid2">
|
|
<label class="premiumField"><span>设备分组</span><select><option>默认分组</option></select></label>
|
|
<label class="premiumField"><span>设备选择</span><select data-premium-bind="#device"></select></label>
|
|
</div>
|
|
<div class="premiumGrid5 premiumConnectionGrid">
|
|
<label class="premiumRadio"><input type="radio" checked><span>USB 连接</span></label>
|
|
<label class="premiumRadio"><input type="radio"><span>无线连接</span></label>
|
|
<label class="premiumField premiumWide"><span>ADB 路径</span><input value="D:\\Android\\platform-tools\\adb.exe"></label>
|
|
<label class="premiumField"><span>设备超时(秒)</span><input type="number" value="15"></label>
|
|
<label class="premiumField"><span>重连次数</span><input type="number" value="3"></label>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="premiumConfigCard">
|
|
<div class="premiumConfigHead">
|
|
<div><span class="premiumSectionIcon">⌘</span><b>运行参数</b></div>
|
|
<label class="premiumSwitch"><input data-premium-bind="#needswitch" type="checkbox"><span></span>启用</label>
|
|
</div>
|
|
<div class="premiumGrid5">
|
|
<label class="premiumField"><span>并发任务数</span><input type="number" value="6"></label>
|
|
<label class="premiumField"><span>启动间隔(秒)</span><input data-premium-bind="#wait_minutes" type="number"></label>
|
|
<label class="premiumField"><span>单任务运行时长(分钟)</span><input data-premium-bind="#fudai_find_max_attempts" type="number"></label>
|
|
<label class="premiumField"><span>任务间隔(秒)</span><input data-premium-bind="#reset_after_swipes" type="number"></label>
|
|
<label class="premiumField"><span>网络切换</span><select data-premium-bind="#reset_after_swipes_action"></select></label>
|
|
</div>
|
|
<div class="premiumChecks">
|
|
<label><input data-premium-bind="#needswitch" type="checkbox">随机滑动</label>
|
|
<label><input data-premium-bind="#infinite_loop_enabled" type="checkbox">随机停留</label>
|
|
<label><input data-premium-bind="#reset_after_swipes_enabled" type="checkbox">随机点赞</label>
|
|
<label><input data-premium-bind="#fudai_disable_content_recognition" type="checkbox">随机关注</label>
|
|
<label><input data-premium-bind="#enable_back_on_misses" type="checkbox">观看直播</label>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="premiumConfigCard">
|
|
<div class="premiumConfigHead">
|
|
<div><span class="premiumSectionIcon">▽</span><b>筛选设置</b></div>
|
|
<label class="premiumSwitch"><input data-premium-bind="#auto_join_fansclub" type="checkbox"><span></span>启用</label>
|
|
</div>
|
|
<div class="premiumGrid6">
|
|
<label class="premiumField"><span>福袋类型</span><select><option>全部</option></select></label>
|
|
<label class="premiumField"><span>福袋价值</span><input data-premium-bind="#min_prize_value_yuan" type="number"></label>
|
|
<label class="premiumField"><span>参与人数</span><input data-premium-bind="#min_participants" type="number"></label>
|
|
<label class="premiumField"><span>开奖倒计时(秒)</span><input data-premium-bind="#skip_if_countdown_lt_seconds" type="number"></label>
|
|
<label class="premiumSwitch premiumInline"><input data-premium-bind="#auto_join_fansclub" type="checkbox"><span></span>过滤已参与</label>
|
|
<button class="premiumGhostBtn" type="button">黑名单用户</button>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="premiumConfigCard">
|
|
<div class="premiumConfigHead">
|
|
<div><span class="premiumSectionIcon">▣</span><b>高价值福袋预约</b></div>
|
|
<label class="premiumSwitch"><input data-premium-bind="#high_value_fudai_enabled" type="checkbox"><span></span>启用</label>
|
|
</div>
|
|
<div class="premiumGrid6">
|
|
<label class="premiumSwitch premiumInline"><input data-premium-bind="#high_value_fudai_enabled" type="checkbox"><span></span>自动预约</label>
|
|
<label class="premiumField"><span>预约门槛(抖币)</span><input data-premium-bind="#high_value_fudai_threshold_yuan" type="number"></label>
|
|
<label class="premiumField"><span>提前预约(秒)</span><input data-premium-bind="#high_value_fudai_join_ahead_seconds" type="number"></label>
|
|
<label class="premiumField"><span>同时预约数量</span><input data-premium-bind="#high_value_fudai_max_reservations" type="number"></label>
|
|
<label class="premiumField"><span>预约失败重试</span><select data-premium-bind="#high_value_fudai_after_action"></select></label>
|
|
<label class="premiumSwitch premiumInline"><input data-premium-bind="#high_value_room_revisit_only_current_run" type="checkbox"><span></span>仅预约未满</label>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="premiumConfigCard">
|
|
<div class="premiumConfigHead">
|
|
<div><span class="premiumSectionIcon">♙</span><b>养号设置</b></div>
|
|
<label class="premiumSwitch"><input data-premium-bind="#yanghao_enabled" type="checkbox"><span></span>启用</label>
|
|
</div>
|
|
<div class="premiumGrid6">
|
|
<label class="premiumField"><span>养号模式</span><select><option>智能养号</option></select></label>
|
|
<label class="premiumField"><span>每日运行时长(小时)</span><input data-premium-bind="#yanghao_recommend_duration_seconds" type="number"></label>
|
|
<label class="premiumField"><span>养号权重</span><select><option>中</option></select></label>
|
|
<label class="premiumField"><span>互动概率</span><input data-premium-bind="#yanghao_like_prob" type="number"></label>
|
|
<label class="premiumField"><span>内容偏好</span><select><option>随机推荐</option></select></label>
|
|
<label class="premiumField"><span>账号轮换</span><select><option>按设备轮换</option></select></label>
|
|
</div>
|
|
<div class="premiumChecks">
|
|
<label><input data-premium-bind="#yanghao_enable_actions" type="checkbox">观看视频</label>
|
|
<label><input type="checkbox" checked>点赞</label>
|
|
<label><input type="checkbox" checked>评论</label>
|
|
<label><input type="checkbox" checked>关注</label>
|
|
<label><input type="checkbox" checked>分享</label>
|
|
<label><input data-premium-bind="#yanghao_step_screenshot" type="checkbox">直播互动</label>
|
|
</div>
|
|
</section>
|
|
|
|
<div class="premiumConfigActions">
|
|
<button class="premiumPrimaryBtn" type="button" data-premium-click="#btnSave">保存配置</button>
|
|
<button class="premiumGhostBtn" type="button" data-premium-click="#btnLoad">另存为模板</button>
|
|
<button class="premiumGhostBtn premiumResetBtn" type="button" data-premium-click="#btnRefresh">恢复默认</button>
|
|
</div>
|
|
`;
|
|
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 = `
|
|
<section class="premiumDashCard premiumTrendCard">
|
|
<div class="premiumDashHead">
|
|
<div class="premiumDashTitle">收益趋势</div>
|
|
<div class="premiumDashTools"><span>近7天</span><span>按小时</span></div>
|
|
</div>
|
|
<svg class="premiumTrendSvg" viewBox="0 0 520 190" preserveAspectRatio="none" aria-hidden="true">
|
|
<defs>
|
|
<linearGradient id="premiumTrendFill" x1="0" y1="0" x2="0" y2="1">
|
|
<stop offset="0%" stop-color="#6d5dfc" stop-opacity="0.20"/>
|
|
<stop offset="100%" stop-color="#6d5dfc" stop-opacity="0"/>
|
|
</linearGradient>
|
|
</defs>
|
|
<path class="premiumTrendGrid" d="M38 30 H500 M38 70 H500 M38 110 H500 M38 150 H500 M38 30 V156 M142 30 V156 M246 30 V156 M350 30 V156 M454 30 V156"/>
|
|
<text class="premiumTrendAxis" x="6" y="34">4,000</text>
|
|
<text class="premiumTrendAxis" x="6" y="74">3,000</text>
|
|
<text class="premiumTrendAxis" x="6" y="114">2,000</text>
|
|
<text class="premiumTrendAxis" x="12" y="154">0</text>
|
|
<path class="premiumTrendArea" d="M38 148 C72 146 85 135 112 136 C150 138 162 115 198 112 C242 107 260 82 300 76 C338 70 354 44 396 48 C432 52 450 72 500 68 L500 170 L38 170 Z"/>
|
|
<path class="premiumTrendLine" d="M38 148 C72 146 85 135 112 136 C150 138 162 115 198 112 C242 107 260 82 300 76 C338 70 354 44 396 48 C432 52 450 72 500 68"/>
|
|
<path class="premiumTrendGhost" d="M38 158 C88 150 112 150 150 142 C198 133 214 124 260 122 C312 118 348 94 396 96 C438 98 456 112 500 108"/>
|
|
<circle class="premiumTrendPoint" cx="198" cy="112" r="3.5"/>
|
|
<circle class="premiumTrendPoint" cx="300" cy="76" r="3.5"/>
|
|
<circle class="premiumTrendPoint premiumTrendPointHot" cx="396" cy="48" r="4.5"/>
|
|
<text class="premiumTrendTick" x="38" y="184">00:00</text>
|
|
<text class="premiumTrendTick" x="246" y="184">12:00</text>
|
|
<text class="premiumTrendTick" x="470" y="184">24:00</text>
|
|
</svg>
|
|
</section>
|
|
<section class="premiumDashCard">
|
|
<div class="premiumDashHead">
|
|
<div class="premiumDashTitle">设备状态</div>
|
|
<span class="premiumDashCount" id="premiumDeviceCount">0</span>
|
|
</div>
|
|
<div class="premiumDeviceTable" id="premiumDeviceTable"></div>
|
|
</section>
|
|
<section class="premiumDashCard">
|
|
<div class="premiumDashHead">
|
|
<div class="premiumDashTitle">最新日志</div>
|
|
<button class="premiumLinkBtn" type="button" data-premium-jump="runLogs">更多日志</button>
|
|
</div>
|
|
<div class="premiumLatestLogs" id="premiumLatestLogs"></div>
|
|
</section>
|
|
`;
|
|
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 = `<span>${escapeSmall(row[0])}</span><b>${escapeSmall(row[1])}</b><em>${escapeSmall(row[2])}</em>`;
|
|
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, ">")
|
|
.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 });
|
|
}
|
|
})();
|