Skip to content

Instantly share code, notes, and snippets.

@qdilmac
Forked from cacheflowe/remove-twitter-likes.js
Created May 24, 2023 16:05
Show Gist options
  • Save qdilmac/4690ca38bf22ea1fe837d8f048b86c99 to your computer and use it in GitHub Desktop.
Save qdilmac/4690ca38bf22ea1fe837d8f048b86c99 to your computer and use it in GitHub Desktop.
Remove your Twitter likes
// [Updated 2021-01-18 w/new selectors]
// go to your account Likes page and run this in the console:
function scrollToLoadMore() {
// keep scrolling if twitter tries to stop loading more.
// scroll up, then down to force infinite load.
window.scrollTo(0, 0);
setTimeout(function() {
window.scrollBy(0, 9999999999);
}, 200);
}
function removeTweet(tweetEl) {
// show it
tweetEl.style.backgroundColor = 'rgba(255,0,0,0.5)';
tweetEl.scrollIntoView();
window.scrollBy(0, -150);
// remove it
setTimeout(function() {
tweetEl.parentNode.removeChild(tweetEl);
}, 750);
}
function removeFav() {
let buttonEl = document.querySelector('[data-testid="unlike"]');
if(buttonEl) {
let tweetEl = buttonEl.closest('article');
if(tweetEl) {
buttonEl.click();
removeTweet(tweetEl);
}
} else {
console.log('No Tweets found');
scrollToLoadMore();
}
}
let unfavInterval = setInterval(removeFav, 1500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment