BoursoBank My BluroBank

Hide numbers on the whole page

// ==UserScript==
// @name         BoursoBank My BluroBank
// @namespace    http://tampermonkey.net/
// @version      2.1
// @description  Hide numbers on the whole page
// @author       Michel Marchand
// @licence      MIT
// @match        https://clients.boursobank.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=boursobank.com
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // Add CSS for the switch
    const style = document.createElement('style');
    style.innerHTML = `
        #floatingSwitch {
            position: fixed;
            bottom: 20px;
            right: 20px;
            width: 60px;
            height: 30px;
            background-color: #4caf50;
            border-radius: 15px;
            display: flex;
            align-items: center;
            padding: 5px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            cursor: pointer;
            z-index: 1000;
        }
        #switchHandle {
            width: 24px;
            height: 24px;
            background-color: white;
            border-radius: 50%;
            transition: transform 0.3s ease;
        }
        #floatingSwitch.on {
            background-color: #4caf50;
        }
        #floatingSwitch.on #switchHandle {
            transform: translateX(30px);
        }
        #floatingSwitch.off {
            background-color: #ccc;
        }
    `;
    document.head.appendChild(style);

    // Create the switch container
    const switchContainer = document.createElement('div');
    switchContainer.id = 'floatingSwitch';
    switchContainer.className = 'on'; // Default state is "on"

    // Create the switch handle
    const switchHandle = document.createElement('div');
    switchHandle.id = 'switchHandle';

    // Append the handle to the switch container
    switchContainer.appendChild(switchHandle);

    // Function to blur numbers on the page
    function blurNumbers() {
        document.querySelectorAll(":not(script):not(style):not(textarea):not(input):not([contenteditable]):not([tabindex]):not([aria-hidden])")
            .forEach(element => {
                const text = element.textContent.trim();
                if (/^−?\s*\d{1,3}(?:[.,\s]\d{3})*(?:[.,]\d+)\s*€?$/.test(text)) {
                    element.style.filter = "blur(1.5rem)";
                }
            });
    }

    // Function to remove the blur effect
    function unblurNumbers() {
        document.querySelectorAll("*").forEach(element => {
            element.style.filter = ""; // Reset the blur effect
        });
    }

    // Wait for the page to fully load before applying blur
    window.addEventListener('load', () => {
        blurNumbers(); // Apply the blur effect by default
    });

    // Add event listener to toggle state and apply behavior
    switchContainer.addEventListener('click', () => {
        if (switchContainer.classList.contains('off')) {
            switchContainer.classList.remove('off');
            switchContainer.classList.add('on');
            blurNumbers(); // Enable blur when switch is "on"
            console.log('Switch is ON');
        } else {
            switchContainer.classList.remove('on');
            switchContainer.classList.add('off');
            unblurNumbers(); // Disable blur when switch is "off"
            console.log('Switch is OFF');
        }
    });

    // Append the switch to the body
    document.body.appendChild(switchContainer);
})();