How do we add new button to gmail compose bar in chrome extension? Is it through javascript or some gmail apis? [closed]

十年热恋 提交于 2019-12-08 08:17:02

问题


I am trying to come up with a chrome extension to add some functionality to gmail. I have been using any.do and wanted to understand how can we do something similar?

Do we inject our new div element in the DOM or are there any gmail apis through which I can add a new button and define action listener?


回答1:


I offer to you to use in this Libraries:

  • InboxSdk - high level JavaScript library used to easily build browser extensions that interact with both Gmail and Inbox by Google.
  • Gmail library github - Great library that using the DOM for many options of gmail

Best option for you I think will be InboxSdk. First you need to register your app here ,Then on your content page of your chrome-extension set :

InboxSDK.load('1.0', 'YOUR_APP_ID_HERE').then(function(sdk){

In this function you need to perform all actions . You could register events ( like when you read/compose message etc.) but your purpose is to add button to tool bar so you need to add a toolbar event:

registerToolbarButtonForList(toolbarButtonDescriptor)

or

registerToolbarButtonForThreadView(toolbarButtonDescriptor)

or

addToolbarButtonForApp(appToolbarButtonDescriptor)

If you want to know specific about every register event go to here

The object the event get it's all the deatils about the button(name, on click event etc) , see this here . From here you could set what ever you want from your button in the object .

Good luck



来源:https://stackoverflow.com/questions/42468422/how-do-we-add-new-button-to-gmail-compose-bar-in-chrome-extension-is-it-through

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!