x.com DEMO mode

Blur usernames and IDs on X.com for DEMO mode, with hover to reveal or hide

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey 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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name       x.com DEMO mode
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Blur usernames and IDs on X.com for DEMO mode, with hover to reveal or hide
// @author       Grok & https://x.com/scavenger869
// @match        https://x.com/*
// @grant        GM_addStyle
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // 添加CSS样式,控制模糊和悬浮效果
    GM_addStyle(`
        /* 默认模糊效果 */
        button[data-testid="SideNav_AccountSwitcher_Button"] > div:nth-child(2) {
            filter: blur(5px);
            transition: filter 0.3s ease; /* 平滑过渡效果 */
        }

        /* 选项1:鼠标悬浮时移除模糊效果 */
        button[data-testid="SideNav_AccountSwitcher_Button"] > div:nth-child(2):hover {
            filter: blur(0);
        }

        /* 选项2:鼠标悬浮时隐藏元素(注释掉选项1后启用) */
        /*
        button[data-testid="SideNav_AccountSwitcher_Button"] > div:nth-child(2):hover {
            display: none;
        }
        */
    `);

    // 函数:确保元素被正确处理(如果需要额外的JavaScript逻辑)
    function applyBlur() {
        const usernameElements = document.querySelectorAll('button[data-testid="SideNav_AccountSwitcher_Button"] > div:nth-child(2)');
        usernameElements.forEach(element => {
            // 确保元素有模糊效果(CSS已处理,这里可以留空)
            // 如果需要额外的JavaScript逻辑,可以在这里添加
        });
    }

    // 初次运行
    applyBlur();

    // 使用MutationObserver监听页面变化
    const observer = new MutationObserver((mutations) => {
        mutations.forEach(() => {
            applyBlur(); // 每次页面有变化时重新处理
        });
    });

    // 观察整个文档的变化
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
})();