This repository was archived by the owner on Mar 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathuserscript.js
More file actions
35 lines (35 loc) · 1.41 KB
/
userscript.js
File metadata and controls
35 lines (35 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// math-with-slack originally ported from https://github.com/fsavje/math-with-slack
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: {
displayMath: [['\$\$', '\$\$']],
element: 'msgs_div',
ignoreClass: 'ql-editor',
inlineMath: [['\$', '\$']],
processEscapes: true,
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
},
TeX: {
extensions: ['AMSmath.js', 'AMSsymbols.js', 'noErrors.js', 'noUndefined.js']
}
});
`;
var mathjax_observer = document.createElement('script');
mathjax_observer.type = 'text/x-mathjax-config';
mathjax_observer.text = `
var target = document.querySelector('#messages_container');
var options = { attributes: false, childList: true, characterData: true, subtree: true };
var observer = new MutationObserver(function (r, o) { MathJax.Hub.Queue(['Typeset', MathJax.Hub]); });
observer.observe(target, options);
`;
var mathjax_script = document.createElement('script');
mathjax_script.type = 'text/javascript';
mathjax_script.src = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js';
document.head.appendChild(mathjax_config);
document.head.appendChild(mathjax_observer);
document.head.appendChild(mathjax_script);