Last active
January 16, 2023 04:42
-
-
Save neighthan/756fbb4ce6ccc40b77cc4eeb13379fe4 to your computer and use it in GitHub Desktop.
Tampermonkey User Script to add MathJax to, e.g., Trello
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name MathJax | |
// @namespace http://tampermonkey.net/ | |
// @version 2.0 | |
// @description Add Mathjax to webpages | |
// @author Nathan Hunt | |
// @match https://trello.com/* | |
// @grant none | |
// ==/UserScript== | |
// Note that github blocks this <.< I haven't found a viable workaround. | |
// See http://docs.mathjax.org/en/latest/web/configuration.html for | |
// instructions on loading mathjax and | |
// http://docs.mathjax.org/en/latest/advanced/typeset.html for | |
// instructions on using mathjax with dynamic webpages | |
(function() { | |
'use strict' | |
if (window.MathJax !== undefined) { | |
return | |
} | |
window.MathJax = { | |
tex: { | |
inlineMath: [['$', '$'], ['\\(', '\\)']] | |
}, | |
svg: { | |
fontCache: 'global' | |
} | |
}; | |
let script = document.createElement('script'); | |
script.src = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js'; | |
script.async = true; | |
document.head.appendChild(script); | |
// Run mathjax every second | |
(function typesetForever() { | |
window.setTimeout(typesetForever, 1000) | |
if (window.MathJax.typeset !== undefined) { // done loading | |
window.MathJax.typeset() | |
} | |
})() | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Someone I shared this with pointed out that this causes an infinite recursion, and something like the following would be more robust: