您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Disable LaTeX rendering but keep the raw LaTeX code visible (no MathJax, no KaTeX)
当前为
- // ==UserScript==
- // @name Disable LaTeX Rendering - Keep Raw LaTeX
- // @namespace http://tampermonkey.net/
- // @version 0.4
- // @description Disable LaTeX rendering but keep the raw LaTeX code visible (no MathJax, no KaTeX)
- // @author You
- // @match *://*/*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // Function to disable LaTeX rendering
- function disableLatexRendering() {
- // Find all elements containing LaTeX formulas, e.g., elements with class names like 'mathjax' or 'katex'
- const latexElements = document.querySelectorAll('script[src*="mathjax"], script[src*="katex"], span, div, p, img');
- latexElements.forEach(element => {
- // Check if the element contains LaTeX code (looks like \[ ... \] or \( ... \))
- if (element.innerHTML && (element.innerHTML.match(/\\\[(.*?)\\\]/) || element.innerHTML.match(/\\\((.*?)\\\)/))) {
- // Replace the LaTeX content with its raw version, preventing rendering
- element.innerHTML = element.innerText;
- }
- });
- // If MathJax or KaTeX is present, disable it
- if (window.MathJax) {
- window.MathJax.Hub.Config({
- showMathMenu: false, // Disable MathJax menu
- skipStartupTypeset: true, // Skip initial render
- });
- }
- // Prevent KaTeX from rendering
- if (window.katex) {
- window.katex.render = function() {}; // Override KaTeX rendering function
- }
- }
- // Run the function when the document is fully loaded
- window.addEventListener('load', function() {
- disableLatexRendering();
- });
- // Continuously check for new LaTeX content if the page is dynamic (AJAX)
- setInterval(disableLatexRendering, 1000);
- })();