-
-
Save gauss256/62e3bee214b1b6591c9dfb30ac2ba87d to your computer and use it in GitHub Desktop.
A GreaseMonkey/TamperMonkey version of the `math-with-slack` script.
This file contains hidden or 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 on Slack | |
// @namespace https://github.com/fsavje/math-with-slack | |
// @description Renders math on Slack using MathJax. Based on github:fsavje/math-with-slack. | |
// @include https://*.slack.com/messages/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
// See: https://github.com/fsavje/math-with-slack | |
window.addEventListener('load', function() { | |
var mathjax_config = document.createElement("script"); | |
mathjax_config.type = "text/x-mathjax-config"; | |
mathjax_config.text = ` | |
MathJax.Hub.Config({ | |
messageStyle: "none", | |
extensions: ["tex2jax.js"], | |
jax: ["input/TeX", "output/HTML-CSS"], | |
tex2jax: { | |
skipTags: ["script","noscript","style","textarea","pre","code"], | |
ignoreClass: "ql-editor", | |
inlineMath: [ ['\$','\$'] ], | |
displayMath: [ ['\$\$','\$\$'] ], | |
processEscapes: true | |
}, | |
TeX: { | |
extensions: ["noErrors.js", "noUndefined.js"] | |
} | |
}); | |
`; | |
var mathjax_script = document.createElement("script"); | |
mathjax_script.type = "text/javascript"; | |
mathjax_script.src = "https://cdn.mathjax.org/mathjax/latest/MathJax.js"; | |
document.getElementsByTagName("head")[0].appendChild(mathjax_config); | |
document.getElementsByTagName("head")[0].appendChild(mathjax_script); | |
var render = function(records, observer) { | |
MathJax.Hub.Queue(["Typeset", MathJax.Hub]); | |
}, | |
target = document.querySelector('#msgs_div'), | |
observer = new MutationObserver(render), | |
config = { attributes: false, childList: true, characterData: true, subtree: true }; | |
observer.observe(target, config); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment