MathJax for Reddit

Enables MathJax on reddit for the TeXtheWorld delimiters [; ... ;].

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name MathJax for Reddit
// @author David Hansen & James Edward Lewis II
// @namespace greasyfork.org
// @version 0.2
// @description Enables MathJax on reddit for the TeXtheWorld delimiters [; ... ;].
// @match https://*.reddit.com/*
// @license MIT
// @grant unsafeWindow
// @run-at document-start
// @copyright 2026
// ==/UserScript==
(function (window, document, undefined) {
  'use strict';
  if (window.MathJax === undefined) {
    var script = document.createElement('script'), cscript = document.createElement('script'),
      head = document.getElementsByTagName('head')[0], config, doMathJax;
    script.type = "text/javascript";
    // script.src = 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML';
    // script.src = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS_HTML';
    script.src = 'https://cdn.jsdelivr.net/npm/mathjax@4/tex-mml-chtml.js';
    config = 'MathJax.Hub.Config({ ' + 'extensions: ["tex2jax.js"], ' + 'tex2jax: { skipTags: ["script","noscript","style","textarea"],inlineMath: [ ["[;", ";]"] ], displayMath: [["[(;",";)]"]], processEscapes: true }, ' + 'jax: ["input/TeX", "output/HTML-CSS"] ' + ' }); ' + 'MathJax.Hub.Startup.onload(); ';
    if (window.opera) cscript.innerHTML = config;
    else cscript.text = config;
    head.appendChild(script);
    doMathJax = function doMathJax() {
        if (window.MathJax === undefined) window.setTimeout(doMathJax, 4);
        else head.appendChild(cscript) && window.MathJax.Hub.Queue(['Typeset', window.MathJax.Hub]);
    };
    doMathJax();
  } else window.MathJax.Hub.Queue(['Typeset', window.MathJax.Hub]);
})(unsafeWindow, document);