我认为更好的方法之一可能是使用 Google Charts API 嵌入图像。
<img src="http://chart.apis.google.com/chart?cht=tx&chl=x=\frac{-b%20\pm%20\sqrt{b^2-4ac}}{2a}">
要了解更多信息:https ://developers.google.com/chart/image/ [注意,该 API 已正式弃用,但将在 2015 年 4 月之前有效]
如果你真的必须使用 LaTeX 和一些 js 库,我认为你可以做到这一点的一种方法是将脚本标签注入 iframe。我希望这是一个好的起点。
例子:
// ==UserScript==
// @name Test Gmail Alterations
// @version 1
// @author Justen
// @description Test Alter Email
// @include https://mail.google.com/mail/*
// @include http://mail.google.com/mail/*
// @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
// ==/UserScript==
(function GmailIframeInject() {
GM_log('Starting GMail iFrame Injection');
var GmailCode = function() {
// Your code here;
// The ':pd' (div id) changes, so you might have to do some extra work
var mail = document.getElementById(':pd');
mail.innerHTML = '<h1>Hello, World!</h1>';
};
var iframe = document.getElementById('canvas_frame');
var doc = null;
if( iframe ) {
GM_log('Got iFrame');
doc = iframe.contentDocument;
} else {
GM_log('ERROR: Could not get iframe with id canvas_frame');
return
}
if( doc ) {
GM_log('Injecting GmailCode');
var code = "(" + GmailCode + ")();"
doc.body.appendChild(doc.createElement('script')).innerHTML=code;
} else {
GM_log('ERROR: Could not get iframe content document');
return;
}
})();