Disable the "For you" timeline

Disable that annoying "For you" timeline!

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Disable the "For you" timeline
// @namespace    https://typeling1578.dev
// @version      1.0.1
// @description  Disable that annoying "For you" timeline!
// @author       typeling1578
// @match        https://twitter.com/*
// @match        https://mobile.twitter.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @grant        none
// @license      MPL-2.0
// ==/UserScript==

(function() {
    'use strict';

    const observer = new MutationObserver(function (mutations) {
        if (location.pathname !== "/home") return;

        const navigations = document.querySelectorAll(
            `[data-testid="primaryColumn"] [role="navigation"] [role="presentation"] [role="tab"][href="/home"],
            [data-testid="TopNavBar"] [role="navigation"] [role="presentation"] [role="tab"][href="/home"]` // mobile layout
        );
        if (navigations.length === 0) return;

        const recommended_tab = navigations[0];
        const follows_tab = navigations[1];

        recommended_tab.style.display = "none";

        if (recommended_tab.getAttribute("aria-selected") === "true") {
            follows_tab.click();
        }
    });
    observer.observe(document.body, {
        subtree: true,
        childList: true,
        attributes: true,
    });
})();