如何开发适用于Gmail的Chrome扩展程序? [英] How to develop Chrome extension for Gmail?

查看:219
本文介绍了如何开发适用于Gmail的Chrome扩展程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑开发Chrome的Chrome扩展程序,我想知道目前的最佳做法是什么。



例如:




  • 默认情况下将GPG签名附加到每个电子邮件

  • 添加一个额外的按钮, )

  • 发送电子邮件的劫持行为,并提示我完成某件事

  • ...




有相当多的显着增加gmail功能的显着扩展:





一个选择是窥探他们的来源,位于这里
〜/ Library / Application Support / Google / Chrome / Default



但是可能有(一厢情愿的想法)一个很好的教程/一套关于如何解决gmail UI和功能的做法?



Gmail扩展程序/ gadget API - 如何添加一个按钮到撰写工具栏?


您将必须以编程方式创建和注入按钮。这将涉及相当多的淘宝Gmail源代码(扰流:它是丑陋的)。


如何构建Chrome扩展程序以将面板添加到Gmail窗口?


您将面临的最大的长期挑战是gmail的布局会意外更改,并破坏电子邮件发现或修改UI。这两个问题需要一些聪明才能解决,否则将要求您在晚上想知道Google是否会突然中断您的分机。


http:// www .jamesyu.org / 2011/02/05 / introduction-gmailr-an-unofficial-javscript-api-for-gmail /


他们正在构建复杂的API,具有类似的功能,如果Gmail决定显着改变应用程序结构(这将不可避免地会),那么这些API都可以独立打破。



Gmail通过关闭编译器运行其代码,从而模糊所有内容。除此之外,Gmail可能是最复杂的JavaScript应用程序之一。图书馆由Parse的创始人 -



< nofollow noreferrer> https://github.com/jamesyu/gmailr
- 但在1.5年内尚未更新。






我可以告诉你我到目前为止,只是这样知道我不是特别喜欢选择器,如 .oh.JZI.J-J5-Ji.TI-ax7注意: /developing-google-chrome-extension-for.htmlrel =nofollow noreferrer> http://anurag-maher.blogspot.co.uk/2012/12/developing-google-chrome-extension-for.html (他也这样做,他也使用这样的混淆选择器)



manifest.json



 content_scripts:[
{
matches:[https://mail.google.com/*],
css:[mystyles.css],
js:[jquery-2.1.0.js,myscript.js]
}
]



myscript.js



  var icon = jQuery(。oh.JZI.J-J5-Ji.TI-ax7)
var clone = icon.clone();
clone.attr(data-tooltip,my tooltip);
clone.on(click,function(){
jQuery(。aDg)。append(< p class ='popup'> ...示例内容...< ; / p>);
});
icon.before(clone);

(重复使用现有的UI元素,所以我的功能本身)






https ://developers.google.com/gmail/gadgets_overview



有侧栏小工具和上下文小工具,但不提供我想要实现的内容。 / p>


Gmail实验室是实验功能的测试基础,并不是黄金时段的准备。他们可能会随时更改,中断或消失。


https://groups.google.com/forum/#!forum/gmail-labs-suggest-a-labs-功能
似乎开发Gmail实验室的能力被锁定给Google员工。



https://developers.google.com/gmail/


需要帮助?在Gmail上找到我们Stack Overflow。







所以是的,我真的很想知道是否有任何教程/参考材料在那里?



(我回顾了许多类似问题,我恐怕我的选择在这里是有限的,但我会非常开心如果我恭维你的启示)

解决方案

看起来你没有偶然发现 gmail.js 项目。它提供了一个丰富的API,可以使用Gmail。不过,请注意,Google不保留此项目。这意味着Gmail中的任何更改可能会破坏您的扩展程序,并且不保证任何人都将关心更新gmail.js以解决这些更改。


I'm thinking about developing Chrome extension for Gmail and I want to know what are the current best practices.

For instance:

  • attaching a GPG signature by default to every email
  • adding an extra button that does something (I have it already)
  • hijacking action of sending email and prompting me to do complete something
  • ...
  • (just them examples helping me to discover what is possible)

There are quite a few notable extensions that significantly augment gmail functionality:

One option would be to peek into their source which is located here ~/Library/Application Support/Google/Chrome/Default

But maybe there is (wishful thinking) a good tutorial / set of practises on how to fiddle with gmail UI and functionality?

Gmail extension/gadget API - how to add a button to the compose toolbar?

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

How to build a chrome extension to add panel to gmail windows?

The greatest long-term challenge you will face is that gmail's layout will change unexpectedly and break email discovery or the modified UI. Both issues either require some cleverness to solve, or will require you to stay up at night wondering whether Google will suddenly break your extension.

http://www.jamesyu.org/2011/02/05/introducing-gmailr-an-unofficial-javscript-api-for-gmail/

They're all building out complex APIs with similar functionality, that can all break independently if Gmail decides to significantly change their app structure (which they inevitably will).

Gmail runs its code through the closure compiler, thereby obfuscating everything. On top of that, Gmail is probably one of the most sophisticated javascript apps out there.

Library by the founder of Parse - https://github.com/jamesyu/gmailr - but haven't updated in 1.5 years.


I can show you what I got so far, and just so know I don't particularly like selectors like .oh.J-Z-I.J-J5-Ji.T-I-ax7

Note: http://anurag-maher.blogspot.co.uk/2012/12/developing-google-chrome-extension-for.html (he also does it, he also uses such an obfuscated selectors)

manifest.json

"content_scripts": [
  {
    "matches": ["https://mail.google.com/*"],
    "css": ["mystyles.css"],
    "js": ["jquery-2.1.0.js", "myscript.js"]
  }
]

myscript.js

var icon = jQuery(".oh.J-Z-I.J-J5-Ji.T-I-ax7")
var clone = icon.clone();
clone.attr("data-tooltip", "my tooltip");
clone.on("click", function() {
    jQuery(".aDg").append("<p class='popup'>... sample content ...</p>");
});
icon.before(clone);

(reusing existing UI elements so my functionality looks natively)


https://developers.google.com/gmail/gadgets_overview

There are Sidebar Gadgets and Contextual Gadgets but they don not offer what I want to achieve.

Gmail Labs is a testing ground for experimental features that aren't quite ready for primetime. They may change, break or disappear at any time.

https://groups.google.com/forum/#!forum/gmail-labs-suggest-a-labs-feature It seems like the ability to develop Gmail Labs is locked to Google employees.

https://developers.google.com/gmail/

Need help? Find us on Stack Overflow under the gmail tag.


So yes, I would really like to know if there are any tutorials / reference materials out there?

(I reviewed many of the 'Similar Questions' and I'm afraid that my options here are limited, but I would be extremely happy if I shrine your enlightenment upon me)

解决方案

It looks like you haven't stumbled upon the gmail.js project. It provides a rich API allowing to work with Gmail. However, please note that this project isn't maintained by Google. This means that any changes in the Gmail may break your extension and there is no guarantee that anyone will care to update gmail.js to address these changes.

这篇关于如何开发适用于Gmail的Chrome扩展程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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