进入拼多多活动

按F12按钮打开控制台

在控制台空白处点击,然后复制脚本进去,回车
// == 拼多多活动取消助手(持续取消版)==
// 功能:自动循环取消 | 自动翻页 | 进度显示 | 直到无活动可取消
// 1. 创建控制面板UI
const panel = document.createElement('div');
panel.id = 'pdd-ultimate-helper';
panel.style = `
position: fixed;
bottom: 30px;
right: 30px;
z-index: 999999;
background: white;
padding: 15px;
border-radius: 8px;
box-shadow: 0 4px 20px rgba(0,0,0,0.15);
font-family: 'PingFang SC', sans-serif;
width: 350px;
`;
// 2. 添加UI内容
panel.innerHTML = `
<h3 style="margin:0 0 10px 0;color:#FF2E4D;display:flex;align-items:center">
<svg width="20" height="20" viewBox="0 0 24 24" style="margin-right:8px">
<path fill="#FF2E4D" d="M12,2L1,21H23M12,6L19.5,19H4.5M11,10V14H13V10M11,16V18H13V16"/>
</svg>
拼多多活动取消(持续版)
</h3>
<div style="margin-bottom:10px">
<div style="display:flex;justify-content:space-between;font-size:12px;color:#666;margin-bottom:4px">
<span>进度: <span id="pdd-progress-text">0%</span></span>
<span>已取消: <span id="pdd-processed">0</span> 条</span>
</div>
<div style="background:#f0f0f0;height:8px;border-radius:4px;overflow:hidden">
<div id="pdd-progress-bar" style="height:100%;width:0%;background:linear-gradient(90deg, #FF2E4D, #FF8000);transition:width 0.3s"></div>
</div>
</div>
<div id="pdd-status" style="margin:10px 0;font-size:13px;min-height:40px">准备就绪</div>
<div style="display:flex;gap:10px;margin-bottom:10px">
<button id="pdd-start-btn" style="
flex:1;
background: linear-gradient(135deg, #FF2E4D 0%, #FF6B81 100%);
color: white;
border: none;
padding: 10px;
border-radius: 6px;
cursor: pointer;
font-weight: bold;
">开始取消</button>
<button id="pdd-stop-btn" style="
flex:1;
background: #f0f0f0;
color: #666;
border: none;
padding: 10px;
border-radius: 6px;
cursor: pointer;
">停止</button>
</div>
<div style="font-size:12px;color:#888">
<label style="cursor:pointer;display:block;margin-bottom:5px">
<input type="checkbox" id="pdd-auto-scroll" checked> 自动滚动到元素
</label>
<label style="cursor:pointer;display:block;margin-bottom:5px">
<input type="checkbox" id="pdd-auto-nextpage" checked> 自动翻下一页
</label>
<label style="cursor:pointer">
<input type="checkbox" id="pdd-skip-error" checked> 出错时自动跳过
</label>
</div>
`;
// 3. 添加到页面
function injectUI() {
const injectors = [
() => document.body.appendChild(panel),
() => document.documentElement.appendChild(panel),
() => {
const container = document.querySelector('body > div:first-child') || document.body;
container.appendChild(panel);
}
];
for (const inject of injectors) {
try { inject(); break; } catch(e) { console.error('注入方式失败:', e); }
}
}
injectUI();
// 4. 核心功能
let isRunning = false;
let stopFlag = false;
let processedCount = 0;
// 更新UI状态
function updateStatus(text, isError = false) {
const statusEl = document.getElementById('pdd-status');
statusEl.innerHTML = text;
statusEl.style.color = isError ? '#FF2E4D' : '#333';
console.log(`[PDD Helper] ${text}`);
}
// 更新进度
function updateProgress(processed) {
processedCount = processed;
document.getElementById('pdd-progress-text').textContent = `${processed}条`;
document.getElementById('pdd-processed').textContent = processed;
}
// 查找所有可取消的活动
function findActivities() {
return Array.from(
document.querySelectorAll('a[data-tracking-click-viewid="bigpopup_reconsider_shared"]')
).filter(btn => {
return btn.offsetParent !== null && !btn.disabled;
});
}
// 查找下一页按钮
function findNextPageButton() {
return document.querySelector('.next-btn, .next-button, [data-testid="next-page"]');
}
// 自动点击"放弃活动"
async function clickAbandonButton(retry = 0) {
const maxRetry = 3;
try {
const confirmBtn = document.querySelector('button[data-tracking-click-viewid="cancel_activity_true_shared"]');
if (confirmBtn) {
confirmBtn.click();
await new Promise(r => setTimeout(r, 1000));
return true;
}
throw new Error('未找到"放弃活动"按钮');
} catch (error) {
if (retry < maxRetry) {
await new Promise(r => setTimeout(r, 500 * (retry + 1)));
return clickAbandonButton(retry + 1);
}
throw error;
}
}
// 处理当前页活动
async function processCurrentPage() {
const activities = findActivities();
if (activities.length === 0) return false;
updateStatus(`当前页找到 ${activities.length} 个活动`);
for (let i = 0; i < activities.length; i++) {
if (stopFlag) return false;
const btn = activities[i];
const activityName = btn.closest('tr')?.querySelector('.activity-name')?.textContent?.trim() || `活动 ${i+1}`;
// 更新状态
updateStatus(`正在处理: ${activityName}`);
document.getElementById('pdd-start-btn').textContent = `取消中...`;
// 自动滚动到当前元素
if (document.getElementById('pdd-auto-scroll').checked) {
btn.scrollIntoView({ behavior: 'smooth', block: 'center' });
await new Promise(r => setTimeout(r, 500));
}
try {
// 点击取消按钮
btn.click();
await new Promise(r => setTimeout(r, 1500));
// 自动点击放弃活动
await clickAbandonButton();
// 更新计数
updateProgress(processedCount + 1);
// 等待操作完成
await new Promise(r => setTimeout(r, 1000));
} catch (error) {
const skipError = document.getElementById('pdd-skip-error').checked;
if (skipError) {
updateStatus(`⚠️ 跳过出错活动: ${error.message}`, true);
continue;
}
throw error;
}
}
return true;
}
// 尝试翻到下一页
async function goToNextPage() {
if (!document.getElementById('pdd-auto-nextpage').checked) return false;
const nextBtn = findNextPageButton();
if (!nextBtn || nextBtn.disabled) return false;
updateStatus('准备翻到下一页...');
nextBtn.click();
await new Promise(r => setTimeout(r, 2000)); // 等待页面加载
// 检查是否翻页成功
return !!findActivities().length;
}
// 主处理流程
async function processAllPages() {
stopFlag = false;
isRunning = true;
processedCount = 0;
document.getElementById('pdd-start-btn').disabled = true;
document.getElementById('pdd-stop-btn').style.background = '#FF2E4D';
document.getElementById('pdd-stop-btn').style.color = 'white';
updateProgress(0);
try {
let hasMore = true;
while (hasMore && !stopFlag) {
// 处理当前页
const hasActivities = await processCurrentPage();
if (!hasActivities) {
// 尝试翻页
hasMore = await goToNextPage();
if (!hasMore) {
updateStatus('✅ 已完成所有活动取消');
break;
}
}
}
if (stopFlag) {
updateStatus(`⏹️ 已停止 (已取消 ${processedCount} 条)`);
}
} catch (error) {
updateStatus(`❌ 处理失败: ${error.message}`, true);
} finally {
isRunning = false;
document.getElementById('pdd-start-btn').disabled = false;
document.getElementById('pdd-start-btn').textContent = '开始取消';
document.getElementById('pdd-stop-btn').style.background = '#f0f0f0';
document.getElementById('pdd-stop-btn').style.color = '#666';
}
}
// 事件绑定
document.getElementById('pdd-start-btn').addEventListener('click', processAllPages);
document.getElementById('pdd-stop-btn').addEventListener('click', () => {
if (isRunning) {
stopFlag = true;
updateStatus('正在停止...');
}
});
// 5. 样式保护
const styleProtection = document.createElement('style');
styleProtection.textContent = `
#pdd-ultimate-helper, #pdd-ultimate-helper * {
all: initial;
font-family: 'PingFang SC', sans-serif !important;
box-sizing: border-box !important;
}
#pdd-ultimate-helper {
position: fixed !important;
bottom: 30px !important;
right: 30px !important;
z-index: 999999 !important;
background: white !important;
padding: 15px !important;
border-radius: 8px !important;
box-shadow: 0 4px 20px rgba(0,0,0,0.15) !important;
width: 350px !important;
animation: pdd-fadeIn 0.3s !important;
}
@keyframes pdd-fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
`;
document.head.appendChild(styleProtection);
// 初始化完成
updateStatus('准备就绪,点击"开始取消"持续处理');
console.log('拼多多持续取消助手已加载!');
点击开始取消

等待进度完成即可

评论区