LaTeX Formula Parser (Suitable for ChatGPT,NewBing,You,etc.)

hello!LaTeX Formula Parser (solving the issue of incapability of Chat GPT, Bing, YOU models to parse La Te X formats in their answers)

  1. // ==UserScript==
  2. // @name LaTeX Formula Parser (Suitable for ChatGPT,NewBing,You,etc.)
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description hello!LaTeX Formula Parser (solving the issue of incapability of Chat GPT, Bing, YOU models to parse La Te X formats in their answers)
  6. // @author season
  7. // @match *://*/*
  8. // @license GPL
  9. // @require https://code.jquery.com/jquery-3.4.1.min.js
  10. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  11. // @grant none
  12. // @run-at document-end
  13. // ==/UserScript==
  14. (function() {
  15. 'use strict';
  16. // Load MathJax library
  17. var script = document.createElement("script");
  18. script.type = "text/javascript";
  19. script.src = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-AMS_HTML";
  20. document.getElementsByTagName("head")[0].appendChild(script);
  21. // Configure MathJax to render LaTeX formulas
  22. window.MathJax = {
  23. tex2jax: {
  24. inlineMath: [ ['$','$'], ['\\(','\\)'] ],
  25. processEscapes: true
  26. },
  27. CommonHTML: { scale: 100 }
  28. };
  29. // Wait for MathJax to load and render LaTeX formulas
  30. var checkLoaded = setInterval(function() {
  31. if (typeof MathJax !== "undefined" && MathJax.Hub.queue.queue.length === 0) {
  32. clearInterval(checkLoaded);
  33. MathJax.Hub.Queue(["Typeset", MathJax.Hub, document.body]);
  34. }
  35. }, 100);
  36. // Listen for changes to the page content and re-render LaTeX formulas
  37. var observer = new MutationObserver(function(mutations) {
  38. mutations.forEach(function(mutation) {
  39. if (mutation.type === "childList" || mutation.type === "subtree") {
  40. MathJax.Hub.Queue(["Typeset", MathJax.Hub, mutation.target]);
  41. }
  42. });
  43. });
  44. observer.observe(document.body, {
  45. childList: true,
  46. subtree: true
  47. });
  48. })();