// ==UserScript== // @name GL脚本 // @namespace http://tampermonkey.net/ // @version 4.3.2 // @description 超低延迟极速响应快速切帧;完整校验;一键提交领包;物理坐标模拟鼠标事件极速点击! // @match https://ads.aligenie.com/* // @grant none // @run-at document-start // ==/UserScript== (function () { 'use strict'; const frameCache = {}; let currentRecordId = null; let panelDom = null; let contentDom = null; let globalBatchId = ""; let globalFrameTotal = 0; let batchUuidList = []; const STANDARD_KP = ["Right Eye","Left Eye","Nose Tip","Right Mouth","Left Mouth"]; let autoCheckTimer = null; let quickAttrClicked = false; // ========== 精准悬停 + MutationObserver 物理坐标点击 ========== let autoSubmitRunning = false; function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } // 核心:模拟物理鼠标点击,绕过 React 拦截 function simulatePhysicalClick(btn) { if (!btn) return; btn.focus(); // 聚光 if (btn.hasAttribute('disabled')) btn.removeAttribute('disabled'); // 解除禁用 // 获取真实坐标 const rect = btn.getBoundingClientRect(); const x = rect.left + rect.width / 2; const y = rect.top + rect.height / 2; // 按真实物理点击顺序发送:鼠标按下、鼠标松开、点击 ['mousedown', 'mouseup', 'click'].forEach(type => { btn.dispatchEvent(new MouseEvent(type, { view: window, bubbles: true, cancelable: true, clientX: x, clientY: y })); }); } async function performSubmitSequence() { if (autoSubmitRunning) return; autoSubmitRunning = true; showToast("正在悬停唤起菜单..."); try { const useElement = document.querySelector('use[xlink\\:href="#icon-tijiao"]'); let clickable = null; if (useElement) { clickable = useElement.closest('div.index_BatchAction__ietCm, button, a, [role="button"]'); if (!clickable) clickable = useElement.parentElement; } if (!clickable) { clickable = document.querySelector('div.index_BatchAction__ietCm'); } if (!clickable) { showToast("未能定位到右下角云朵按钮!"); autoSubmitRunning = false; return; } const rect = clickable.getBoundingClientRect(); const x = rect.left + rect.width / 2; const y = rect.top + rect.height / 2; ['mouseenter', 'mouseover', 'mousemove'].forEach(type => { const ev = new MouseEvent(type, { view: window, bubbles: true, cancelable: true, clientX: x, clientY: y }); clickable.dispatchEvent(ev); }); setTimeout(() => { const clickEv = new MouseEvent('click', { view: window, bubbles: true, cancelable: true }); clickable.dispatchEvent(clickEv); clickable.click(); console.log('[提交] 已触发悬停与点击云朵图标'); }, 200); await sleep(800); let submitBtn = document.querySelector('button[data-autolog="feature=customPassButton"]'); if (!submitBtn) { const allBtns = document.querySelectorAll('button'); for (const btn of allBtns) { if (btn.textContent && btn.textContent.trim().includes("提交")) { submitBtn = btn; break; } } } if (submitBtn) { submitBtn.style.pointerEvents = 'auto'; submitBtn.click(); showToast("已触发提交,正在极速监听下一包..."); console.log('[提交] 已成功点击提交按钮'); } else { showToast("悬停后未找到【提交】按钮!"); autoSubmitRunning = false; return; } // ========================================== // 💥 加速核心:MutationObserver 极速捕捉 + 物理坐标模拟 3 连击 // ========================================== let nextBtn = null; let observer = null; await new Promise((resolve) => { // 如果页面快得离谱,先做个预检查 let immediateBtn = document.querySelector('.ant-result-extra button:last-child'); if (immediateBtn && immediateBtn.textContent && immediateBtn.textContent.trim() === "领取下一个") { nextBtn = immediateBtn; resolve(); return; } observer = new MutationObserver((mutations, obs) => { let btn = document.querySelector('.ant-result-extra button:last-child'); if (btn && btn.textContent && btn.textContent.trim() === "领取下一个") { nextBtn = btn; obs.disconnect(); resolve(); return; } }); observer.observe(document.body, { childList: true, subtree: true }); // ⏱️ 4 秒安全兜底(比之前的8秒快一倍,没出现就不拖累) setTimeout(() => { if (observer) { observer.disconnect(); resolve(); } }, 4000); }); if (nextBtn) { console.log('[提交] 开始物理坐标模拟连发...'); // 瞬时第一击(0毫秒) simulatePhysicalClick(nextBtn); // 极速补刀第二击(40毫秒,防 React 眨眼) setTimeout(() => { if (document.body.contains(nextBtn)) { simulatePhysicalClick(nextBtn); } }, 40); // 极速补刀第三击(80毫秒,绝杀收尾) setTimeout(() => { if (document.body.contains(nextBtn)) { simulatePhysicalClick(nextBtn); } }, 80); showToast("✅ 已成功领取下一包!"); } else { showToast("未检测到【领取下一个】按钮,请检查页面!"); console.warn('[提交] 监听超时,未找到领取按钮'); } // ========================================== } catch (err) { console.error('[提交] 发生错误:', err); showToast("提交出错:" + err.message); } finally { autoSubmitRunning = false; } } // ========== 提交逻辑结束 ========== function showToast(msg) { const tip = document.createElement("div"); tip.style.cssText = "position:fixed;top:24px;left:50%;transform:translateX(-50%);background:#222;color:#fff;padding:8px 14px;border-radius:6px;z-index:999999999;font-size:13px;"; tip.innerText = msg; document.body.appendChild(tip); setTimeout(() => tip.remove(), 2000); } async function copyBatchFrameData() { const copyText = `${globalBatchId}\t\t\t\t${globalFrameTotal}`; try { await navigator.clipboard.writeText(copyText); showToast("复制成功"); } catch (e) { showToast("复制失败:" + copyText); } } function initPanel() { if (panelDom && document.body.contains(panelDom)) return; panelDom = document.createElement('div'); panelDom.style.cssText = ` position: fixed; z-index: 999999999; width: 420px; left:15px; top:70px; background:#fff; border:1px solid #d1d5db; border-radius:10px; box-shadow:0 4px 20px rgba(0,0,0.15); font-family:"Microsoft YaHei"; font-size:13px; overflow:hidden; `; const header = document.createElement('div'); header.style.cssText = `display:flex;gap:6px;align-items:center;padding:8px 12px;background:#f3f4f6;border-bottom:1px solid #ddd;cursor:move`; header.innerHTML = `GL人脸五点‑极速校验`; const btnWrap = document.createElement('div'); btnWrap.style.display = 'flex'; const refreshBtn = makeBtn("↻", ()=>runCheck()); const closeBtn = makeBtn("✕", ()=>panelDom.remove()); btnWrap.append(refreshBtn, closeBtn); header.appendChild(btnWrap); panelDom.append(header); contentDom = document.createElement('div'); contentDom.style.padding = "12px"; contentDom.style.maxHeight = "480px"; contentDom.style.overflowY = "auto"; panelDom.append(contentDom); const copyBox = document.createElement("div"); copyBox.style.cssText = "padding:0 12px 8px;"; const copyBtn = document.createElement("div"); copyBtn.style.cssText = "width:100%;padding:9px 0;background:#cce5ff;text-align:center;border-radius:6px;font-weight:bold;font-size:14px;cursor:pointer;"; copyBtn.innerText = "📋 一键复制批次&有效帧"; copyBtn.onmouseover = () => copyBtn.style.background = "#74a9ff"; copyBtn.onmouseout = () => copyBtn.style.background = "#cce5ff"; copyBtn.onclick = copyBatchFrameData; copyBox.appendChild(copyBtn); panelDom.appendChild(copyBox); const submitBox = document.createElement("div"); submitBox.style.cssText = "padding:0 12px 12px;"; const autoSubmitBtn = document.createElement("div"); autoSubmitBtn.style.cssText = "width:100%;padding:9px 0;background:#dcfce7;text-align:center;border-radius:6px;font-weight:bold;font-size:14px;cursor:pointer;margin-top:6px;"; autoSubmitBtn.innerText = "🚀 一键提交并领取下一包"; autoSubmitBtn.onmouseover = () => autoSubmitBtn.style.background = "#86efac"; autoSubmitBtn.onmouseout = () => autoSubmitBtn.style.background = "#dcfce7"; autoSubmitBtn.onclick = performSubmitSequence; submitBox.appendChild(autoSubmitBtn); panelDom.appendChild(submitBox); let drag = false, ox, oy; header.onmousedown = e=>{ drag = true; const r = panelDom.getBoundingClientRect(); ox = e.clientX - r.left; oy = e.clientY - r.top; document.onmousemove = ev=>{ panelDom.style.left = (ev.clientX - ox)+'px'; panelDom.style.top = (ev.clientY - oy)+'px'; } document.onmouseup = ()=>{drag=false;document.onmousemove=null} } document.body.appendChild(panelDom); } function makeBtn(text, click){ const s = document.createElement('span'); s.innerText=text; s.style.cssText = `width:26px;height:26px;border-radius:6px;background:#e5e7eb;display:flex;align-items:center;justify-content:center;cursor:pointer;font-weight:bold`; s.onclick = click; return s; } // 核心防抖和轮询方法 function autoRunCheck() { clearTimeout(autoCheckTimer); autoCheckTimer = setTimeout(() => { runCheck(); if (!quickAttrClicked) { let quickBtn = document.querySelector('button[title="快捷属性"]'); if (!quickBtn) { const svgUse = document.querySelector('use[xlink\\:href="#icon-kuaijieshuxing"]'); if (svgUse) { quickBtn = svgUse.closest('button, div[role="button"]'); } } if (quickBtn) { quickBtn.click(); quickAttrClicked = true; console.log('[快捷属性] 已自动点击打开快捷属性菜单'); } } }, 60); } function calcValidFrameCount(){ let validNum = 0; for(let recordId in frameCache){ const oneFrame = frameCache[recordId]; try{ const workObj = JSON.parse(oneFrame.workResult); if(workObj?.labels?.invalid !== "true") validNum +=1; }catch { validNum +=1; } } return validNum; } function runCheck(){ initPanel(); globalFrameTotal = calcValidFrameCount(); if(!currentRecordId || !frameCache[currentRecordId]){ contentDom.innerHTML = `暂无帧缓存,等待加载数据`; return; } const frameData = frameCache[currentRecordId]; let workObj; try{ workObj = JSON.parse(frameData.workResult); }catch{ return; } if(workObj?.labels?.invalid === "true"){ contentDom.innerHTML = `