X (Twitter) Remove Subscription Prompts

Removes the "Premium", "Business", "Ads", "Monetization" and "Upgrade" tabs/ads/banners on desktop and mobile devices. This is strictly meant for non-subscribers.

当前为 2025-04-23 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        X (Twitter) Remove Subscription Prompts
// @namespace   github.com/mirbyte
// @match       *://x.com/*
// @match       *://twitter.com/*
// @license     MIT
// @grant       none
// @version     1.55 // Incrementing version number
// @author      mirbyte
// @description Removes the "Premium", "Business", "Ads", "Monetization" and "Upgrade" tabs/ads/banners on desktop and mobile devices. This is strictly meant for non-subscribers.
// @icon        https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// ==/UserScript==



(function () {
    'use strict';

    function hideBanners() {
        // Premium and Upgrade tabs
        const premiumBanner = document.querySelector('[data-testid="premium-signup-tab"], [aria-label="Premium"], a[href="/i/premium_sign_up"]');
        if (premiumBanner) {
            premiumBanner.remove();
        }

        // Business tab
        const businessBanner = document.querySelector('[data-testid="vo-signup-tab"], [aria-label="Business"], a[href="/i/verified-orgs-signup"]');
        if (businessBanner) {
            businessBanner.remove();
        }

        // Ads tab mobile
        const adsBanner = document.querySelector('a[href="https://ads.x.com/?ref=gl-tw-tw-twitter-ads-rweb"]');
        if (adsBanner) {
            adsBanner.remove();
        }

        // Monetization tab mobile
        const monetizationBanner = document.querySelector('a[href="/i/monetization"]');
        if (monetizationBanner) {
            monetizationBanner.remove();
        }

        // Upgrade banner mobile
        const mobileUpgradeBanner = document.querySelector('.css-175oi2r.r-dnmrzs a[href="/i/premium_sign_up"]');
        if (mobileUpgradeBanner) {
            mobileUpgradeBanner.remove();
        }

        // 1.52
        // "Go ad-free with Premium+"
        const premiumPlusPrompt = document.querySelector('div[data-testid="cellInnerDiv"] div[data-testid="inlinePrompt"]');
        if (premiumPlusPrompt) {
            premiumPlusPrompt.remove();
        }


        // 1.53
        // found at the right side of the page
        const verifiedBanner = document.querySelector('aside[aria-label="Get Verified with a blue check"]');
        if (verifiedBanner) {
            verifiedBanner.remove();
        }
        // came after posting a reply
        const fullscreenPopup = document.querySelector('div[data-testid="sheetDialog"]');
        if (fullscreenPopup) {
            fullscreenPopup.remove();
        }

        // Premium subscription ad in right sidebar
        const premiumSidebarAd = document.querySelector('aside[aria-label="Subscribe to Premium"]');
        if (premiumSidebarAd) {
            premiumSidebarAd.remove();
        }
	
	//1.55
        // New Premium subscription ad in right sidebar (super-upsell)
        const superUpsellBanner = document.querySelector('div[data-testid="super-upsell-UpsellCardRenderProperties"]');
        if (superUpsellBanner && superUpsellBanner.parentElement && superUpsellBanner.parentElement.parentElement) {
             superUpsellBanner.parentElement.parentElement.remove();
        }


    }

    // run
    hideBanners();
    const observer = new MutationObserver((mutations) => {
        mutations.forEach(() => {
            hideBanners();
        });
    });
    observer.observe(document.body, { subtree: true, childList: true });
})();