Dynamic and Static Text Replacer for voxiom.io

Replace specified text on voxiom.io, including static and dynamic content

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

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         Dynamic and Static Text Replacer for voxiom.io
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  Replace specified text on voxiom.io, including static and dynamic content
// @author       You
// @match        https://voxiom.io/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Define the text to search for and replace with
    const searchterm = 'yourName';
    const replaceterm = 'customName';

    // Function to escape special characters in the search term for use in RegExp
    function escapeRegExp(string) {
        return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
    }

    // Function to replace text in a given node
    function replaceTextInNode(node) {
        if (node.nodeType === Node.TEXT_NODE) {
            // Skip script and style tags to avoid breaking the page
            if (node.parentNode && node.parentNode.tagName !== 'SCRIPT' && node.parentNode.tagName !== 'STYLE') {
                node.nodeValue = node.nodeValue.replace(new RegExp(escapeRegExp(searchterm), 'g'), replaceterm);
            }
        } else if (node.nodeType === Node.ELEMENT_NODE) {
            // Handle input elements
            if (node.tagName === 'INPUT' && ['text', 'search', 'password', 'email', 'url'].includes(node.type)) {
                node.value = node.value.replace(new RegExp(escapeRegExp(searchterm), 'g'), replaceterm);
            }
            // Recurse into child nodes
            node.childNodes.forEach(replaceTextInNode);
        }
    }

    // Function to perform replacement on the entire document
    function replaceAllText() {
        replaceTextInNode(document.body);
    }

    // Run initial replacement after a short delay to ensure DOM is fully loaded
    setTimeout(replaceAllText, 1000);

    // Set up MutationObserver to handle dynamic content
    const observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            mutation.addedNodes.forEach(function(node) {
                replaceTextInNode(node);
            });
        });
    });

    // Configure observer to watch for changes in the entire document
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
})();