Greasy Fork is available in English.

X/Twitter Clean menu and sidebar (Supports multiple language)

hidden Menu,Grok,Premium subscription,Verified Orgs,other,Explore,Notifications,Messages,Bookmarks and Customizable Settings

اعتبارا من 19-01-2025. شاهد أحدث إصدار.

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 or Violentmonkey 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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         X/Twitter Clean menu and sidebar (Supports multiple language)
// @name:ja      X/Twitter きれいなメニューとサイドバー(多言語対応)
// @name:zh-TW   X/Twitter 乾淨的選單和側邊欄(支持多種語言)
// @name:zh-cn   X/Twitter 干净的选单和侧边栏(支持多种语言)
// @version      1.8
// @description  hidden Menu,Grok,Premium subscription,Verified Orgs,other,Explore,Notifications,Messages,Bookmarks and Customizable Settings
// @description:ja    清潔なメニュー、Grok、高度なサブスクリプション、認証済み組織、他の、探索、通知、メッセージ、ブックマーク、およびカスタム設定
// @description:zh-tw 乾淨的 選單、Grok、高級訂閱、已認證組織、其他、探索、通知、訊息、書籤和可自訂設定
// @description:zh-cn 干净的 选单、Grok、高级订阅、已认证组织、其他、探索、通知、私信、书签和可自订设定
// @license      MIT
// @author       movwei
// @match        https://x.com/*
// @match        https://twitter.com/*
// @grant        GM_registerMenuCommand
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_addStyle
// @namespace https://greatest.deepsurf.us/users/1041101
// ==/UserScript==

