Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
[Deprecated] A Tampermonkey / Greasemonkey script that turns LaTeX code on page into mathematical symbols using MathJax
// ==UserScript==
// @name TeXify the World MathJax
// @namespace
// @version 1.0
// @description Enables MathJax to process LaTeX on all websites. Based off SOUP (Stack Overflow Unofficial Patch) and
// @include *
// @copyright
// ==/UserScript==
var mathjaxVersion = "";
if ('https:' === location.protocol) {
var mjs = $('script[src^=""]').remove();
var mjEncrypt = "";
if (mjs.length > 0) $.ajax( {
dataType: "script", cache: true,
url: mjs[0].src.replace(mathjaxVersion, mjEncrypt)
} );
mathjaxVersion = mjEncrypt;
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "//" //(mathjaxVersion + "/mathjax/latest/MathJax.js?config=TeX-AMS_HTML");
var 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(); ';
script.text = config;
setTimeout(function () {"use strict"; script.Hub.Queue(["Typeset", script.Hub]); }, 1000);
console.log("The TeX-ification is complete!");
Copy link

schlichtanders commented Feb 9, 2016

Dear goatandsheep,

I tried your script with SLACK, it outputs "The TeX-ification is complete!" on the console, but nothing is rendered.
I tried $x^2$, $$x^2$$, but nothing unfortunately...

Could you provide an example how to use this script?, that would be helpful.

I would be glad if you have some time,

Copy link

igauravsehrawat commented May 30, 2016

I pondered over this line "Enables MathJax to process LaTeX on all websites. Based off SOUP (Stack Overflow Unofficial Patch) and" from the comments, that helped me to get it working.

Copy link

goatandsheep commented May 30, 2016

@schilichtanders It's had trouble rendering on streams, since it compiles the content at page load. If someone knows how to do that, that would be awesome.

Copy link

goatandsheep commented Oct 21, 2017

Copy link

ragaar commented Sep 2, 2018

For the random bypasser that reads the comments:

It's also possible to install a local copy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment