Visual Username Hider Roblox

Hides your username in browser

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Visual Username Hider Roblox
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Hides your username in browser
// @author       Xavior S
// @license MIT
// @match        https://www.roblox.com/*
// @match        https://*.roblox.com/*
// @grant        none
// ==/UserScript==

(function () {
  'use strict';

  // --- CONFIGURE THESE ---
  const newName = "";             // <-- If you change it roblox will crash
  let originalName = "";     // Do NOT change this or it will break
  // -----------------------
console.log('|RVUC Working 1.0|');

  const selectors = [
    '.text-overflow.age-bracket-label-username.font-caption-header',
    '.font-header-2.dynamic-ellipsis-item',
    '.MuiTypography-root.profile-header-username',
    '.MuiTypography-root.web-blox-css-tss-1sr4lqx-Typography-h1-Typography-root'
  ];

  function replaceUsernameInText(text) {
    if (text && text.includes(originalName)) {
      return text.split(originalName).join(newName);
    }
    return text;
  }

  function replaceUsernameInElement(el) {
    if (!el) return;
    const walker = document.createTreeWalker(el, NodeFilter.SHOW_TEXT, null, false);
    const toChange = [];
    while (walker.nextNode()) {
      const txt = walker.currentNode;
      if (txt.nodeValue && txt.nodeValue.includes(originalName)) {
        toChange.push(txt);
      }
    }
    toChange.forEach(txt => {
      txt.nodeValue = replaceUsernameInText(txt.nodeValue);
    });
  }

  function changeUsernames() {
    if (!originalName) return;


    selectors.forEach(sel => {
      document.querySelectorAll(sel).forEach(el => replaceUsernameInElement(el));
    });


    if (document.title && document.title.includes(originalName)) {
      document.title = replaceUsernameInText(document.title);
    }
  }

  function autoDetectOriginal() {
    if (originalName && originalName.length) return;
    for (const sel of selectors) {
      const el = document.querySelector(sel);
      if (el && el.textContent && el.textContent.trim().length) {
        originalName = el.textContent.trim();
        return;
      }
    }
    if (document.title && document.title.trim().length) {
      originalName = document.title.trim();
    }
  }

  autoDetectOriginal();
  changeUsernames();

  let timer = null;
  const observer = new MutationObserver(() => {
    if (timer) clearTimeout(timer);
    timer = setTimeout(() => {
      autoDetectOriginal();
      changeUsernames();
    }, 50);
  });
  observer.observe(document.body, { childList: true, subtree: true, characterData: true });
})();