Greasy Fork is available in English.

Better X-perience

A collection of improvements to the Twitter experience, removing all AI from the site, removing premium being shot down your throat and more. You can edit it to turn off what you don't want.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name        Better X-perience
// @namespace   http://tampermonkey.net/
// @version     1.0.9
// @author      TheSigmaArts
// @match       https://x.com/*
// @match       https://twitter.com/*
// @icon        https://x.com/favicon.ico
// @grant       none
// @license     GPL-3.0-or-later
// @description A collection of improvements to the Twitter experience, removing all AI from the site, removing premium being shot down your throat and more. You can edit it to turn off what you don't want.
// ==/UserScript==

//CSS INJECTION
(function() {
  let css = `
  /*GENERAL*/
  /*Removing Second Home in sidebar*/
  [aria-label="Home"], [aria-label="Home (New unread posts)"] {display: none !important;}
  /*Removing LISTS option in sidebar*/
  [role="link"][href*="list"], [role="menuitem"][href*="list"] {display: none !important;}
  /*Removing BUSINESS options*/
  [aria-label="Business"], div:has(>a[href="/i/verified-orgs-signup"]), [data-testid="Dropdown"] a[href^="https://business.x.com"]{display: none !important;}
  /*Removing Business from landing page*/
  [aria-label="Footer"] div:has(a[href^="https://business.x.com"]){display: none !important;}
  /*Removing Marketing from landing page*/
  [aria-label="Footer"] div:has(a[href="https://marketing.x.com"]){display: none !important;}
  /*Removing JOBS option in sidebar*/
  nav [href*='jobs']{display: none !important;}
  /*Removing Careers from landing page*/
  [aria-label="Footer"] div:has(a[href="https://careers.x.com"]){display: none !important;}
  /*Removing VERIFIED ORGANIZATION option in sidebar*/
  nav [href*='orgs']{display: none !important;}
  /*Removing WHAT'S HAPPENING bar in sidebar*/
  [aria-label="Trending"] div div:has([role="region"]){display: none !important;}
  /*Removing LIVE NOW bar in sidebar*/
  [aria-label="Trending"] div div:has([data-testid="placementTracking"]){display: none !important;}
  /*Removing Prompts from feed*/
  [data-testid="cellInnerDiv"]:has([data-testid="inlinePrompt"]){display: none !important;}
  /*Removing Creators For You choice*/
  [role="navigation"]:has([href="/i/connect_people?is_creator_only=true"]){display: none !important;}

  /*PREMIUM*/
  /*Removing ANALYTICS option in sidebar*/
  nav [href*='analytics']{display: none !important;}
  /*Removing CREATE YOUR SPACE option*/
  [href='/i/spaces/start']{display: none !important;}
  /*Removing CREATOR STUDIO option*/
  [href*='/i/jf/creators/studio']{display: none !important;}
  /*Removing PREMIUM option in sidebar*/
  [aria-label="Premium"]{display: none !important;}
  /*Removing MONETIZATION option in sidebar*/
  [href='/i/monetization']{display: none !important;}
  /*Removing ADS option in sidebar*/
  [href*='ads.x.com']{display: none !important;}
  /*Removing Ads from landing page*/
  [aria-label="Footer"] div:has(a[href^="https://ads.x.com"]){display: none !important;}
  /*Removing Premium Highlights on profiles*/
  [role="presentation"]:has([href*="highlights"]){display: none !important;}
  /*Removing Premium Articles on profiles*/
  [role="presentation"]:has([href*="articles"]){display: none !important;}
  /*Removing Unlock Analytics on profiles*/
  [data-testid="analytics-preview"]{display: none !important;}
  /*Removing Highlight on Your Profile premium option*/
  [data-testid="highlightUpsell"]{display: none !important;}
  /*Remove Promote*/
  [href*='quick_promote_web']{display: none !important;}
  /*Remove Promotions*/
  [data-testid="cellInnerDiv"] div:has(> div):has(> div):has(> div):has(> div):has(> div):has(> img[src*="subscriptions"]){display: none !important;}
  /*Removing Monetization settings*/
  [data-testid="activeRoute"]:has([href='/settings/monetization']){display: none !important;}
  /*Removing Premium settings*/
  [data-testid="activeRoute"]:has([href*='/i/premium']){display: none !important;}
  /*Removing Creator Subscriptions settings*/
  [data-testid="activeRoute"]:has([href='/settings/manage_subscriptions']){display: none !important;}
  /*Removing Subscribe to Premium*/
  [aria-label="Trending"] div div:has([aria-label="Subscribe to Premium"]){display: none !important;}

  /*GROK*/
  /*General removal*/
  [href="https://grok.com/"]{display: none !important;}
  /*Removing GROK option in sidebar*/
  [aria-label="Grok"]{display: none !important;}
  /*Removing Profile Summary on profiles*/
  [aria-label="Profile Summary"], [data-testid="HoverCard"] div div:last-child:has(> button){display: none !important;}
  /*Removing Show Grok Translation on profiles*/
  div:has(> [aria-label="Show translation"]){display: none !important;}
  /*Removing Explain This Post on posts*/
  [aria-label="Grok actions"]{display: none !important;}
  /*Removing Enhance Your Post With Grok on posts*/
  [role="presentation"]:has([aria-label="Enhance your post with Grok"]){display: none !important;}
  /*Removing Generate With Grok on posts*/
  [aria-label="Generate image"]{display: none !important;}
  /*Removing Grok Translation on posts*/
  article div div div div div div:has([aria-label="Show translation"]){display: none !important;}
  /*Removing Create Your Own With Grok on posts*/
  article div div div div div div div div div:has(> div):has(> [href*="https://grok.com/"]){display: none !important;}
  /*Removing Edit Image with Grok*/
  [href^="https://grok.com/imagine"]{display: none !important;}
  /*Removing Grok Chat Drawer*/
  [data-testid="GrokDrawer"]{display: none !important;}
  /*Removing Ask Grok*/
  [data-testid="action-menu-item-ask-grok"]{display: none !important;}
  /*Removing "GET GROK" in startup*/
  [href="https:/*grok.com/"]{display: none !important;}
  /*Removing Grok from landing page*/
  [aria-label="Footer"] div:has(a[href="https://grok.com/"]){display: none !important;}

  /*CLEANER SEARCH*/
  /*Removing Search landing page*/
  [role="region"]:has([aria-label*="Explore"]){display: none !important;}
  /*Removing FOR YOU*/
  [role="presentation"]:has([href*='for_you']){display: none !important;}
  /*Removing TRENDING*/
  [role="presentation"]:has([href*='trending']){display: none !important;}
  /*Removing NEWS*/
  [role="presentation"]:has([href*='news']){display: none !important;}
  /*Removing SPORT*/
  [role="presentation"]:has([href*='sport']){display: none !important;}
  /*Removing ENTERTAINMENT*/
  [role="presentation"]:has([href*='entertainment']){display: none !important;}
  /*Removing LISTS*/
  [role="presentation"]:has([href*='&f=list']){display: none !important;}
  /*Removing VERIFIED*/
  [role="presentation"]:has([href="/notifications/verified"]){display: none !important;}
  /*Removing useless Next button*/
  [aria-label="Home timeline"] [data-testid="ScrollSnap-nextButtonWrapper"]{display: none !important;}
  /*Removing Today's News*/
  [aria-label="Trending"] div div:has([data-testid="news_sidebar"]){display: none !important;}
  `;
  const styleNode = document.createElement("style");
  styleNode.appendChild(document.createTextNode(css));
  (document.querySelector("head") || document.documentElement).appendChild(styleNode);
})();

