How to build a chrome extension to add panel to gm

2020-07-06 07:00发布

问题:

I want to build a chrome extension like rapportive.com. I'm new to Chrome extensions and Gmail Content Script. Can any one please suggest how to go about this?

Currently I'm reading Google's Gadget docs.

回答1:

Here are some notes to you started. There are more robust ways to build this, but this is the "hello world" of the functionality you are talking about:

  1. You will need to define a content script that you add to the context of gmail. This part is pretty easy and can work with any of the content script examples available in the Google's documentation. You should read and learn about what it means to be a content script.
  2. The content script will need to know where to look inside gmail for an email address. This address will be used to grab the social media information on the user. You message this email address from the content script to the extension's background page.
  3. The background page will need to have social media integration that the user pre-configured. Basically, you need to plug the background page into Facebook's/Twitter's/LinkedIn's APIs and use their APIs to collect information about the email address.
  4. The background page will then message the content script you added to gmail with the social media details for the email address
  5. The content script then modifies gmail's user interface to contain your social media details.

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.

Good luck!



回答2:

I don't know what google gadget is and link you provided gives 404 but I don't think you even need this.

What you need is a content script that is injected into gmail page where it adds a panel. So, start with reading about how to create a Chrome extension that is using content scripts.



回答3:

There is a new SDK for modifying the DOM elements in gmail: https://www.inboxsdk.com/docs/

They have a useful API for adding buttons and other elements.