Skip to content

Instantly share code, notes, and snippets.

@aymericbeaumet
Last active September 6, 2024 12:39
Show Gist options
  • Save aymericbeaumet/d1d6799a1b765c3c8bc0b675b1a1547d to your computer and use it in GitHub Desktop.
Save aymericbeaumet/d1d6799a1b765c3c8bc0b675b1a1547d to your computer and use it in GitHub Desktop.
[Recipe] Delete all your likes/favorites from Twitter

Ever wanted to delete all your likes/favorites from Twitter but only found broken/expensive tools? You are in the right place.

  1. Go to: https://twitter.com/{username}/likes
  2. Open the console and run the following JavaScript code:
setInterval(() => {
  for (const d of document.querySelectorAll('div[data-testid="unlike"]')) {
    d.click()
  }
  window.scrollTo(0, document.body.scrollHeight)
}, 1000)
@WizardOfOoo
Copy link

I combined some of the above to make this:
Was slow, and didn't have much action on the screen, but it worked.
Chrome / Win 10

setInterval(() => {
for (const d of document.querySelectorAll('div[data-testid="unlike"]')) {
d.click()
}
window.scrollTo(0, window.pageYOffset+300)
}, 10000)

@dcole819
Copy link

dcole819 commented Aug 1, 2022

How do I remove the code??? My Twitter has been acting up since I did this I want it back to normal please help

@kyllian-vssr
Copy link

Working nice today.

@dcole819
Copy link

dcole819 commented Aug 3, 2022

It’s unliking things but it still shows up in my likes just without the heart…anyway to remove the code???

@partsp
Copy link

partsp commented Aug 10, 2022

still can't get it to work. it deletes the tweets but then they come back

@nonononono9
Copy link

Works for a bit and then stops, most likely because of the API but then everything it unfavorites comes back. Which 100% defeats the purpose of this.

@kyllian-vssr
Copy link

kyllian-vssr commented Aug 15, 2022

It’s unliking things but it still shows up in my likes just without the heart…anyway to remove the code???

@dcole819, CTRL+F5 or MAJ+F5 to stop the scripts correctly.

Sometime the API will block you for some minutes or hours if you have mass likes to "remove". 😁

still can't get it to work. it deletes the tweets but then they come back

@partsp same here, just got blocked by API because of too much tweet. retry later. ^^

@MBUMILA
Copy link

MBUMILA commented Sep 4, 2022

It worked! thanks

Copy link

ghost commented Sep 11, 2022

I'm not so good with Javascript - does anyone know how to modify this to unlike Tweets which contain a certain phrase?- eg only unlike Tweets containing the phrase 'boiled eggs'.

@dystorwell
Copy link

dystorwell commented Sep 26, 2022

hello there.
I don't know why but it doesn't work. here's a screenshot of the error.
it worked for a hundred of likes and then stopped.
keep in mind I don't know anything about java.
have a good day :)

Schermata 2022-09-26 alle 21 18 17

edit. worked, then all my likes came back, including the ones I unliked before using this...

@ChitranshuV
Copy link

ChitranshuV commented Oct 12, 2022

setInterval(() => { for (const d of document.querySelectorAll('div[data-testid="unlike"]')) { d.click() } window.scrollTo(0, document.body.scrollHeight) }, 10000)

setInterval 5000 did not work on me. If you have more than 2000 likes, like me. Try 10000 for setInterval, it worked.

Anyway, thanks!

Working for me as of 12th Oct 2022. The only issue is that it starts throwing errors like api/graphql after some time. I take 5 mins break and restart it and it works great. There is rate limit of 900 requests every 15 minutes. https://developer.twitter.com/en/docs/twitter-api/rate-limits

Is there any code similarly for deleting tweets&repllies ??

@Kirytah
Copy link

Kirytah commented Oct 16, 2022

I haven't found any. If you find one please let me know.

@mscdo
Copy link

mscdo commented Nov 11, 2022

It worked for a moment, but as others said, the tweets come back. Still finding an answer to that.

@WizardOfOoo
Copy link

setInterval(() => { for (const d of document.querySelectorAll('div[data-testid="unlike"]')) { d.click() } window.scrollTo(0, document.body.scrollHeight) }, 10000)
setInterval 5000 did not work on me. If you have more than 2000 likes, like me. Try 10000 for setInterval, it worked.
Anyway, thanks!

Working for me as of 12th Oct 2022. The only issue is that it starts throwing errors like api/graphql after some time. I take 5 mins break and restart it and it works great. There is rate limit of 900 requests every 15 minutes. https://developer.twitter.com/en/docs/twitter-api/rate-limits

Is there any code similarly for deleting tweets&repllies ??

https://tweetdelete.net/

@lionbytes
Copy link

lionbytes commented Nov 13, 2022

setInterval(() => { for (const d of document.querySelectorAll('div[data-testid="unlike"]')) { d.click() } window.scrollTo(0, document.body.scrollHeight) }, 10000)
setInterval 5000 did not work on me. If you have more than 2000 likes, like me. Try 10000 for setInterval, it worked.
Anyway, thanks!