//REDIRECTION RULES
const checkUrlAndRedirect = () => {
    const currentUrl = window.location.href;
    /*Redirect if in Highlights*/
    if (currentUrl.includes('/highlights')){ window.location.href = currentUrl.replace('/highlights', ""); }
    /*Redirect if in Articles*/
    if (currentUrl.includes('/articles')){ window.location.href = currentUrl.replace('/articles', ""); }
    /*Redirect from any Grok to home*/
    if (currentUrl.includes('/grok')){ window.location.href = "https://x.com"; }
};

//JAVASCRIPT INJECTION
const filterPosts = () => {
    checkUrlAndRedirect();

    let posts = document.querySelectorAll('[data-testid="cellInnerDiv"]');
    const currentUrl = window.location.href;
    const isWithReplies = currentUrl.includes("/with_replies");
    const isSearch = currentUrl.includes("/search?");

    posts.forEach((post, p) => {
        const html = post.innerHTML;
        /*Highlight Confirmed AI Made Posts*/
        if (html.includes('>Made with AI</span>')) { post.style.background = "darkblue"; }
        /*Remove Useless Headings*/
        if (html.includes('>Suggested for you</')) { post.remove(); }
        /*Remove Ads*/
        if (html.includes('>Ad</span>')) { post.remove(); }
        /*Remove Boosted posts*/
        if (html.includes('>Boosted</span>')) { post.remove(); }
        /*Remove Pinned posts in Replies*/
        if (isWithReplies && html.includes('data-testid="socialContext">Pinned')) { post.remove(); }

        /*Remove Who To Follow section in feed*/
        if (html.includes('>Who to follow</')) {
            for (let i = 0; i <= 5 && p + i < posts.length; i++) {
                posts[p + i].style.display = "none";
            }
        }
        /*Remove People section in Top search*/
        if (isSearch && html.includes('>People</span>')) {
            for (let i = 0; i <= 5 && p + i < posts.length; i++) {
                posts[p + i].style.display = "none";
            }
        }
    });
};

// REDIRECTION RULES AT START
checkUrlAndRedirect();
// JAVASCRIPT INJECTION AT START
let debounceTimeout = null;
const observer = new MutationObserver(() => {
    if (debounceTimeout) return;
    debounceTimeout = requestAnimationFrame(() => {
        filterPosts();
        debounceTimeout = null;
    });
});
// JAVASCRIPT INJECTION AT CHANGE
observer.observe(document.body, {
    childList: true,
    subtree: true
});