Skip to content

Instantly share code, notes, and snippets.

@mogery
Created November 2, 2022 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mogery/b0808762c2fffe5ec4d430d5cf216d45 to your computer and use it in GitHub Desktop.
Save mogery/b0808762c2fffe5ec4d430d5cf216d45 to your computer and use it in GitHub Desktop.
View Latest Tweets (Tampermonkey Userscript)
// ==UserScript==
// @name View Latest Tweets
// @namespace https://mogery.me/
// @version 1.0
// @description Automatically switches Twitter timeline to Latest Tweets.
// @author mogery
// @match https://twitter.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
window.onload = () => {
console.log("[WLT] Checking for button...");
let topBtn = document.querySelector('div[aria-label="Top Tweets on"]');
if (topBtn) {
console.log("[WLT] Button found!");
topBtn.click();
setTimeout(() => {
document.querySelector('div[data-testid="Dropdown"]').children[1].click();
}, 100);
} else console.warn("[WLT] Button not found.");
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment