Created
January 19, 2014 20:26
-
-
Save tillahoffmann/8510540 to your computer and use it in GitHub Desktop.
This is a modification of the script provided by Davide Cervone (http://stackoverflow.com/questions/11255900/mathjax-support-in-github-using-a-chrome-browser-plugin). The script URL is modified to load the script from *.github.com* in order to comply with the new [Content Security Policies](https://github.com/blog/1477-content-security-policy).
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 Run MathJax in Github or Bitbucket | |
// @namespace http://www.mathjax.org/ | |
// @description Runs MathJax on any page in github.com or bitbucket.org | |
// @include http://github.com/* | |
// @include https://github.com/* | |
// @include http://bitbucket.org/* | |
// @include https://bitbucket.org/* | |
// ==/UserScript== | |
/*****************************************************************/ | |
(function () { | |
function LoadMathJax() { | |
if (!window.MathJax) { | |
if (document.body.innerHTML.match(/$|\\\[|\\\(|<([a-z]+:)math/)) { | |
var script = document.createElement("script"); | |
script.type = "text/javascript"; | |
script.src = "https://raw.github.com/mathjax/MathJax/master/MathJax.js?config=TeX-AMS-MML_HTMLorMML"; | |
script.text = [ | |
"MathJax.Hub.Config({", | |
" tex2jax: {inlineMath: [['$','$'],['\\\\\(','\\\\\)']]}", | |
"});" | |
].join("\n"); | |
var parent = (document.head || document.body || document.documentElement); | |
parent.appendChild(script); | |
} | |
} | |
}; | |
var script = document.createElement("script"); | |
script.type = "text/javascript"; | |
script.text = "(" + LoadMathJax + ")()"; | |
var parent = (document.head || document.body || document.documentElement); | |
setTimeout(function () { | |
parent.appendChild(script); | |
parent.removeChild(script); | |
},0); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment