Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When sender is a Gmail/G Suite address, replace Letter icon with their profile picture #51

Open
russelldc opened this issue Apr 15, 2019 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@russelldc
Copy link
Collaborator

We'll need to figure out how Google makes the request for their profile picture.
If one exists (and it isn't the default avatar mask), then it should replace the colored first letter icon on the email list.

@russelldc
Copy link
Collaborator Author

russelldc commented Apr 15, 2019

@boukestam and @g60madman and I had previously discussed incorporating Google's favicon fetching api, but as far as I can tell from old screenshots, Inbox never used something like that.

It only fetched the profile pictures from Gmail and G Suite accounts. Sometimes it just seemed like it may have fetched a favicon, because it was actually a G Suite account, like Medium.com for example:

Screen Shot 2019-04-15 at 10 54 32 PM

@ryanmclaughlin
Copy link

Apparently this is not possible anymore since the Google+ API is deprecated. Hopefully there's another way. There are services that will fetch favicon's and web app icons from the head of a domain, but many sites do not have this.

@joeytroy
Copy link
Collaborator

@ryanmclaughlin With Google Currents I would thing this maybe a possibility https://gsuite.google.com/products/currents/ I don't see anything about API posted on the site yet.

@ryanmclaughlin
Copy link

Ah neat. fingers crossed

@joeytroy
Copy link
Collaborator

@russelldc
Copy link
Collaborator Author

@g60madman @ryanmclaughlin I was aware that the official Google+ api is now gone, as well as the Picasa one that some people used for this.

My intention wasn't to use something official, but to reverse engineer the request that Gmail is using right now to pull those profile pictures.

@ryanmclaughlin
Copy link

@russelldc Gotcha. I did something similar with Inbox's old placeholder images, but obviously a better options is to render these with css rather than make many requests.

const avatarUrl = "https://ssl.gstatic.com/bt/C3341AA7A1A076756462EE2E5CD71C11/avatars/avatar_tile_" + firstLetter + "_28.png"

@russelldc russelldc added the enhancement New feature or request label Apr 29, 2019
@russelldc
Copy link
Collaborator Author

russelldc commented May 4, 2019

I think I'm pretty dang close to cracking this :) I've figured out how most of the hashed tokens and api keys get generated for the profile photo lookup request.

Edit: Got almost everything ready. There's just 2-3 more parameters I need to find the origin of.

@russelldc
Copy link
Collaborator Author

Alright, I've got the request all working, but I don't have it hooked up to anything automated/UI-related yet. It can be triggered from the Chrome web console, like:

You should see a parsed response like this one:

[
   {
      "senderAddress": "[email protected]",
      "photoURL": "https://lh3.googleusercontent.com/-XdUIqdMkC[....snipped...]"
   },
   {
      "senderAddress": "[email protected]",
      "photoURL": "https://www.google.com/s2/photos/public/AIbEiAIAAABECJm0[....snipped...]"
   },
   {
      "senderAddress": "[email protected]",
      "photoURL": "https://www.google.com/s2/photos/private/AIbEiAIAAABEiC3Zj[....snipped...]"
   },
   {
      "senderAddress": "[email protected]",
      "photoURL":null
   }
]

I had to inject this code into the body/document, because of a CORS issue. Google's API wasn't accepting the requests because they showed as originating from the extension URL.

I'm having trouble coming up with a sensible way to communicate between the injected script and the extension's content script.

Perhaps I'm overthinking it (very tired right now), and it doesn't need to communicate with the extension script at all? I'm putting it up in a PR to get some input from others. @boukestam @ryanmclaughlin @abasiri

@russelldc russelldc self-assigned this May 7, 2019
russelldc pushed a commit that referenced this issue May 8, 2019
Inject script directly, to avoid CORS issue. Add profile photo option


[#51] Adjust profile lookup request headers, remove unneeded code


[#51] Appends list of cachedProfiles with senderAddress, photoURL pairs


Consistently tabs rather than spaces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants