Skip to content

Commit 1abac89

Browse files
author
Ivan Beloborodov
committed
MathJax user JS script.
1 parent b7e524f commit 1abac89

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

mathjax-in-github.user.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// ==UserScript==
2+
// @name Run MathJax in Github
3+
// @namespace http://www.mathjax.org/
4+
// @description Runs MathJax on any page in github.com
5+
// @include http://github.com/*
6+
// @include https://github.com/*
7+
// ==/UserScript==
8+
9+
/*****************************************************************/
10+
11+
(function () {
12+
13+
function LoadMathJax() {
14+
if (!window.MathJax) {
15+
if (document.body.innerHTML.match(/$|\\\[|\\\(|<([a-z]+:)math/)) {
16+
var script = document.createElement("script");
17+
script.type = "text/javascript";
18+
script.src = "https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
19+
script.text = [
20+
"MathJax.Hub.Config({",
21+
" tex2jax: {inlineMath: [['$','$'],['\\\\\(','\\\\\)']]}",
22+
"});"
23+
].join("\n");
24+
var parent = (document.head || document.body || document.documentElement);
25+
parent.appendChild(script);
26+
}
27+
}
28+
};
29+
30+
var script = document.createElement("script");
31+
script.type = "text/javascript";
32+
script.text = "(" + LoadMathJax + ")()";
33+
var parent = (document.head || document.body || document.documentElement);
34+
setTimeout(function () {
35+
parent.appendChild(script);
36+
parent.removeChild(script);
37+
},0);
38+
39+
})();

0 commit comments

Comments
 (0)