Last active
August 11, 2017 16:49
-
-
Save bassup/93f78c0fac2a7be25086 to your computer and use it in GitHub Desktop.
GreaseMonkey script for rendering ChatJax automatically on stackexchange.com chat sites (like Physics or Math)
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 ChatJax | |
// @namespace http://stackexchange.com/ | |
// @description Rendering ChatJax | |
// @include http://chat.stackexchange.com/* | |
// @author Bass | |
// @license Beerware | |
// @version 1 | |
// @grant GM_addStyle | |
// ==/UserScript== | |
function main() { | |
window.doChatJax = function () { | |
window.setTimeout(doChatJax, 2000); | |
window.MathJax.Hub.Queue(['Typeset',window.MathJax.Hub]); | |
}; | |
if (window.MathJax === undefined) { | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.src = 'https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML'; | |
var config = 'MathJax.Hub.Config({' + 'extensions: ["tex2jax.js"],' + 'tex2jax: { inlineMath: [["$","$"],["\\\\\\\\\\\\(","\\\\\\\\\\\\)"]], displayMath: [["$$","$$"],["\\\\[","\\\\]"]], processEscapes: true },' + 'jax: ["input/TeX","output/HTML-CSS"]' + '});' + 'MathJax.Hub.Startup.onload();'; | |
if (window.opera) { | |
script.innerHTML = config | |
} else { | |
script.text = config | |
} | |
document.getElementsByTagName('head') [0].appendChild(script); | |
window.setTimeout(doChatJax, 500); | |
} | |
}; | |
var script = document.createElement('script'); | |
script.appendChild(document.createTextNode('('+ main +')();')); | |
(document.body || document.head || document.documentElement).appendChild(script); |
I think if you give it a name ending in .user.js
, it will be possible to automatically install it by just clicking on "Raw"
Cool, didn't know that.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to install: