博主头像
哎呀博客

Se-Ryong .Blog

火山引擎 批量删除历史对话

const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));

function simulateClick(element) {
if (element) {

const eventOptions = { bubbles: true, cancelable: true, view: window };
element.dispatchEvent(new MouseEvent('mousedown', eventOptions));
element.dispatchEvent(new MouseEvent('mouseup', eventOptions));
element.dispatchEvent(new MouseEvent('click', eventOptions));

}
}

async function clickDeleteForAllCards() {
console.log('🚀 开始批量删除话题卡片');

const cards = document.querySelectorAll('[data-apm-action="话题列表-选择话题"]');
console.log(📦 共找到 ${cards.length} 个话题卡片);

for (let i = 0; i < cards.length; i++) {

const card = cards[i];
const moreBtn = card.querySelector('button.arco-btn-icon-only');

if (!moreBtn) {
  console.warn(`❌ 第 ${i + 1} 个卡片未找到“更多”按钮`);
  continue;
}

// 点击“更多”按钮
moreBtn.scrollIntoView({ behavior: 'instant', block: 'center' });
simulateClick(moreBtn);
console.log(`✅ 第 ${i + 1} 个话题“更多”按钮已点击`);

await delay(500); // 等待菜单弹出

// 查找并点击“删除对话”
const deleteBtn = Array.from(document.querySelectorAll('div.arco-dropdown-menu-item'))
  .find(el => el.textContent.trim() === '删除对话');

if (deleteBtn) {
  simulateClick(deleteBtn);
  console.log(`🗑️ 点击了“删除对话”`);
} else {
  console.warn(`❌ 没有找到“删除对话”菜单项`);
  continue;
}

await delay(500); // 等待弹窗出现

// 查找确认弹窗中的“确定”按钮
const confirmBtn = document.querySelector('button[data-apm-action="删除对话弹窗-确认"]');

if (confirmBtn) {
  simulateClick(confirmBtn);
  console.log(`✅ 第 ${i + 1} 项已确认删除`);
} else {
  console.warn(`❌ 未找到“确定”按钮`);
  continue;
}

await delay(1500); // 等待页面更新

}

console.log('✅ 所有话题删除流程已完成');
}

clickDeleteForAllCards();

火山引擎 批量删除历史对话
https://aiya.blog/archives/46.html
本文作者 seryong
发布时间 2025-05-14
许可协议 CC BY-NC-SA 4.0

评论已关闭