← Blog
免费工具2026年5月30日·4分钟阅读

如何一次性删除所有推文 — 免费,无需API,无需App

X/Twitter没有'全部删除'按钮。付费工具按月收费。这个免费浏览器脚本几分钟就能搞定——无需安装,无需账户,没有陷阱。

问题所在

无论你是在重塑品牌、清理旧账号还是重新开始,逐条删除数千条推文都不现实。X没有批量删除功能。TweetDelete等服务虽然有效,但它们每月收取€6–15的费用,而这本应是免费的。

免费解决方案

我们构建了一个JavaScript脚本,直接在浏览器控制台中运行。它自动滚动你的主页,识别你自己的推文和转推,并逐一删除。无需安装,无需API密钥,无需外部服务——只需你的浏览器。

我们在重新启动@Sublime_Arts_之前,自己用它清理了一个旧的X账号——它删除了数百条帖子,没有出现任何问题。

使用方法 — 3步

1访问你的X个人主页 — x.com/你的用户名
2打开DevTools:按F12 → 点击Console标签
3粘贴下面的脚本并按Enter。保持标签页打开。

功能说明

↩️撤销所有转帖
🗑️删除原创推文
🔍仅针对主Feed列
⏭️跳过广告和他人帖子

进度实时记录在控制台中。8次空滚动后自动停止。如果X懒加载了更多帖子,重新运行脚本即可。

脚本

cleanup_x_profile.jsF12 → Console
const sleep = ms => new Promise(r => setTimeout(r, ms));

async function cleanupXProfile() {
  let repostsRemoved = 0, tweetsDeleted = 0, emptyScrolls = 0;
  const getCol = () =>
    document.querySelector('[data-testid="primaryColumn"]') ||
    document.querySelector('main') || document;
  const closeMenu = async () => {
    document.dispatchEvent(new KeyboardEvent('keydown',
      { key: 'Escape', keyCode: 27, bubbles: true }));
    await sleep(250);
    const h = getCol().querySelector('h1, h2');
    if (h) h.click(); await sleep(200);
  };
  console.log('🧹 X Profile Cleanup started...');
  while (emptyScrolls < 8) {
    let actions = 0; const col = getCol();
    for (const btn of [...col.querySelectorAll('button')]
      .filter(b => b.innerHTML.includes('M4.75 3.79l4.603'))) {
      try {
        btn.click(); await sleep(700);
        const c = document.querySelector('[data-testid="unretweetConfirm"]');
        if (c) { c.click(); repostsRemoved++; actions++;
          console.log(`↩️ Repost removed #${repostsRemoved}`); await sleep(900);
        } else await closeMenu();
      } catch { await closeMenu(); }
    }
    for (const btn of [...col.querySelectorAll('button')]
      .filter(b => b.innerHTML.includes('M3 12c0-1.1.9-2 2-2s2'))) {
      await closeMenu(); await sleep(300);
      try {
        btn.click(); await sleep(800);
        const del = [...document.querySelectorAll('[role="menuitem"]')]
          .find(i => i.textContent.trim()
            .match(/^(Delete|Elimina|Supprimer|Löschen|Eliminar|Удалить|削除|삭제)$/));
        if (del) {
          del.click(); await sleep(700);
          const ok = document.querySelector('[data-testid="confirmationSheetConfirm"]');
          if (ok) { ok.click(); tweetsDeleted++; actions++;
            console.log(`🗑️ Tweet deleted #${tweetsDeleted}`); await sleep(1200);
          } else await closeMenu();
        } else await closeMenu();
      } catch { await closeMenu(); }
    }
    if (actions === 0) { emptyScrolls++;
      console.log(`Scrolling... (${emptyScrolls}/8)`);
    } else emptyScrolls = 0;
    window.scrollBy(0, 900); await sleep(2000);
  }
  console.log(`\n✅ Done! Reposts: ${repostsRemoved} | Tweets: ${tweetsDeleted}`);
}
cleanupXProfile();

About

Patrick Chen — Sublimearts.io背后的独立开发者。这是我在重新启动自己的X账号时构建的工具。