-
-
Save antlionguard/a1be44823d552fe378660fcaa37b0736 to your computer and use it in GitHub Desktop.
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); |
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}
Helo @antlionguard
your code is working for me, but sometimes the script runs an error because the delete button can't click.
I try with my code:
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');
}, 1000);
And gotcha! it works mannnn~
Thank you for your repository!
I hope your day will be nicely