Last active
September 6, 2023 15:35
-
-
Save antlionguard/a1be44823d552fe378660fcaa37b0736 to your computer and use it in GitHub Desktop.
With this script, you can remove all tweets you are tweeted on Twitter. Don't forget add your nickname to line 9. (The script begins 60 seconds after pasting the code.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const timer = ms => new Promise(res => setTimeout(res, ms)); | |
setInterval(async () => | |
{ | |
// Get all tweets | |
const allTweets = document.querySelectorAll('.css-1dbjc4n.r-18u37iz.r-1wbh5a2.r-13hce6t'); | |
// Filter tweets | |
const filteredTweets = Array.prototype.slice.call(allTweets).filter(x => x.innerText === '@{YOUR_TWITTER_NICKNAME}'); // --> e.g. '@twitter' | |
for (const tweet of filteredTweets) { | |
tweet.scrollIntoView(); | |
// Click three dot and open action menu | |
tweet.parentElement.parentElement.parentElement.parentElement.parentElement.querySelector('div[data-testid="caret"]').click(); | |
await timer(250); | |
// Click delete button | |
document.querySelector('.r-9l7dzd.r-4qtqp9.r-yyyyoo.r-1q142lx.r-1xvli5t.r-1rq6c10.r-dnmrzs.r-bnwqim.r-1plcrui.r-lrvibr').parentElement.parentElement.click(); | |
await timer(250); | |
// Click confirm button | |
document.querySelector('div[data-testid="confirmationSheetConfirm"]').click(); | |
await timer(250); | |
} | |
await window.scrollTo(0, document.body.scrollHeight); | |
}, 60000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
filteredTweets keeps coming out with length 0
I've set my user name at line 9 correctly
and checked allTweets which is populated with elements
and can see my username in innerText - but noticed innerText with name + date in differing formats
hence
const filteredTweets = Array.prototype.slice.call(allTweets).filter(x => x.innerText === '@{YOUR_TWITTER_NICKNAME}');
always has 0 in filteredTweets
so changed to use baseURI
const filteredTweets = Array.prototype.slice.call(allTweets).filter(x => x.baseURI === 'https://twitter.com/{myname}');
and worked your script worked and deleted all tweets
I noticed innerText would include my twitter name and the date - but the format was different from tweet to tweet
some were {name}\n{date}
some were {name}.{date}