Skip to content

Instantly share code, notes, and snippets.

@David256
Created October 25, 2024 14:14
Show Gist options
  • Save David256/c3261c8b2e4087a00efcb73c6dabdad0 to your computer and use it in GitHub Desktop.
Save David256/c3261c8b2e4087a00efcb73c6dabdad0 to your computer and use it in GitHub Desktop.
Javascript to automatically translate tweets
window.translator = setInterval(() => {
document.querySelectorAll('[data-testid="tweetText"][lang="en"]').forEach(tweetText => {
const parent = tweetText.parentNode;
const translateButton = parent.querySelector('button span');
if (translateButton && translateButton.textContent.includes("Traducir post")) {
translateButton.closest('button').click();
console.log(translateButton)
tweetText.style.color = "#555";
}
});
}, 4000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment