网页latex公式解析(解决ChatGPT回答的latex格式无法解析)

hello!

  1. // ==UserScript==
  2. // @name 网页latex公式解析(解决ChatGPT回答的latex格式无法解析)
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.4.1
  5. // @description hello!
  6. // @author season
  7. // @match https://chat.openai.com/*
  8. // @match https://www.bing.com/search?*
  9. // @match https://you.com/search?*&tbm=youchat*
  10. // @match https://www.you.com/search?*&tbm=youchat*
  11. // @icon https://chat.openai.com/favicon.ico
  12. // @license GPL
  13. // @require https://code.jquery.com/jquery-3.4.1.min.js
  14. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  15. // @grant none
  16. // @run-at document-end
  17. // ==/UserScript==
  18.  
  19.  
  20.  
  21. (function() {
  22. 'use strict';
  23. // Load MathJax library
  24. var script = document.createElement("script");
  25. script.type = "text/javascript";
  26. script.src = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-AMS_HTML";
  27. document.getElementsByTagName("head")[0].appendChild(script);
  28.  
  29. // Configure MathJax to render LaTeX formulas
  30. window.MathJax = {
  31. tex2jax: {
  32. inlineMath: [ ['$','$'], ['\\(','\\)'] ],
  33. processEscapes: true
  34. },
  35. CommonHTML: { scale: 100 }
  36. };
  37.  
  38. // Wait for MathJax to load and render LaTeX formulas
  39. var checkLoaded = setInterval(function() {
  40. if (typeof MathJax !== "undefined" && MathJax.Hub.queue.queue.length === 0) {
  41. clearInterval(checkLoaded);
  42. MathJax.Hub.Queue(["Typeset", MathJax.Hub, document.body]);
  43. }
  44. }, 100);
  45.  
  46. // Listen for changes to the page content and re-render LaTeX formulas
  47. var observer = new MutationObserver(function(mutations) {
  48. mutations.forEach(function(mutation) {
  49. if (mutation.type === "childList" || mutation.type === "subtree") {
  50. MathJax.Hub.Queue(["Typeset", MathJax.Hub, mutation.target]);
  51. }
  52. });
  53. });
  54. observer.observe(document.body, {
  55. childList: true,
  56. subtree: true
  57. });
  58. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址