nileshtrivedi / Disable "For You" Tab on X.com

// ==UserScript==
// @name         Disable "For You" Tab on X.com
// @namespace    http://tampermonkey.net/
// @version      0.7
// @description  Automatically switch to the "Following" tab and hide the "For You" tab on X.com with a delay
// @author       nileshtrivedi
// @match        https://twitter.com/*
// @match        https://x.com/*
// @grant        none
// @license MIT 
// ==/UserScript==

(function() {
    'use strict';

    // function to switch to "Following" tab by filtering <a> tags in <nav>
    function switchToFollowing() {
        document.querySelectorAll('nav a').forEach(link => {
            if (link.innerText === "Following") {
                link.click();
            }
        });
    }

    // function to hide "For You" tab by filtering <a> tags in <nav>
    function hideForYou() {
        document.querySelectorAll('nav a').forEach(link => {
            if (link.innerText === "For you") {
                link.style.display = 'none';
            }
        });
    }

    // wait for the page to load, then execute the functions with a 3-second delay
    window.addEventListener('load', function() {
        setTimeout(function() {
            switchToFollowing();
            hideForYou();
        }, 3000); // 3-second delay
    });

})();