Skip to content

Instantly share code, notes, and snippets.

@whizvox
Last active March 25, 2023 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save whizvox/2c5eb769c29576bdf4173ac2ee58445a to your computer and use it in GitHub Desktop.
Save whizvox/2c5eb769c29576bdf4173ac2ee58445a to your computer and use it in GitHub Desktop.
De-tab Twitter
// ==UserScript==
// @name De-tab Twitter
// @namespace https://whizvox.me
// @version 1.1.1
// @downloadURL https://gist.githubusercontent.com/whizvox/2c5eb769c29576bdf4173ac2ee58445a/raw/38eba91a8c3da6da262de56bcd6ce712e153af04/detabtwt.js
// @description Removes "For You" and "Following" tabs, as well as selecting "Following" upon page load
// @author whizvox
// @match https://twitter.com/home
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @grant none
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// ==/UserScript==
// CHANGELOG
// - 1.1.1 (Jan 19, 2023): Add manual check to prevent script from running on non-home pages
// - 1.1 (Jan 19, 2023): Select "Following" whenever the page loads, since Twitter now selects "For You" on reload
// - 1.0 (Jan 13, 2023): Initial release, removes tabs that say "For You" and "Following"
function removeTopTabs(jNode) {
// for some dumb reason tampermonkey's @match isn't filtering anything, resulting in weird behavior
if (location.href === 'https://twitter.com/home') {
// select the "Following" tab
document.getElementsByClassName('r-1qhn6m8')[1].click();
// Delete the group that contains the "For You" and "Following" tabs
$(".r-1gn8etr")[0].firstChild.children[1].innerHTML = '';
}
}
(function() {
'use strict';
// wait for the tabs to be loaded before doing anything
waitForKeyElements(".r-1gn8etr", removeTopTabs);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment