// ==UserScript== // @name TEMU自动滚动核价 // @namespace http://tampermonkey.net/ // @version 4.0 // @description 自动查找带固定高度+滚动的div,自动滚动+自动操作 // @author 助手 // @match https://agentseller.temu.com/* // @grant none // ==/UserScript== (function() { 'use strict'; // 配置 let SCROLL_SPEED = 30; let CHECK_VALUE = 80; let isRunning = false; let loopId = null; let scrollInterval = null; // 【核心修复】通过样式查找滚动容器:max-height:940px + height:940px + overflow-y:scroll function getScrollEl() { const allDivs = document.querySelectorAll('div'); for (const div of allDivs) { const style = window.getComputedStyle(div); const maxH = style.maxHeight; const h = style.height; const overflowY = style.overflowY; if (maxH === '940px' && h === '940px' && overflowY === 'scroll') { return div; } } return null; } // 延时工具 function delay(ms) { return new Promise(r => setTimeout(r, ms)); } // 滚动控制 function startScroll() { const el = getScrollEl(); if (!el) { console.log('未找到滚动区域'); return; } scrollInterval = setInterval(() => { el.scrollTop += SCROLL_SPEED; // 滚到底自动停止 if (el.scrollTop + el.clientHeight >= el.scrollHeight - 10) { stopAll(); console.log('已到底部,自动停止'); } }, 30); } function stopScroll() { clearInterval(scrollInterval); scrollInterval = null; } // 自动检测操作逻辑 async function checkAndProcess() { if (!isRunning) return; const drawer = document.querySelector('.Drawer_content_5-120-1.Drawer_right_5-120-1.Drawer_visible_5-120-1'); if (!drawer) return; const tbody = drawer.querySelector('tbody'); if (!tbody) return; const trs = tbody.querySelectorAll('tr'); for (const tr of trs) { if (!isRunning) return; const prependCell = tr.querySelector('.IPT_prependCell_5-120-1.IPT_prependAppendCell_5-120-1'); if (!prependCell) continue; const inputWrapper = prependCell.nextElementSibling; if (!inputWrapper) continue; const input = inputWrapper.querySelector('input'); if (!input) continue; const val = Number(input.value.trim()); if (isNaN(val) || val >= CHECK_VALUE) continue; console.log(`检测到小于 ${CHECK_VALUE}:`, val); const cell = tr.querySelector('.IPT_inputBlockCell_5-120-1.ST_inputBlockCell_5-120-1'); if (cell) { cell.click(); await delay(200); } const panel = document.querySelector('.ST_dropdownPanel_5-120-1'); if (panel) { const lis = panel.querySelectorAll('li'); if (lis.length >= 3) lis[2].click(); } await delay(300); } } // 统一启停 function startAll() { if (isRunning) return; isRunning = true; startScroll(); loopId = setInterval(checkAndProcess, 500); } function stopAll() { isRunning = false; stopScroll(); clearInterval(loopId); loopId = null; } // 创建控制面板(同行布局) function createPanel() { if (document.querySelector('#autoPanel')) return; const panel = document.createElement('div'); panel.id = 'autoPanel'; panel.style.cssText = ` position: fixed; top: 20px; right: 20px; z-index: 99999; background: #fff; border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,0.15); padding: 10px 12px; font-size: 14px; color: #333; display: flex; align-items: center; gap: 8px; `; panel.innerHTML = `