User:Fndercole/vector.js

var commonConfig = { jax: [], preRemoveClass: "MathJax_hide_me", tex2jax : { inlineMath : [], displayMath : [], processRefs : false, processEnvironments : false },	extensions: ["Safe.js"], TeX: { // Macros not defined in the TeX extension "mediawiki-texvc.js", see https://github.com/mathjax/MathJax/blob/master/unpacked/extensions/TeX/mediawiki-texvc.js		Macros: { sen: "\\operatorname{sen}",		// alternative symbol of the sinus function used in some countries, recognised by wikipedia server software sgn: "\\operatorname{sgn}",		// signum function, recognised by wikipedia server software AA: "\\unicode[.8,0]{x212B}",	// angstrom symbol, see https://github.com/mathjax/MathJax/issues/795#issuecomment-41437894 Digamma: "F", euro: "\\unicode{0x20AC}", geneuro: "\\unicode{0x20AC}", geneuronarrow: "\\unicode{0x20AC}", geneurowide: "\\unicode{0x20AC}", officialeuro: "\\unicode{0x20AC}", textvisiblespace: "\\unicode{x2423}", pagecolor: ["", 1],				// MathJax does not support background color P: "\\unicode{xB6}",			// ¶ symbol emph: "",						// emph does nothing on wikipedia but it's sometimes used },		// Uncomment to easily find missing TeX and LaTeX macros /*		noUndefined: { disabled: true },		noErrors: { disabled: true },		*/		extensions: ["autoload-all.js", "mediawiki-texvc.js"] } };

function wikipediaTextual(spans) { console.log("Replacing LaTeX with MathJax...");

var script; for (var i = 0; i < spans.length; i++) { var span = spans.get(i); var tex = span.innerHTML; tex = tex.substring(1, tex.length - 2); script = document.createElement("script"); if (span.className.indexOf("mwe-math-fallback-source-display") > -1) { script.type = "math/tex; mode=display"; } else { script.type = "math/tex"; }		span.className = "MathJax_hide_me"; script[(window.opera ? "innerHTML" : "text")] = "\\displaystyle " + tex; $(span).after(script); }

// Load MathJax script = document.createElement("script"); script.type = "text/x-mathjax-config"; var config = commonConfig; script[(window.opera ? "innerHTML" : "text")] = "MathJax.Hub.Config(" + JSON.stringify(config) + ");"; console.log(script[(window.opera ? "innerHTML" : "text")]); $("head").append(script); script = document.createElement("script"); script.type = "text/javascript"; script.src = "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML,Safe"; $("head").append(script); }

// Load MathJax only if no one else (the webpage, another browser extension...) has already loaded it if (window.MathJax === undefined && (window.unsafeWindow === undefined || window.unsafeWindow.MathJax === undefined)) { console.log("Loading MathJax in Wikipedia..."); var spans = $("span.tex"); if (spans.length > 0) { wikipediaTextual(spans); } else { console.log("Math seems unused on this page. MathJax will not be loaded."); } } else { console.log("MathJax seems to be already loaded, doing nothing."); }