KartikTalwar / gmail.js

Gmail JavaScript API
MIT License
3.74k stars 455 forks source link

get.user_email() no longer works? #734

Closed AvnerCohen closed 6 months ago

AvnerCohen commented 1 year ago

I can't seem to get user_email or manager_email to work.

Any chance there was a UI change that caused it to break?

josteink commented 1 year ago

I'm not able to reproduce this. Anyone else?

AvnerCohen commented 1 year ago

Thanks @josteink For checking that! Here is what I am seeing, when stopping inside a gmail.observe.on("recipient_change", ... break point:

image
josteink commented 1 year ago

Looking at the code, it seems all this is supposed to be extracted from gmail.tracker.globals.

How does that look on your end?

AvnerCohen commented 1 year ago

Seems empty ..

image
josteink commented 1 year ago

If so, that might make some other things stop working too…

If anyone can find an appropriate css-selector to fall back to, I guess we could add that as a fallback?

AvnerCohen commented 1 year ago

UI changed, using the following ugly-as-hell as a workaround:

  let mainObj = Array.from(document.querySelectorAll('div')).find(el => el.textContent === 'Google Account');
  var email = mainObj ? mainObj.parentNode.childNodes[2].innerText : 'N/A';

I am really surprised this is only happening to me...

josteink commented 1 year ago

If that works for you... How about making it into a PR? :smile:

To be clear: I've tested it in the dev-console on my machine and it seems to work.

AvnerCohen commented 1 year ago

Yeah, but I think this (wrong) solution assume English as the gmail language, for example. Not something that is really scalable.. I am sure there are better ways to do that. But I 1st love to know if this is even happening to other people..

MattIrineu commented 1 year ago

gmail.get.user_email() only returns undefined, it doesn't seem to work anymore, anyone with a workaround for it?

Thank you!

josteink commented 1 year ago

A short status update, based on a new duplicate bug-report.

Using the boilerplate and latest gmail.js, I've tested on three different google accounts, using Google Chrome, on Linux:

On neither of those accounts can I reproduce this issue.

If this is an issue to you, you will probably have to do the debugging yourself, and try to reverse engineer another way to obtain the email and create a PR for it.

There's not really much I can do on my end.

AvnerCohen commented 1 year ago

Thanks @josteink yeah, it's been a while :) but I eventually got to try and find out what might be going on in here.. I got stuck pretty quickly I afraid..

I see the get method: https://github.com/KartikTalwar/gmail.js/blob/master/src/gmail.js#L121

But I can't seem to find out where does this global ([10]) is ever being set...

Any suggested pointers ?

josteink commented 1 year ago

Globals are things set in the global window-namespace by Gmail itself.

We dump it, investigate it, reverse-engineer it, and put that into our code.

We never set globals ourself.

josteink commented 11 months ago

Still not able to reproduce this issue. Closing for now.

Please re-open if you still have this issue, and know how to reproduce :)

josteink commented 6 months ago

Confirming I can reproduce this issue now. I can only reproduce on a grandfathered Google Apps account, but not others Weird.

josteink commented 6 months ago

Fix published in 1.1.13.