From f3ee6098d32cf0796303a18755395249ce15efb6 Mon Sep 17 00:00:00 2001 From: nobody Date: Fri, 4 Nov 2022 06:23:29 +0100 Subject: [PATCH] MathJax latest.js v2.7.5 file modified (#1194) --- resources/mathjax/2.7.5/latest.jsm | 113 ++++++++++++++++------------- 1 file changed, 63 insertions(+), 50 deletions(-) diff --git a/resources/mathjax/2.7.5/latest.jsm b/resources/mathjax/2.7.5/latest.jsm index c5b034b9..cead25a6 100644 --- a/resources/mathjax/2.7.5/latest.jsm +++ b/resources/mathjax/2.7.5/latest.jsm @@ -16,6 +16,15 @@ * 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 Error(text) { if (console && console.log) { @@ -62,30 +71,30 @@ } } - function setVersion(value) { - cookie = "mjx.latest=" + value; - var d = new Date; - d.setDate(d.getDate() + 7); - cookie = cookie + ("; expires=" + d.toGMTString()); - cookie = cookie + "; path=/"; - try { - document.cookie = cookie; - } catch (r) {} - } + // function setVersion(value) { + // cookie = "mjx.latest=" + value; + // var d = new Date; + // d.setDate(d.getDate() + 7); + // cookie = cookie + ("; expires=" + d.toGMTString()); + // cookie = cookie + "; path=/"; + // try { + // document.cookie = cookie; + // } catch (r) {} + // } - function getXMLHttpRequest() { - if (window.XMLHttpRequest) { - return new XMLHttpRequest; - } - if (window.ActiveXObject) { - try { - return new ActiveXObject("Msxml2.XMLHTTP"); - } catch (q) {} - try { - return new ActiveXObject("Microsoft.XMLHTTP"); - } catch (q) {} - } - } + // function getXMLHttpRequest() { + // if (window.XMLHttpRequest) { + // return new XMLHttpRequest; + // } + // if (window.ActiveXObject) { + // try { + // return new ActiveXObject("Msxml2.XMLHTTP"); + // } catch (q) {} + // try { + // return new ActiveXObject("Microsoft.XMLHTTP"); + // } catch (q) {} + // } + // } function loadMathJax(url) { var script = document.createElement("script"); @@ -110,34 +119,36 @@ } function getLatestMathJax(cdn, config, unpacked) { - var request = getXMLHttpRequest(); - if (request) { - request.onreadystatechange = function() { - if (request.readyState === 4) { - if (request.status === 200) { - var json = JSON.parse(request.responseText); - if (json instanceof Array) { - json = json[0]; - } - var value = json[cdn.version]; - if (value.substr(0, 2) === "2.") { - setVersion(value); - loadMathJax(cdn.mathjax + json[cdn.version] + unpacked + "/MathJax.js" + config); - return; - } - } else { - Error("Problem acquiring MathJax version: status = " + request.status); - } - loadDefaultMathJax(); - } - }; - request.open("GET", cdn.api, true); - request.send(null); - } else { - Error("Can't create XMLHttpRequest object"); - loadDefaultMathJax(); - } + // var request = getXMLHttpRequest(); + // if (request) { + // request.onreadystatechange = function() { + // if (request.readyState === 4) { + // if (request.status === 200) { + // var json = JSON.parse(request.responseText); + // if (json instanceof Array) { + // json = json[0]; + // } + // var value = json[cdn.version]; + // if (value.substr(0, 2) === "2.") { + // setVersion(value); + // loadMathJax(cdn.mathjax + json[cdn.version] + unpacked + "/MathJax.js" + config); + // return; + // } + // } else { + // Error("Problem acquiring MathJax version: status = " + request.status); + // } + // loadDefaultMathJax(); + // } + // }; + // request.open("GET", cdn.api, true); + // request.send(null); + // } else { + // Error("Can't create XMLHttpRequest object"); + // loadDefaultMathJax(); + // } + loadDefaultMathJax(); } + var CDN = { "cdnjs.cloudflare.com": { api: "https://api.cdnjs.com/libraries/mathjax?fields=version", @@ -155,9 +166,11 @@ mathjax: "https://cdn.jsdelivr.net/mathjax/" } }; + var valExpr = /(?:^|;\s*)mjx\.latest=([^;]*)(?:;|$)/; var script = getScript(); var cdn = getCDN(script); + if (cdn) { var config = script.src.replace(/.*?(\?|$)/, "$1"); config = config + ((config ? "&" : "?") + "latest");