Working for me as of 12th Oct 2022. The only issue is that it starts throwing errors like api/graphql after some time. I take 5 mins break and restart it and it works great. There is rate limit of 900 requests every 15 minutes. https://developer.twitter.com/en/docs/twitter-api/rate-limits

Is there any code similarly for deleting tweets&repllies ??

I modified the code a while ago. It worked for me, you just need to run it and go do something while it deletes the tweets:
https://gist.github.com/lionbytes/2e8ad01d0ec318354aa5e95b746c7e54

@osmanbowser
Copy link

Works on Chrome! Thanks!

@chriiisclm
Copy link

chriiisclm commented Nov 18, 2022

nice still works on chrome, tab should be open tho.

@qoqnus13
Copy link

Hi,
How can I limit this code to a time period or a username? I don't want all likes to be removed and only want to remove the likes of a particular account

@dafunks
Copy link

dafunks commented Nov 28, 2022

Just so you all know, if you use GreaseMonkey you can easily do this with a script:
https://stackoverflow.com/questions/64863099/deleting-tweets-with-js-console/71333246#71333246 and it works really well.

@abdessalaam
Copy link

abdessalaam commented Dec 15, 2022

Would anyone please share the latest snippet? (15 Dec 2022 doesn't seem to be deleting likes...) - Thank you!
EDIT (18/12/22): The script might actually be working: it removes the "hearts" but the liked tweets still stay in place, so I was a bit confused.

@briocon7
Copy link

I have 13 likes on my account that i can't get rid of. I also can't see them. I assume these likes are from suspended twitter accounts. But i don't know for sure. I tried running the code but it didn't change anything. Any idea how to get rid of those invisible likes?

@plambrechtsen
Copy link

FYI for anyone who happens across this gist, there is a limit of 1000 likes / unlikes per day and older liked tweets don't show up as "liked" on your timeline, so you need to like and unlike them to actually remove them.
I am using semiphemeral to remove the likes and retweets.
As per https://github.com/micahflee/semiphemeral#deleting-old-likes

@bobmagicii
Copy link

bobmagicii commented Dec 30, 2022

the OG post is still working for me on the 30th of dec 2022. doing it in batches of 900 due to the rate limit.

i think a lot of people seeing it not work are seeing cache. the current iteration of their site uses stupid amounts of local cache in addition to server side stuff. a hard refresh (shift+refresh) usually clears it. also deleting my tweets with another script, my counter still says 41 even though there are 1. and yesterday it still said 83. so that was more of their server side cache i think and maybe a week from now it'll be a different lower number.

also i think if you posted in "communities" those count as posts but are not searchable by anything on their system. i was semi active in the php community and there seems to be no way to even manually find those posts to hand delete.

if you're rooting around the dev console to use this you can kinda see how absolutely bad their app is. cors violations for days lmao.

another final note if you do hit the api rate limit, and hit it too hard, the rest of the ui will take a dump. if you hit the like delete rate limit and refresh there is a chance it will say you still have 300 likes, but "you dont have any likes yet" for a while, because the api just so angry. that only happened once so far though. it can also happen if you've blocked accounts. you'll have to unblock and unmute them.

@7jmoran
Copy link

7jmoran commented Jan 5, 2023

Screen Shot 2023-01-04 at 10 55 00 PM

Hello!

I hope those who see this are having a great week. I used the script to mass delete likes, and it was working well until it broke. I guess I did it too quickly and reached the limit. If anyone, absolutely anyone, can help me figure out how to fix this so that my likes will reappear so that I can continue deleting likes (carefully this time), I will be eternally grateful. Please. I am desperate. I am afraid that I have ruined Twitter forever. As you can see, it says that I have not liked anything yet, but I have over 5K likes.

Thank you!

@Jsdfngjkds
Copy link

i have the same problem, the no. of tweets is 300 but it says on the likes tab You don’t have any likes yet
. ANY HELP?

@bobmagicii
Copy link

bobmagicii commented Jan 8, 2023

every weekend i have to go back to twitter and more likes are there. its almost like it takes their system forever to dig them out of super old archive. and if i unlike like 20 of them, while still staring at more and refresh all of them will vanish. until next weekend again. im down to 291 now.

you just have to keep on keeping on.

@10ensura
Copy link

10ensura commented Jan 18, 2023

by favorite, you mean bookmarks yes or no ? thats can be usefull for myself if yes.

@jbreckmckye
Copy link

It's hard to say what the deal is with Twitter right now. Since the takeover it seems increasingly unstable. A lot of non-core things are apparently silently broken

@gomz404
Copy link

gomz404 commented Jan 23, 2023

thankyou sir :) worked your all script ,

@allbombs
Copy link

Thanks for sharing this.
It removed 5k likes, but now i'm stuck at 4k? It appears around 2018 is when the above script stopped working.

It's been 36 hours and stuck

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