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

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

问题描述

我试图弄清楚如何将按钮添加到Gmail撰写窗口。在Gmail实验室中,他们有一些扩展程序可以添加某些按钮,例如发送和存档按钮和插入图像按钮,所以我认为这是可能的。



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



你知道怎么可以这样做?

如果使用Gmail API无法实现,那么我可以通过另一种方式实现这一目标吗?也许通过创建Google Chrome扩展程序或用户脚本?



我希望任何能够指引我朝着正确方向的信息。



谢谢。

解决方案

Gmail实验室具有特殊权限,因为它们是由Google员工编写的,不幸的是,我们的凡人不具备这种权力。当然有一种解决方法,您已经正确指出要制作 Chrome扩展名或UserScript。如果您选择使用Chrome扩展程序它将只是一个UserScript的封装器

您必须以编程方式创建并注入按钮。这将涉及到很多对Gmail源代码的冲刷(扰流:它很丑)。



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

  function bootstrap(){
target = document.querySelectorAll ( '.vt:否(.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


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

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.

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.

Do you know how can this be done?

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.

Thanks.

解决方案

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

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).

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);

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

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

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