Skip to content

Free script to delete all tweets. Javascript, paste into Chrome.

Notifications You must be signed in to change notification settings

techleadhd/XDelete

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 

Repository files navigation

Script to delete all X / Twitter tweets. (Credits go to ChatGPT, I didn't write any of this code)

How to run:

const deleteAllTweets = async () => {
  const processedButtons = new Set();
  const getDeleteButtons = () => Array.from(document.querySelectorAll('[data-testid="tweet"] [data-testid="caret"]'));
  const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));

  while (true) {
    const deleteButtons = getDeleteButtons().filter(button => !processedButtons.has(button));
    if (deleteButtons.length === 0) break;

    for (const button of deleteButtons) {
      processedButtons.add(button);
      button.click();
      await delay(250);

      const menuItems = Array.from(document.querySelectorAll('[role="menuitem"]'));
      const deleteOption = menuItems.find(item => item.textContent === 'Delete');

      if (deleteOption) {
        deleteOption.click();
        document.querySelector('[data-testid="confirmationSheetConfirm"]')?.click();
        await delay(3000);
      } else {
        const tweetContainer = button.closest('[data-testid="tweet"]');
        const unretweetButton = tweetContainer?.querySelector('[data-testid="unretweet"]');

        if (unretweetButton) {
          unretweetButton.click();
          await delay(250);
          document.querySelector('[data-testid="unretweetConfirm"]')?.click();
          await delay(3000);
        }
      }
    }
  }

  console.log('All tweets deleted successfully!');
};

deleteAllTweets();
Screenshot 2023-12-31 at 7 18 45 PM

About

Free script to delete all tweets. Javascript, paste into Chrome.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published