inbox-in-gmail
inbox-in-gmail copied to clipboard
When sender is a Gmail/G Suite address, replace Letter icon with their profile picture
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.
@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:

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 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.
Ah neat. fingers crossed
Yeah since it's been replaced by Google+ https://www.insidehook.com/article/apps/google-is-back-from-the-dead-now-called-google-currents
@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 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"
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.
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