Created
July 31, 2019 08:24
-
-
Save mikker/a471bfd7e8b010cb519f2ceb9ee011bd to your computer and use it in GitHub Desktop.
Automatically switch (back) to Latest Tweets timeline
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
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