Raw Source
nascent / Claude.ai Font Changer

// ==UserScript==
// @name Claude.ai Font Changer
// @namespace https://claude.ai/
// @version 0.1
// @description Font changer for https://claude.ai
// @author nascent
// @match https://claude.ai/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=claude.ai
// @updateURL  https://openuserjs.org/meta/nascent/Claude.ai_Font_Changer_Enhanced.meta.js
// @downloadURL https://openuserjs.org/src/scripts/nascent/Claude.ai_Font_Changer.user.js
// @license GPL-3.0-or-later
// @grant none
// ==/UserScript==

(function() {
    'use strict';

    // Function to remove font styling from all elements
    function removeFontStyling() {
        var elements = document.getElementsByTagName('*');
        for (var i = 0; i < elements.length; i++) {
            var element = elements[i];
            element.style.fontFamily = '';
            element.style.fontSize = '';
            element.style.fontWeight = '';
            element.style.fontStyle = '';
            element.style.textDecoration = '';
            element.style.textTransform = '';
            element.style.letterSpacing = '';
            element.style.lineHeight = '';
            element.style.textShadow = '';
        }
    }

    function replaceStyle() {
        var style = document.createElement('style');
        style.type = 'text/css';
        var cssStyles = `
            * {
                font-family: 'Roboto', sans-serif !important;
            }
            .font-styrene, .font-serif, .font-sans-serif, .font-system {
                font-family: 'Roboto', sans-serif !important;
            }
            :root {
                --font-styrene-b: 'Roboto', sans-serif !important;
                --font-tiempos: 'Roboto', sans-serif !important;
                --font-serif: 'Roboto', sans-serif !important;
                --font-sans-serif: 'Roboto', sans-serif !important;
                --font-system: 'Roboto', sans-serif !important;
            }
        `;
        style.appendChild(document.createTextNode(cssStyles));
        document.head.appendChild(style);
    }

    // Wait for the DOM to fully load before applying changes
    document.addEventListener('DOMContentLoaded', function() {
        removeFontStyling();
        replaceStyle();
    });

    // Enhance the MutationObserver to watch for more types of changes
    var observer = new MutationObserver(function() {
        removeFontStyling();
        replaceStyle();
        // Update CSS directly instead of individual element styles
        var style = document.querySelector('style#customFontStyle');
        if (!style) {
            style = document.createElement('style');
            style.id = 'customFontStyle';
            document.head.appendChild(style);
        }
        style.textContent = `
            * {
                font-family: 'Roboto', sans-serif !important;
            }
        `;
    });

    var config = { childList: true, subtree: true, attributes: true, characterData: true };
    observer.observe(document.body, config);
})();