MathJax for All

Uses MathJax to properly display LaTeX code, on any site

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name       MathJax for All
// @version    0.4
// @description Uses MathJax to properly display LaTeX code, on any site
// @namespace 1993.uk
// @match https://mail.google.com/*
// @match file:///*
// ==/UserScript==
if (window.MathJax === undefined) {
    var mjscr = document.createElement("script");
    mjscr.type = "text/javascript";
    mjscr.src = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js";
    mjscr.text = 'MathJax.Hub.Config({extensions:["tex2jax.js"],'+"tex2jax:{inlineMath:[['$','$']]"
        +',skipTags:["script","noscript","pre","code"]},jax:["input/TeX","output/CommonHTML"],'
        +'TeX:{extensions:["autoload-all.js","noUndefined.js"]}'
        +'});MathJax.Hub.Startup.onload();';
    document.getElementsByTagName("head")[0].appendChild(mjscr);

    (new MutationObserver(function(mutationsList, observer) {
        let el = [];
        for (const mutation of mutationsList) {
            const node = mutation.addedNodes.item(0);
            if (node === null || node.nodeType !== 1 || node.className == "MathJax_Preview" || node.id.substring(0,7) == "MathJax" || node.className.substring(0,4) == "mjx-" || node.isContentEditable) break;
            if (node.offsetParent !== null && node.innerText != "") el.push(node);
        }
        if (el.length != 0) MathJax.Hub.Queue(["Typeset", MathJax.Hub,el,{}]);
    })).observe(document,{subtree: true, childList: true});
}