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

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

Per 01-08-2024. Zie de nieuwste versie.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

// ==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.5
// @description  hidden Menu,Grok,Premium subscription,Verified Orgs,#Paris2024,Explore,Notifications,Messages,Bookmarks and Customizable Settings
// @description:ja    清潔なメニュー、Grok、高度なサブスクリプション、認証済み組織、#Paris2024、探索、通知、メッセージ、ブックマーク、およびカスタム設定
// @description:zh-tw 乾淨的 選單、Grok、高級訂閱、已認證組織、#Paris2024、探索、通知、訊息、書籤和可自訂設定
// @description:zh-cn 干净的 选单、Grok、高级订阅、已认证组织、#Paris2024、探索、通知、私信、书签和可自订设定
// @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,
        hideParis2024: 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),
        hideParis2024: GM_getValue('hideParis2024', defaultSettings.hideParis2024),
        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',
            'hideParis2024': 'Hide #Paris2024',
            'settings': 'Settings',
            'saveRefresh': 'Save & refresh',
            'close': 'Close'
        },
        'zh-TW': {
            'hideGrok': '隱藏 Grok',
            'hidePremiumSignUp': '隱藏 高級訂閱',
            'hideSelectors': '隱藏 訂閱訊息',
            'hideVerifiedOrgs': '隱藏 已認證組織',
            'hideExplore': '隱藏 探索',
            'hideNotifications': '隱藏 通知',
            'hideMessages': '隱藏 訊息',
            'hideBookmarks': '隱藏 書籤',
            'hideParis2024': '隱藏 #Paris2024',
            'settings': '設定',
            'saveRefresh': '保存並刷新',
            'close': '關閉'
        },
        'zh-CN': {
            'hideGrok': '隐藏 Grok',
            'hidePremiumSignUp': '隐藏 高级订阅',
            'hideSelectors': '隐藏 订阅消息',
            'hideVerifiedOrgs': '隐藏 已认证组织',
            'hideExplore': '隐藏 探索',
            'hideNotifications': '隐藏 通知',
            'hideMessages': '隐藏 私信',
            'hideBookmarks': '隐藏 书签',
            'hideParis2024': '隐藏 #Paris2024',
            'settings': '设置',
            'saveRefresh': '保存并刷新',
            'close': '关闭'
        },
        'ja': {
            'hideGrok': 'Grokを非表示',
            'hidePremiumSignUp': 'プレミアムサインアップを非表示',
            'hideSelectors': 'サブスクライブメッセージを非表示',
            'hideVerifiedOrgs': '認証済み組織を非表示',
            'hideExplore': '話題を検索を非表示',
            'hideNotifications': '通知を非表示',
            'hideMessages': 'メッセージを非表示',
            'hideBookmarks': 'ブックマークを非表示',
            'hideParis2024': '#Paris2024を非表示',
            '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="hideParis2024Checkbox" ${settings.hideParis2024 ? 'checked' : ''}> ${currentLanguage['hideParis2024']}</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.hideParis2024 = document.getElementById('hideParis2024Checkbox').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('hideParis2024', settings.hideParis2024);
        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) {
        cssRules += '.css-175oi2r.r-1habvwh.r-eqz5dr.r-uaa2di.r-1mmae3n.r-3pj75a.r-bnwqim { display: none !important; }';
    }
    if (settings.hideGrok) {
        cssRules += 'a[href="/i/grok"] { display: none !important; }';
    }
    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.hideParis2024) {
        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);
})();