Skip to content

Instantly share code, notes, and snippets.

@parkr
Last active August 22, 2024 16:26
Show Gist options
  • Save parkr/d600696478d03d6f9c32 to your computer and use it in GitHub Desktop.
Save parkr/d600696478d03d6f9c32 to your computer and use it in GitHub Desktop.
delete your tweets and un-retweet tweets
// go to https://twitter.com/your-username, and enter the following into the developer console:
for(var i = 1; i < 500; i++){ // just do it a bunch
// Un retweet
document.getElementsByClassName("ProfileTweet-actionButtonUndo")[i].click();
document.getElementsByClassName("js-close")[0].click();
// Delete tweets
document.getElementsByClassName("js-actionDelete")[i].childNodes[1].click();
document.getElementsByClassName("delete-action")[0].click()
}
@thesarfo
Copy link

I used this script over a year ago and now my twitter likes do not show in the likes tab. How do i fix this ?

@ferreira710
Copy link

ferreira710 commented Jun 27, 2024

setting a timeout to prevent browser to crash

(function () {
  var delTweets = function () {
    var tweetsRemaining = document.querySelectorAll('[role="heading"]+div')[1]
      .textContent;
    console.log("Remaining: ", tweetsRemaining);

    var moreButtons = document.querySelectorAll('[aria-label="More"]');
    var deleteCount = 0;

    moreButtons.forEach(function (v) {
      v.click();
      var deleteButtons = document.querySelectorAll("span");
      for (var i = 0; i < deleteButtons.length; i++) {
        if (deleteButtons[i].textContent === "Delete") {
          deleteButtons[i].click();
          document
            .querySelectorAll('[data-testid="confirmationSheetConfirm"]')
            .forEach(function (v3) {
              v3.click();
              deleteCount++;
            });
          break;
        }
      }
      document.body.click();
    });

    var unretweetButtons = document.querySelectorAll('[data-testid="unretweet"]');
    unretweetButtons.forEach(function (v) {
      v.click();
      document
        .querySelectorAll('[data-testid="unretweetConfirm"]')
        .forEach(function (v2) {
          v2.click();
        });
    });

    if (deleteCount === 0) {
      window.scrollBy(0, 1000);
    }

    setTimeout(delTweets, 2000);
  };

  delTweets();
})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment