Skip to content

Instantly share code, notes, and snippets.

@wwmoraes
Last active September 20, 2025 10:18
Show Gist options
  • Select an option

  • Save wwmoraes/c80cac4c201952cd325c76c7095a3efe to your computer and use it in GitHub Desktop.

Select an option

Save wwmoraes/c80cac4c201952cd325c76c7095a3efe to your computer and use it in GitHub Desktop.
Twitter/X post remover
var skip = 0;
var tweetTexts = [
"@untappd",
"@ Untappd at Home",
"untp.beer/"
];
var removalIntervalHandler = setInterval(() => {
try {
let tweets = Array.from(document.querySelectorAll("[role=article][data-testid=tweet]")).filter(element => tweetTexts.find(text => element.textContent.includes(text)) !== undefined);
console.log("trying option removal... count:", tweets.length, "skip:", skip);
const tweet = tweets.slice(skip).shift();
if (tweet === undefined) {
console.log("no more tweets to remove, stopping");
clearInterval(removalIntervalHandler);
return;
}
let menuToggle = tweet.querySelector("[role=button][aria-label=More]");
if (menuToggle == undefined) {
console.log("tweet menu not found, stopping");
clearInterval(removalIntervalHandler);
return;
}
tweet.scrollIntoView();
menuToggle.click();
setTimeout(() => {
console.log("removing...");
const removeButton = Array.from(document.querySelectorAll('[data-testid=Dropdown] [role=menuitem]')).filter((element) => {
return element.textContent == "Delete";
});
if (removeButton.length == 0) {
console.log("remove button not found, skipping");
skip += 1;
return;
}
removeButton[0].click();
setTimeout(() => {
Array.from(document.querySelectorAll("[data-testid=confirmationSheetDialog] [data-testid=confirmationSheetConfirm]")).forEach(element => element.click());
// scrollTo(0, document.querySelector("[role=main]").scrollHeight);
}, 300);
}, 300);
} catch (err) {
console.error("caught unhandled error, stopping", err);
clearInterval(removalIntervalHandler);
}
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment