gpt4 book ai didi

math - 在 Gmail 邮件的正文上运行 Javascript

转载 作者:行者123 更新时间:2023-12-05 00:06:48 26 4
gpt4 key购买 nike

我想在收到的 gmail 消息中显示 LaTeX 数学,以便例如 $\mathbb P^2$ 将显示为一个不错的公式。现在,有几个可用的 Javascript(例如,this one 或 MathJax 可以完成这项工作,我只需要在正确的时间调用它们来操作 gmail 消息。

我知道这可以在“基本 HTML”和“打印” View 中完成。是否可以在标准 Gmail View 中执行?我试图在“canvas_frame”iframe 之前插入对 javascript 的调用,但这不起作用。

我怀疑通过任何 Javascript 操作 Gmail 邮件将是一个重大的安全漏洞(想想可能插入的所有恶意链接),谷歌会尽一切努力防止这种情况发生。所以我的问题的答案可能是“不”。我是对的吗?

当然,Google 很容易通过在其服务器上使用 MathJax 来实现对 LaTeX 和 MathML 数学的查看。我提出了相应的 Gmail Lab 请求,但没有得到答复,而且 Google 显然没有兴趣。

所以,再一次:在客户端,如果没有谷歌的合作,这可能吗?

最佳答案

我认为更好的方法之一可能是使用 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 库,我认为你可以做到这一点的一种方法是将脚本标签注入(inject) 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;
}
})();

关于math - 在 Gmail 邮件的正文上运行 Javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2796525/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com