Revision 3. This one actually has a working loop, and uses jQuery instead of directly injecting a script element.
Unfortunately, it seems that new chat messages no longer trigger the ajaxComplete event, so my hack has to be replaced with a different one. This one runs MathJax on a 1-second cycle.
Bookmarklet:
javascript:(function()%7Bif(window.MathJax===undefined)%7BjQuery.getScript(%22http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML%22,function()%7BMathJax.Hub.Config(%7B%22HTML-CSS%22:%7BpreferredFont:%22TeX%22,availableFonts:%5B%22STIX%22,%22TeX%22%5D,linebreaks:%7Bautomatic:true%7D,EqnChunk:MathJax.Hub.Browser.isMobile?10:50%7D,tex2jax:%7BinlineMath:%5B%5B%22$%22,%22$%22%5D,%5B%22%5C%5C%5C%5C(%22,%22%5C%5C%5C%5C)%22%5D%5D,displayMath:%5B%5B%22$$%22,%22$$%22%5D,%5B%22%5C%5C%5B%22,%22%5C%5C%5D%22%5D%5D,processEscapes:true,ignoreClass:%22tex2jax_ignore%7Cdno%22%7D,TeX:%7BnoUndefined:%7Battributes:%7Bmathcolor:%22red%22,mathbackground:%22#FFEEEE%22,mathsize:%2290%25%22%7D%7D%7D,messageStyle:%22none%22%7D);MathJax.Hub.Startup.onload();theLoop=function()%7BMathJax.Hub.Queue(%5B%22Typeset%22,MathJax.Hub%5D);window.setTimeout(theLoop,1e3)%7D;theLoop()%7D)%7Delse%7BMathJax.Hub.Queue(%5B%22Typeset%22,MathJax.Hub%5D)%7D%7D)()
Source code:
(function () {
if (window.MathJax === undefined) {
jQuery.getScript('http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML', function () {
MathJax.Hub.Config({
"HTML-CSS": {
preferredFont: "TeX",
availableFonts: ["STIX", "TeX"],
linebreaks: {
automatic: true
},
EqnChunk: (MathJax.Hub.Browser.isMobile ? 10 : 50)
},
tex2jax: {
inlineMath: [
["$", "$"],
["\\\\(", "\\\\)"]
],
displayMath: [
["$$", "$$"],
["\\[", "\\]"]
],
processEscapes: true,
ignoreClass: "tex2jax_ignore|dno"
},
TeX: {
noUndefined: {
attributes: {
mathcolor: "red",
mathbackground: "#FFEEEE",
mathsize: "90%"
}
}
},
messageStyle: "none"
});
MathJax.Hub.Startup.onload();
theLoop = function () {
MathJax.Hub.Queue(['Typeset', MathJax.Hub]);
window.setTimeout(theLoop, 1000);
};
theLoop();
});
} else {
MathJax.Hub.Queue(['Typeset', MathJax.Hub]);
}
})();