Skip to content

Instantly share code, notes, and snippets.

@parkr
Last active April 4, 2024 20:19
Show Gist options
  • Star 30 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • 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()
}
@wesamlibya
Copy link

I have used this script and it has been working for a while, do you have any of yours working for it?

@M-YasirGhaffar
Copy link

^ modified the previous code to also "undo retweets"

(function () {
  var delTweets = function () {
    var tweetsRemaining = document.querySelectorAll('[role="heading"]+div')[1]
      .textContent;
    console.log("Remaining: ", tweetsRemaining);
    window.scrollBy(0, 10000);
    document
      .querySelectorAll('[aria-label="More"]')
      .forEach(function (v, _, _) {
        v.click();
        document.querySelectorAll("span").forEach(function (v2, i2, a2) {
          if (v2.textContent === "Delete") {
            v2.click();
            document
              .querySelectorAll('[data-testid="confirmationSheetConfirm"]')
              .forEach(function (v3, i3, a3) {
                v3.click();
              });
          } else {
            document.body.click();
          }
        });
      });
    document
      .querySelectorAll('[data-testid="unretweet"]')
      .forEach(function (v, _, _) {
        v.click();
        document
          .querySelectorAll('[data-testid="unretweetConfirm"]')
          .forEach(function (v2, _, _) {
            v2.click();
          });
      });
    setTimeout(delTweets, 0);
  };

  delTweets();
})();

you may need to refresh the page and restart the script every so often since it seems twitter rate limits loading tweets

now longer work for likes

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