Gmail 扩展程序/小工具 API - 如何向撰写工具栏添加按钮? [英] Gmail extension/gadget API - how to add a button to the compose toolbar?

查看:35
本文介绍了Gmail 扩展程序/小工具 API - 如何向撰写工具栏添加按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想弄清楚如何在 Gmail 撰写窗口中添加一个按钮.

I'm trying to figure out how can I add a button to the Gmail compose window.

在Gmail Labs"中,他们有一些添加某些按钮的扩展程序,例如发送和存档"按钮和插入图像"按钮,所以我认为这是可能的.

In "Gmail Labs" they have some extensions that add certain buttons For example "Send & Archive" button and "Inserting images" button, so I assume this is possible.

我检查了他们的 API here,看来您可以在左侧边栏中添加小工具或使用依赖于消息上下文的上下文小工具.我正在寻找一种将按钮添加到撰写窗口的工具栏的方法,但这两个选项似乎都不支持.

I checked their API here and it seems that you can either add a gadget to left sidebar or use contextual gadgets that are dependent on the message context. I'm looking for a way to add a button to the toolbar of the compose window, and both options don't seem to support it.

你知道怎么做吗?

如果无法使用 Gmail API,还有其他方法可以实现吗?也许通过创建 Google Chrome 扩展程序或用户脚本?

If it's not possible using Gmail API, is there another way I can achieve this? Maybe by creating a Google Chrome extension or user scripts?

如果有任何信息可以指引我正确的方向,我将不胜感激.

I would appreciate any info that can direct me in the right direction.

谢谢.

推荐答案

Gmail Labs 拥有特殊权限,因为它们是由 Google 员工编写的,遗憾的是我们凡人没有这样的权力.当然有一种解决方法,您已经正确指出它是制作一个 Chrome扩展 或用户脚本.如果你选择做一个 Chrome 扩展 它只是一个用户脚本的包装器

The Gmail Labs have special permissions because they are written by Google Employees, unfortunately we mortals don't have such power. There is a way around it of course and you've correctly pointed out that it is to make a Chrome Extension or a UserScript. If you choose to do a Chrome Extension it will just be a wrapper for a UserScript anyway

您必须以编程方式创建和注入按钮.这将涉及对 Gmail 源代码的大量搜索(剧透:它很难看).

You will have to create and inject the button programmatically. This will involve quite a bit of scouring the Gmail source code (spoiler: it's ugly).

如果没有关于您想要做什么的更多详细信息,我将无法提供更多帮助,但我可以立即帮助您解决一个问题.您必须让脚本等到 Gmail 加载过程完成,这有点挑战.这是我目前在 Minimalist 中使用的解决方案:

Without more details about what you want to do, I won't be able to provide much more help but I can help you with one problem right away. You have to make your script wait until the Gmail loading process is done which is a bit of a challenge. This is the solution I'm currently using in Minimalist:

function bootstrap() {
    target = document.querySelectorAll('.vt:not(.SFzvCe)');
    if (document.querySelectorAll('html.xiu1Fc, html.aao')[0] == null) {
        return;
    }
    if (target.length > 0) {
        // loaded, do stuff
    } else {
        window.setTimeout(bootstrap, 200);
    }
}
window.addEventListener('DOMSubtreeModified', bootstrap);

该版本等待聊天完全加载.如果您有任何其他问题,请告诉我:@anstosa

That version waits for the chat to fully load. Let me know if you have any other questions: @anstosa

这篇关于Gmail 扩展程序/小工具 API - 如何向撰写工具栏添加按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