User:Sivizius/common.js

function beautifyMath { elements = document.getElementsByClassName("mwe-math-fallback-image-inline"); client = new XMLHttpRequest; while (elements[0] ) { client.open('GET', elements[0].src, async=false); client.onreadystatechange = function {}; client.send; elements[0].parentElement.innerHTML = client.responseText; } } function beautifySVG { elements = document.getElementsByTagName("img"); for (k = 0; k < elements.length; k++ ) {   var strings = elements[k].src.split("/"); var output = strings[strings.length - 2]; if ( output.endsWith(".svg") ) {     for (i = ( strings.length - 3 ); i; i--) {       if ( strings[i] !== "thumb" ) {         output = strings[i] + "/" + output; }       else {         break; }     }      console.log("//upload.wikimedia.org/wikipedia/commons/" + output); }   else {     elements = elements.slice(1,elements.length); } } } beautifyMath; window.wpDarkModeAutoToggle = true;