TexTelegram

Activa MathJax en la ventana de mensajes de telegram

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey 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.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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        TexTelegram
// @namespace   https://ncordon.github.io/
// @description Activa MathJax en la ventana de mensajes de telegram
// @version     1
// @include     https://web.telegram.org/*
// @grant       none
// @license     WTFPL
// ==/UserScript==


(function(){
    var toRender = document.getElementsByClassName("im_history_scrollable_wrap nano-content")

    if(window.MathJax===undefined){
        var script = document.createElement("script");
        script.type = "text/javascript";
        script.src = "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML";
        var config = 'MathJax.Hub.Config({' + 'extensions: ["tex2jax.js"],' + 
            'tex2jax: { inlineMath: [["$","$"]], displayMath: [["$$","$$"]], processEscapes: true },' +
            'jax: ["input/TeX","output/HTML-CSS"]' + '});' +
            'MathJax.Hub.Startup.onload();';
        
        if (window.opera) {
            script.innerHTML = config
        }
        else {
            script.text = config
        }

        document.getElementsByTagName("head")[0].appendChild(script);

        (doTexTelegram=function(){
            window.setTimeout(doTexTelegram,1000);
            MathJax.Hub.Queue(["Typeset", MathJax.Hub, toRender]);
        })();
    }
    else{
        MathJax.Hub.Queue(["Typeset", MathJax.Hub, toRender]);
    }
})();