Skip to content

Instantly share code, notes, and snippets.

@mikker
Created July 31, 2019 08:24
Show Gist options
  • Save mikker/a471bfd7e8b010cb519f2ceb9ee011bd to your computer and use it in GitHub Desktop.
Save mikker/a471bfd7e8b010cb519f2ceb9ee011bd to your computer and use it in GitHub Desktop.
Automatically switch (back) to Latest Tweets timeline
function main() {
console.log("tick");
// Find the header signifying current timeline mode
const title = document.querySelector(
'[data-testid="primaryColumn"] h2[role="heading"]'
);
// If it isn't loaded yet, try again in 0.5 secs
if (!title) {
setTimeout(main, 500);
return;
}
// If not matching Home, stop looking
if (title.innerText !== "Home") {
return;
}
// If Home, continue
console.log("Match!");
// Click ✨
document.querySelector('[aria-label="Top Tweets on"]').click();
// Wait 0.5 secs then click "Latest tweets"
setTimeout(() => {
console.log("Click!");
document.querySelector('div[role="menuitem"]').click();
}, 500);
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment