切換
舊版
前往
大廳
主題

使巴哈姆特能顯示數學式子(LaTeX語法)(2022.11.22更新)

Lumi | 2022-06-19 14:34:52 | 巴幣 2 | 人氣 264

瀏覽器需要安裝Tampermonkey附加元件,並加入此文章最下方的script即可
script的來源在此,原本是給Trello用的,我已修改成支援巴哈姆特,並支援文字顏色、cancel符號和tag編號。
1. 此方法只支援PC
2. 注意已加入此script的人會看到錯誤的script(因為其中的錢符號)
要更新的話須先關閉舊script才會看到正確內容

若設定成功,會看到數學公式:$\mathbf{a} \times \mathbf{b} = (\mathbf{a \wedge b})^{\textcolor{magenta}{*}} = (\mathbf{a \wedge b}) \textcolor{magenta}{\rfloor \mathbf{I}^{-1}_3}$
若不成功,只會看到LaTeX語法



// ==UserScript==
// @name        MathJax Gamer
// @description    Apply Mathjax to gamer
// @match        https://forum.gamer.com.tw/*
// @match        https://home.gamer.com.tw/*
// @match        https://haha.gamer.com.tw/*
// @grant       none
// ==/UserScript==

if (window.MathJax === undefined) {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src = "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
  script.text = 'MathJax.Hub.Config({'
              + '  messageStyle: "none",'
              + '  tex2jax: {'
              + '    inlineMath: [["$", "$"], ["\\\\(", "\\\\)"]],'
              + '    processEscapes: true'
              + '  },'
              + '  "HTML-CSS": {'
              + '    availableFonts: ["TeX"]'
              + '  },'
              + '  TeX: { extensions: ["color.js", "cancel.js", "tagformat.js"] },'
              + '});'
              // Run mathjax every second (the overhead is very low).
              + '(function doMathJax() {'
              + '  window.setTimeout(doMathJax, 1000);'
              + '  window.MathJax.Hub.Queue(["Typeset", window.MathJax.Hub]);'
              + '})();';
  document.getElementsByTagName("head")[0].appendChild(script);
} else {
  MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
}

創作回應

相關創作

更多創作