(function() {
    'use strict';

    const defaultSettings = {
        hideGrok: true,
        hidePremiumSignUp: true,
        hideSelectors: true,
        hideVerifiedOrgs: true,
        hideother: true,
        hideExplore: false,
        hideNotifications: false,
        hideBookmarks: false,
        hideMessages: false,
    };

    const settings = {
        hideGrok: GM_getValue('hideGrok', defaultSettings.hideGrok),
        hidePremiumSignUp: GM_getValue('hidePremiumSignUp', defaultSettings.hidePremiumSignUp),
        hideSelectors: GM_getValue('hideSelectors', defaultSettings.hideSelectors),
        hideVerifiedOrgs: GM_getValue('hideVerifiedOrgs', defaultSettings.hideVerifiedOrgs),
        hideother: GM_getValue('hideother', defaultSettings.hideother),
        hideExplore: GM_getValue('hideExplore', defaultSettings.hideExplore),
        hideNotifications: GM_getValue('hideNotifications', defaultSettings.hideNotifications),
        hideBookmarks: GM_getValue('hideBookmarks', defaultSettings.hideBookmarks),
        hideMessages: GM_getValue('hideMessages', defaultSettings.hideMessages),
    };

    // 多語言支持
    const language = navigator.language || navigator.userLanguage;
    const languages = {
        'en': {
            'hideGrok': 'Hide Grok',
            'hidePremiumSignUp': 'Hide Premium Sign-up',
            'hideSelectors': 'Hide Subscribe Message',
            'hideVerifiedOrgs': 'Hide Verified Orgs',
            'hideExplore': 'Hide Explore',
            'hideNotifications': 'Hide Notifications',
            'hideMessages': 'Hide Messages',
            'hideBookmarks': 'Hide Bookmarks',
            'hideother': 'Hide other',
            'settings': 'Settings',
            'saveRefresh': 'Save & refresh',
            'close': 'Close'
        },
        'zh-TW': {
            'hideGrok': '隱藏 Grok',
            'hidePremiumSignUp': '隱藏 高級訂閱',
            'hideSelectors': '隱藏 訂閱訊息',
            'hideVerifiedOrgs': '隱藏 已認證組織',
            'hideExplore': '隱藏 探索',
            'hideNotifications': '隱藏 通知',
            'hideMessages': '隱藏 訊息',
            'hideBookmarks': '隱藏 書籤',
            'hideother': '隱藏 其他',
            'settings': '設定',
            'saveRefresh': '保存並刷新',
            'close': '關閉'
        },
        'zh-CN': {
            'hideGrok': '隐藏 Grok',
            'hidePremiumSignUp': '隐藏 高级订阅',
            'hideSelectors': '隐藏 订阅消息',
            'hideVerifiedOrgs': '隐藏 已认证组织',
            'hideExplore': '隐藏 探索',
            'hideNotifications': '隐藏 通知',
            'hideMessages': '隐藏 私信',
            'hideBookmarks': '隐藏 书签',
            'hideother': '隐藏 其他',
            'settings': '设置',
            'saveRefresh': '保存并刷新',
            'close': '关闭'
        },
        'ja': {
            'hideGrok': 'Grokを非表示',
            'hidePremiumSignUp': 'プレミアムサインアップを非表示',
            'hideSelectors': 'サブスクライブメッセージを非表示',
            'hideVerifiedOrgs': '認証済み組織を非表示',
            'hideExplore': '話題を検索を非表示',
            'hideNotifications': '通知を非表示',
            'hideMessages': 'メッセージを非表示',
            'hideBookmarks': 'ブックマークを非表示',
            'hideother': '他のを非表示',
            'settings': '設定',
            'saveRefresh': '保存してリフレッシュ',
            'close': '閉じる'
        },
    };

    const currentLanguage = languages[language] || languages['en'];

    function createSettingsPanel() {
        const panel = document.createElement('div');
        panel.id = 'settingsPanel';
        panel.innerHTML = `
            <div id="settingsPanelContent">
                <h2>${currentLanguage['settings']}</h2>
                <label><input type="checkbox" id="hideGrokCheckbox" ${settings.hideGrok ? 'checked' : ''}> ${currentLanguage['hideGrok']}</label><br>
                <label><input type="checkbox" id="hidePremiumSignUpCheckbox" ${settings.hidePremiumSignUp ? 'checked' : ''}> ${currentLanguage['hidePremiumSignUp']}</label><br>
                <label><input type="checkbox" id="hideSelectorsCheckbox" ${settings.hideSelectors ? 'checked' : ''}> ${currentLanguage['hideSelectors']}</label><br>
                <label><input type="checkbox" id="hideVerifiedOrgsCheckbox" ${settings.hideVerifiedOrgs ? 'checked' : ''}> ${currentLanguage['hideVerifiedOrgs']}</label><br>
                <label><input type="checkbox" id="hideotherCheckbox" ${settings.hideother ? 'checked' : ''}> ${currentLanguage['hideother']}</label><br>
                <label><input type="checkbox" id="hideExploreCheckbox" ${settings.hideExplore ? 'checked' : ''}> ${currentLanguage['hideExplore']}</label><br>
                <label><input type="checkbox" id="hideNotificationsCheckbox" ${settings.hideNotifications ? 'checked' : ''}> ${currentLanguage['hideNotifications']}</label><br>
                <label><input type="checkbox" id="hideMessagesCheckbox" ${settings.hideMessages ? 'checked' : ''}> ${currentLanguage['hideMessages']}</label><br>
                <label><input type="checkbox" id="hideBookmarksCheckbox" ${settings.hideBookmarks ? 'checked' : ''}> ${currentLanguage['hideBookmarks']}</label><br>
                <button id="saveSettingsButton">${currentLanguage['saveRefresh']}</button>
                <button id="closeSettingsButton">${currentLanguage['close']}</button>
            </div>
        `;
        document.body.appendChild(panel);

        document.getElementById('saveSettingsButton').addEventListener('click', saveSettings);

        document.getElementById('closeSettingsButton').addEventListener('click', () => {
            document.getElementById('settingsPanel').style.display = 'none';
        });
    }

    function saveSettings() {
        settings.hideGrok = document.getElementById('hideGrokCheckbox').checked;
        settings.hidePremiumSignUp = document.getElementById('hidePremiumSignUpCheckbox').checked;
        settings.hideSelectors = document.getElementById('hideSelectorsCheckbox').checked;
        settings.hideVerifiedOrgs = document.getElementById('hideVerifiedOrgsCheckbox').checked;
        settings.hideExplore = document.getElementById('hideExploreCheckbox').checked;
        settings.hideNotifications = document.getElementById('hideNotificationsCheckbox').checked;
        settings.hideBookmarks = document.getElementById('hideBookmarksCheckbox').checked;
        settings.hideMessages = document.getElementById('hideMessagesCheckbox').checked;
        settings.hideother = document.getElementById('hideotherCheckbox').checked;

        GM_setValue('hideGrok', settings.hideGrok);
        GM_setValue('hidePremiumSignUp', settings.hidePremiumSignUp);
        GM_setValue('hideSelectors', settings.hideSelectors);
        GM_setValue('hideVerifiedOrgs', settings.hideVerifiedOrgs);
        GM_setValue('hideExplore', settings.hideExplore);
        GM_setValue('hideNotifications', settings.hideNotifications);
        GM_setValue('hideBookmarks', settings.hideBookmarks);
        GM_setValue('hideMessages', settings.hideMessages);
        GM_setValue('hideother', settings.hideother);
        location.reload();
    }

    GM_addStyle(`
        #settingsPanel {
            width: 250px;
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: white;
            border: 1px solid #ccc;
            padding: 20px;
            z-index: 10000;
            display: none;
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
            border-radius: 8px;
        }

        #settingsPanelContent {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            width: 100%;
        }

        #settingsPanel h2 {
            margin: 0 0 15px 0;
            font-size: 18px;
            color: #333;
            text-align: center;
            width: 100%;
        }

        #settingsPanel label {
            margin: 5px 0;
            font-size: 14px;
            color: #333;
        }

        #settingsPanel button {
            margin-top: 10px;
            padding: 8px 15px;
            font-size: 14px;
            color: white;
            background-color: #007BFF;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            width: 100%;
        }

        #settingsPanel button#closeSettingsButton {
            background-color: #6c757d;
        }
    `);

    createSettingsPanel();
    GM_registerMenuCommand(currentLanguage['settings'], () => {
        const panel = document.getElementById('settingsPanel');
        panel.style.display = 'block';
    });

    function addGlobalStyle(css) {
        var head, style;
        head = document.getElementsByTagName('head')[0];
        if (!head) { return; }
        style = document.createElement('style');
        style.type = 'text/css';
        style.innerHTML = css;
        head.appendChild(style);
    }

    var cssRules = '';
    if (settings.hideSelectors) {
    const observer = new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            const elements = document.querySelectorAll('.css-175oi2r.r-1habvwh.r-eqz5dr.r-uaa2di.r-1mmae3n.r-3pj75a.r-bnwqim');
            elements.forEach(element => {
                const parentDiv = element.closest('div');
                if (parentDiv) {
                    parentDiv.remove();
                }
            });
        });
    });

    observer.observe(document.body, { childList: true, subtree: true });
    }
    if (settings.hideGrok) {
        cssRules += `
        a[href="/i/grok"] {
            display: none !important;
        }

        .css-175oi2r.r-1867qdf.r-xnswec.r-13awgt0.r-1ce3o0f.r-1udh08x.r-u8s1d.r-13qz1uu.r-173mn98.r-1e5uvyk.r-ii8lfi.r-40lpo0.r-rs99b7.r-12jitg0 {
            display: none;
        }

        `;
    }
    if (settings.hidePremiumSignUp) {
        cssRules += 'a[href="/i/premium_sign_up"] { display: none !important; }';
    }
    if (settings.hideVerifiedOrgs) {
        cssRules += 'a[href="/i/verified-orgs-signup"] { display: none !important; }';
    }
    if (settings.hideother) {
        cssRules += '.css-175oi2r.r-l00any.r-109y4c4.r-kuekak { display: none; }';
        cssRules += 'a.css-175oi2r.r-5oul0u.r-knv0ih.r-faml9v.r-2dysd3.r-13qz1uu.r-o7ynqc.r-6416eg.r-1ny4l3l.r-1loqt21 { display: none; }';
        cssRules += 'a.css-175oi2r.r-5oul0u.r-1wzrnnt.r-1c4vpko.r-1c7gwzm.r-13qz1uu.r-o7ynqc.r-6416eg.r-1ny4l3l.r-1loqt21 { display: none; }';
    }
    if (settings.hideExplore) {
        cssRules += 'a[href="/explore"] { display: none !important; }';
    }
    if (settings.hideNotifications) {
        cssRules += 'a[href="/notifications"] { display: none !important; }';
    }
    if (settings.hideBookmarks) {
        cssRules += 'a[href="/i/bookmarks"] { display: none !important; }';
    }
    if (settings.hideMessages) {
        cssRules += 'a[href="/messages"] { display: none !important; }';
    }

    addGlobalStyle(cssRules);
})();