// ==UserScript== // @name TEMU 广告批量循环删除 // @namespace https://docs.scriptcat.org/ // @version 3.0.0 // @description 无弹窗、无停止,当前页自动循环执行删除,刷新后自动继续 // @author You // @match *://seller.kuajingmai.com/* // @match *://ads.temu.com/* // @noframes false // @grant none // @run-at document-idle // ==/UserScript== (function() { 'use strict'; let isRunning = false; // 添加控制按钮 function addButton() { if (document.getElementById('temu-loop-btn')) return; // 添加样式标签 if (!document.getElementById('temu-loop-style')) { const style = document.createElement('style'); style.id = 'temu-loop-style'; style.textContent = ` /* 悬浮按钮美化样式 */ #temu-loop-btn { position: fixed; top: 100px; right: 20px; z-index: 999999; width: 48px; height: 48px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; border: none; border-radius: 50%; font-size: 20px; cursor: pointer; box-shadow: 0 8px 32px rgba(102, 126, 234, 0.4); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); display: flex; align-items: center; justify-content: center; user-select: none; backdrop-filter: blur(10px); } #temu-loop-btn:hover:not(:disabled) { transform: scale(1.08); box-shadow: 0 12px 40px rgba(102, 126, 234, 0.5); } #temu-loop-btn:active:not(:disabled) { transform: scale(0.95); } #temu-loop-btn:disabled { background: linear-gradient(135deg, #a0aec0 0%, #718096 100%); cursor: not-allowed; box-shadow: 0 4px 16px rgba(113, 128, 150, 0.3); opacity: 0.9; } /* 执行中动画 */ @keyframes pulse-glow { 0%, 100% { box-shadow: 0 8px 32px rgba(102, 126, 234, 0.4); } 50% { box-shadow: 0 8px 32px rgba(102, 126, 234, 0.7); } } #temu-loop-btn.running { animation: pulse-glow 2s ease-in-out infinite; } #temu-loop-btn.dragging { transition: none; cursor: grabbing; } `; document.head.appendChild(style); } const btn = document.createElement('button'); btn.id = 'temu-loop-btn'; btn.textContent = '🗑️'; btn.title = '点击开始当前页循环删除'; // 拖拽逻辑 let isDragging = false; let dragOffsetX = 0; let dragOffsetY = 0; btn.addEventListener('mousedown', function(e) { isDragging = false; dragOffsetX = e.clientX - btn.offsetLeft; dragOffsetY = e.clientY - btn.offsetTop; function onMouseMove(e) { isDragging = true; btn.classList.add('dragging'); let x = e.clientX - dragOffsetX; let y = e.clientY - dragOffsetY; // 限制在视口内 x = Math.max(0, Math.min(window.innerWidth - btn.offsetWidth, x)); y = Math.max(0, Math.min(window.innerHeight - btn.offsetHeight, y)); btn.style.left = x + 'px'; btn.style.top = y + 'px'; btn.style.right = 'auto'; } function onMouseUp(e) { document.removeEventListener('mousemove', onMouseMove); document.removeEventListener('mouseup', onMouseUp); btn.classList.remove('dragging'); } document.addEventListener('mousemove', onMouseMove); document.addEventListener('mouseup', onMouseUp); }); btn.onclick = async function(e) { if (isDragging) { isDragging = false; return; } // 如果正在运行,点击则暂停 if (isRunning) { isRunning = false; btn.disabled = false; btn.classList.remove('running'); btn.textContent = '🗑️'; btn.title = '点击开始当前页循环删除'; console.log('=== 已暂停循环删除 ==='); return; } // 开始运行 isRunning = true; btn.classList.add('running'); btn.textContent = '⏳'; btn.title = '点击暂停循环删除'; console.log('=== 已开始当前页无限循环删除 ==='); while (isRunning) { await deleteCurrentPage(); // 等待页面刷新/数据加载 await sleep(3000); } }; document.body.appendChild(btn); } // 延时工具 function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } // 核心:当前页删除流程(无弹窗、无提示) async function deleteCurrentPage() { console.log('--- 开始处理当前页 ---'); // 1. 自动全选(双保险,无检查) const checkAllWrapper = document.querySelector('thead th .CBX_square_123, thead th .ant-checkbox'); if (checkAllWrapper) { checkAllWrapper.click(); await sleep(1000); } const checkAllInput = document.querySelector('thead th input[type="checkbox"]'); if (checkAllInput) { checkAllInput.click(); await sleep(1000); } // 2. 点击删除按钮 let deleteBtn = null; const allButtons = document.querySelectorAll('button, div[role="button"]'); for (let btn of allButtons) { if (btn.textContent.trim() === '删除' && !btn.closest('tr')) { deleteBtn = btn; break; } } if (deleteBtn) { deleteBtn.click(); console.log('✅ 已点击删除按钮'); await sleep(1500); } else { console.warn('❌ 未找到删除按钮,等待刷新后重试'); return; } // 3. 自动确认删除(无弹窗提示) let confirmBtn = null; const modalButtons = document.querySelectorAll('.MDL_footer_123 button, .ant-modal button, div[role="button"]'); for (let btn of modalButtons) { if (btn.textContent.trim() === '确定删除') { confirmBtn = btn; break; } } if (confirmBtn) { confirmBtn.click(); console.log('✅ 已自动确认删除,等待刷新...'); await sleep(2000); } else { console.warn('❌ 未找到确认按钮,等待刷新后重试'); } } // 页面加载后自动添加按钮 if (document.readyState === 'complete') { addButton(); } else { window.addEventListener('load', addButton); } setTimeout(addButton, 1000); setTimeout(addButton, 3000); })();