Completely disable LaTeX rendering (MathJax, KaTeX, etc.)
当前为
// ==UserScript==
// @name Disable LaTeX Rendering Completely3
// @namespace http://tampermonkey.net/
// @version 0.3
// @description Completely disable LaTeX rendering (MathJax, KaTeX, etc.)
// @author You
// @match *://*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Function to disable LaTeX rendering (remove MathJax, KaTeX scripts, and prevent any rendering)
function disableLatexRendering() {
// Remove any LaTeX rendering scripts like MathJax or KaTeX
const scripts = document.querySelectorAll('script[src*="mathjax"], script[src*="katex"], script[type="math/tex"]');
scripts.forEach(script => script.remove());
// Remove elements that might be rendering LaTeX as images or HTML
const latexElements = document.querySelectorAll('span, div, p, img');
latexElements.forEach(element => {
if (element.innerHTML && element.innerHTML.match(/(?:\\\[.*\\\]|\\\(.*\\\))/)) {
// If the element contains LaTeX, change its inner HTML to raw LaTeX code
element.innerHTML = element.innerText;
}
});
// Make sure no LaTeX is being auto-rendered by MathJax/KaTeX
const mathJaxVars = ['MathJax', 'katex'];
mathJaxVars.forEach(varName => {
if (window[varName]) {
window[varName] = undefined;
}
});
}
// Run the function when the document is fully loaded
window.addEventListener('load', function() {
disableLatexRendering();
});
// Also run the function periodically to handle dynamic content (e.g., AJAX updates)
setInterval(disableLatexRendering, 1000);
})();