Skip to content

Instantly share code, notes, and snippets.

@arshsingh
Forked from goatandsheep/Texify-Mathjax.js
Last active October 22, 2024 20:58
Show Gist options
  • Save arshsingh/bd859d577d998581daff to your computer and use it in GitHub Desktop.
Save arshsingh/bd859d577d998581daff to your computer and use it in GitHub Desktop.

Revisions

  1. arshsingh revised this gist Feb 4, 2016. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion Texify-Mathjax.js
    Original file line number Diff line number Diff line change
    @@ -23,6 +23,8 @@ var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = "//cdn.mathjax.org/mathjax/latest/MathJax.js" //(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 + 'setInterval(function () {"use strict"; MathJax.Hub.Queue(["Typeset", MathJax.Hub]); }, 7000);' // re-render every 7 seconds;
    config += 'function reMathJax() {"use strict"; MathJax.Hub.Queue(["Typeset", MathJax.Hub]);}'
    config += 'var mathJaxIntervalId; window.onload = window.onfocus = function(){ mathJaxIntervalId = setInterval(reMathJax, 5000); }; window.onblur = function(){ clearInterval(mathJaxIntervalId) };'
    script.text = config;
    document.getElementsByTagName("head")[0].appendChild(script);
    console.log("The TeX-ification is complete!");
  2. arshsingh revised this gist Feb 4, 2016. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions Texify-Mathjax.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,6 @@
    // ==/UserScript==
    /*
    var mathjaxVersion = "http://cdn.mathjax.org";
    if ('https:' === location.protocol) {
    var mjs = $('script[src^="http://cdn.mathjax.org/"]').remove();
    var mjEncrypt = "https://c328740.ssl.cf1.rackcdn.com";
    @@ -23,8 +22,7 @@ if ('https:' === location.protocol) {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = "//cdn.mathjax.org/mathjax/latest/MathJax.js" //(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;
    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 + 'setInterval(function () {"use strict"; MathJax.Hub.Queue(["Typeset", MathJax.Hub]); }, 7000);' // re-render every 7 seconds;
    document.getElementsByTagName("head")[0].appendChild(script);
    setTimeout(function () {"use strict"; script.Hub.Queue(["Typeset", script.Hub]); }, 1000);
    console.log("The TeX-ification is complete!");
  3. @goatandsheep goatandsheep revised this gist Dec 15, 2015. No changes.
  4. @goatandsheep goatandsheep revised this gist Oct 17, 2015. No changes.
  5. @goatandsheep goatandsheep created this gist Oct 17, 2015.
    30 changes: 30 additions & 0 deletions Texify-Mathjax.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    // ==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 http://www.math.ucla.edu/~robjohn/math/mathjax.html.
    // @include *
    // @copyright
    // ==/UserScript==
    /*
    var mathjaxVersion = "http://cdn.mathjax.org";
    if ('https:' === location.protocol) {
    var mjs = $('script[src^="http://cdn.mathjax.org/"]').remove();
    var mjEncrypt = "https://c328740.ssl.cf1.rackcdn.com";
    if (mjs.length > 0) $.ajax( {
    dataType: "script", cache: true,
    url: mjs[0].src.replace(mathjaxVersion, mjEncrypt)
    } );
    mathjaxVersion = mjEncrypt;
    console.log("https");
    }*/

    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = "//cdn.mathjax.org/mathjax/latest/MathJax.js" //(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;
    document.getElementsByTagName("head")[0].appendChild(script);
    setTimeout(function () {"use strict"; script.Hub.Queue(["Typeset", script.Hub]); }, 1000);
    console.log("The TeX-ification is complete!");