简体   繁体   中英

Delete all tweets from personal twitter account

My Twitter account has been hacked and a scam posted about 500 scam-tweets from it.

The task: delete all tweets with JS in DevTools.

My solution:

const tweets = document.querySelectorAll('[data-testid="tweet"]')
for (let i = 0; i<= tweets.length; i++) {
   //1. Click on a tweet to show the tweet-menu:
   setTimeout(() => {tweets[i].querySelector('[aria-label="More"]').click()}, 1000)

   //2. Click on delete option:
   setTimeout(() => {document.querySelector('[role="menuitem"]').click()}, 1000)

   //3. Approve deleting in popup:
   setTimeout(() => {document.querySelector('[data-testid="confirmationSheetConfirm"]').click()}, 1000)
}

Problems:

  1. We need to scroll for more tweets and only then run it again.
  2. Each step (1,2,3) is not waiting for the previous to end running.

I think what you are looking for is the Twitter API, you can find the documentation here: Twitter Developer API

It allows you to log into your account with your API Key and post, delete and do basically everything with your account using code.

Alternatively, there is already a web application for bulk deleting tweets: TweetDelete

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM