MathJax latest.js v2.7.5 file modified (#1194)

This commit is contained in:
nobody 2022-11-04 06:23:29 +01:00
parent da9224c551
commit f3ee6098d3
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
1 changed files with 63 additions and 50 deletions

View File

@ -16,6 +16,15 @@
* limitations under the License. * limitations under the License.
*/ */
/*
* @author nobody
* @since 2022-11-04
*
* This file was modified:
* - Obfuscation reverted with www.dcode.fr
* - getLatestMathJax defused and call the loadDefaultMathJax() method directly.
*/
(function() { (function() {
function Error(text) { function Error(text) {
if (console && console.log) { if (console && console.log) {
@ -62,30 +71,30 @@
} }
} }
function setVersion(value) { // function setVersion(value) {
cookie = "mjx.latest=" + value; // cookie = "mjx.latest=" + value;
var d = new Date; // var d = new Date;
d.setDate(d.getDate() + 7); // d.setDate(d.getDate() + 7);
cookie = cookie + ("; expires=" + d.toGMTString()); // cookie = cookie + ("; expires=" + d.toGMTString());
cookie = cookie + "; path=/"; // cookie = cookie + "; path=/";
try { // try {
document.cookie = cookie; // document.cookie = cookie;
} catch (r) {} // } catch (r) {}
} // }
function getXMLHttpRequest() { // function getXMLHttpRequest() {
if (window.XMLHttpRequest) { // if (window.XMLHttpRequest) {
return new XMLHttpRequest; // return new XMLHttpRequest;
} // }
if (window.ActiveXObject) { // if (window.ActiveXObject) {
try { // try {
return new ActiveXObject("Msxml2.XMLHTTP"); // return new ActiveXObject("Msxml2.XMLHTTP");
} catch (q) {} // } catch (q) {}
try { // try {
return new ActiveXObject("Microsoft.XMLHTTP"); // return new ActiveXObject("Microsoft.XMLHTTP");
} catch (q) {} // } catch (q) {}
} // }
} // }
function loadMathJax(url) { function loadMathJax(url) {
var script = document.createElement("script"); var script = document.createElement("script");
@ -110,34 +119,36 @@
} }
function getLatestMathJax(cdn, config, unpacked) { function getLatestMathJax(cdn, config, unpacked) {
var request = getXMLHttpRequest(); // var request = getXMLHttpRequest();
if (request) { // if (request) {
request.onreadystatechange = function() { // request.onreadystatechange = function() {
if (request.readyState === 4) { // if (request.readyState === 4) {
if (request.status === 200) { // if (request.status === 200) {
var json = JSON.parse(request.responseText); // var json = JSON.parse(request.responseText);
if (json instanceof Array) { // if (json instanceof Array) {
json = json[0]; // json = json[0];
} // }
var value = json[cdn.version]; // var value = json[cdn.version];
if (value.substr(0, 2) === "2.") { // if (value.substr(0, 2) === "2.") {
setVersion(value); // setVersion(value);
loadMathJax(cdn.mathjax + json[cdn.version] + unpacked + "/MathJax.js" + config); // loadMathJax(cdn.mathjax + json[cdn.version] + unpacked + "/MathJax.js" + config);
return; // return;
} // }
} else { // } else {
Error("Problem acquiring MathJax version: status = " + request.status); // Error("Problem acquiring MathJax version: status = " + request.status);
} // }
loadDefaultMathJax(); // loadDefaultMathJax();
} // }
}; // };
request.open("GET", cdn.api, true); // request.open("GET", cdn.api, true);
request.send(null); // request.send(null);
} else { // } else {
Error("Can't create XMLHttpRequest object"); // Error("Can't create XMLHttpRequest object");
loadDefaultMathJax(); // loadDefaultMathJax();
} // }
loadDefaultMathJax();
} }
var CDN = { var CDN = {
"cdnjs.cloudflare.com": { "cdnjs.cloudflare.com": {
api: "https://api.cdnjs.com/libraries/mathjax?fields=version", api: "https://api.cdnjs.com/libraries/mathjax?fields=version",
@ -155,9 +166,11 @@
mathjax: "https://cdn.jsdelivr.net/mathjax/" mathjax: "https://cdn.jsdelivr.net/mathjax/"
} }
}; };
var valExpr = /(?:^|;\s*)mjx\.latest=([^;]*)(?:;|$)/; var valExpr = /(?:^|;\s*)mjx\.latest=([^;]*)(?:;|$)/;
var script = getScript(); var script = getScript();
var cdn = getCDN(script); var cdn = getCDN(script);
if (cdn) { if (cdn) {
var config = script.src.replace(/.*?(\?|$)/, "$1"); var config = script.src.replace(/.*?(\?|$)/, "$1");
config = config + ((config ? "&" : "?") + "latest"); config = config + ((config ? "&" : "?") + "latest");