Skip to content

Instantly share code, notes, and snippets.

@parkr
Last active September 17, 2023 16:47
  • Star 30 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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()
}
@nabilazzh
Copy link

i make this account just for comment on your post, so please help me...

@krrskl
Copy link

krrskl commented Apr 24, 2020

@Throwaway-MM
Copy link

This doesn't work anymore, I made a new one that works with the current more involved REACT UI:

https://gist.github.com/FocusWho/5a8e74895293eae0071cec612477c72f

@iMaz1n
Copy link

iMaz1n commented Mar 3, 2022

@c0c41n3
Copy link

c0c41n3 commented Jun 13, 2022

// Un retweet

function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
for(var i = 1; i < 500; i++){
document.querySelectorAll('[data-testid="unretweet"]')[0].click()
await sleep(1000)
document.querySelectorAll('[data-testid="unretweetConfirm"]')[0].click()
await sleep(1000)
}

@thesarfo
Copy link

thesarfo commented Feb 7, 2023

// Un retweet

function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } for(var i = 1; i < 500; i++){ document.querySelectorAll('[data-testid="unretweet"]')[0].click() await sleep(1000) document.querySelectorAll('[data-testid="unretweetConfirm"]')[0].click() await sleep(1000) }

Does this still work? How do I use it?

@Golgrax
Copy link

Golgrax commented Feb 12, 2023

// Un retweet
function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } for(var i = 1; i < 500; i++){ document.querySelectorAll('[data-testid="unretweet"]')[0].click() await sleep(1000) document.querySelectorAll('[data-testid="unretweetConfirm"]')[0].click() await sleep(1000) }

Does this still work? How do I use it?

yes it is.

@10ensura
Copy link

10ensura commented Apr 8, 2023

function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
for(var i = 1; i < 500; i++){
document.querySelectorAll('[data-testid="unretweet"]')[0].click()
await sleep(1000)
document.querySelectorAll('[data-testid="unretweetConfirm"]')[0].click()
await sleep(1000)
}

// Un retweet

function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } for(var i = 1; i < 500; i++){ document.querySelectorAll('[data-testid="unretweet"]')[0].click() await sleep(1000) document.querySelectorAll('[data-testid="unretweetConfirm"]')[0].click() await sleep(1000) }

tysm !!

@NukeManDan
Copy link

This was needed for Firefox for me, 100ms :

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

async function unretweet() {
    for(var i = 1; i < 500; i++){
    document.querySelectorAll('[data-testid="unretweet"]')[0].click()
    await sleep(100)
    document.querySelectorAll('[data-testid="unretweetConfirm"]')[0].click()
    await sleep(100)
  }
}

unretweet()

@urstrulyrocky
Copy link

bro i got 1563:5 Uncaught TypeError: Cannot read properties of undefined (reading 'click')
at :5:58
( like this what to do not working in chrome

@urstrulyrocky
Copy link

is this code works in fire fox for sure ?

@veixvv
Copy link

veixvv commented Aug 23, 2023

This is the code I have used today and it works perfectly fine:

(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, i, a) {
            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();
                }
            });
        });
        setTimeout(delTweets, 0);
    };

    delTweets();
})();

Credits to: g-h-0-S-t for providing the code.

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