inbox-in-gmail icon indicating copy to clipboard operation
inbox-in-gmail copied to clipboard

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

Open russelldc opened this issue 5 years ago • 9 comments

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 avatar Apr 15 '19 21:04 russelldc

@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

russelldc avatar Apr 15 '19 21:04 russelldc

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.

ryanmclaughlin avatar Apr 16 '19 16:04 ryanmclaughlin

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

joeytroy avatar Apr 16 '19 16:04 joeytroy

Ah neat. fingers crossed

ryanmclaughlin avatar Apr 16 '19 17:04 ryanmclaughlin

Yeah since it's been replaced by Google+ https://www.insidehook.com/article/apps/google-is-back-from-the-dead-now-called-google-currents

joeytroy avatar Apr 16 '19 17:04 joeytroy

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

russelldc avatar Apr 16 '19 17:04 russelldc

@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"

ryanmclaughlin avatar Apr 16 '19 17:04 ryanmclaughlin

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 avatar May 04 '19 13:05 russelldc

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:

fetchProfilePhoto(['[email protected]', '[email protected]', '[email protected]'])

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 avatar May 04 '19 18:05 russelldc