RoQuotes

Bring back roblox quotes to profiles! Put in your roblox about q"Text you want" to add quotes to your profile. (Only shows if you have the userscript)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         RoQuotes
// @namespace    http://tampermonkey.net/
// @version      2024-03-23
// @description  Bring back roblox quotes to profiles! Put in your roblox about q"Text you want" to add quotes to your profile. (Only shows if you have the userscript)
// @author       lxvdev
// @license      MIT
// @match        https://www.roblox.com/users/*/profile*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=roblox.com
// ==/UserScript==

(function() {
    'use strict';

    // Settings
    var ChangeNameLayout=true
    var NameInParentheses=false
    var HideUsernameIfSameAsDisplayName=false // Not stable, wouldn't recommend using it.
    var DisableQuotes=false // Why would you disable this, right?
    // End of settings

    function injectCSS(css) {
        var styleElement = document.createElement('style');
        styleElement.innerHTML = css;

        document.head.appendChild(styleElement);
    }

    // Thanks Kris Lachance
    // https://www.basedash.com/blog/waiting-for-an-element-to-exist-with-javascript
    function onElementAvailable(selector, callback) {
        const observer = new MutationObserver(mutations => {
          if (document.querySelector(selector)) {
            observer.disconnect();
            callback();
          }
        });

        observer.observe(document.body, { childList: true, subtree: true });
    }

    var NameLayout = `
        .header-names {
            display: flex;
            align-items: end;
        }
        .profile-display-name {
            margin-bottom: 8px;
        }
        .profile-display-name {
            font-size: 16px !important;
        }
        .profile-name-button {
            padding: 0px !important;
        }

        .tooltip-container {
            margin-right: 8px;
            order: 1;
        }
    `;

    if (ChangeNameLayout) {
        injectCSS(NameLayout);
    }

    if (NameInParentheses) {
        onElementAvailable(".profile-display-name", () => {
            var name = document.querySelector('.profile-display-name');
            name.textContent = "(" + name.textContent + ")";
            name.classList.remove("font-caption-body")
        });
    }

    if (HideUsernameIfSameAsDisplayName) {
        onElementAvailable(".profile-display-name", () => {
            var name = document.querySelector('.profile-display-name');
            var displayname = document.querySelector('.profile-name');

            if (name.textContent.substring(1) === displayname.textContent) {
                name.style.display = 'none';
            }
        });
    }

    if (!DisableQuotes) {
        // Quote handle
        onElementAvailable(".header-names", () => {
            // Create quote div
            var quotesDiv = document.createElement('div');
            quotesDiv.className = "header-quote text";

            // Insert quote div
            var namesDiv = document.querySelector(".header-names");
            namesDiv.insertAdjacentElement("afterend", quotesDiv);

            // Set quote content
            onElementAvailable(".profile-about-content-text", () => {
                var profileDesc = document.querySelector('.profile-about-content-text');

                var regex = /\n*q"([^"]*)"/;

                var match = profileDesc.textContent.match(regex);

                if (match && match.length > 1) {
                    var extractedText = match[1];
                    quotesDiv.textContent = '"' + extractedText + '"';
                    profileDesc.textContent = profileDesc.textContent.replace(regex, '');
                } else {
                    //do smth
                }
            });
        })
    }
})(); // Welcome to the end of the script! What brings you here?