use gmail api with tampermonkey/javascript

337 views
Skip to first unread message

bernd3

unread,
Mar 11, 2023, 8:01:59 AM3/11/23
to Chromium Extensions
Hi, I know that this is a forum for chrome extensions mainly but I hope someone can still help me.
I want to built some super simple tamermonkey script that sents an mail from my gmaila dress to another given adress.
Already got the api key, client id and that stuf (hopefully also correctly setup).
I literally jsut copied the code from the official quick start guide for gmail api+javascript from
https://developers.google.com/gmail/api/quickstart/js
only intead of having script tags in a html file, I create and inject those script tags into the head with javascript.

no matter what I do, there are always errors of the kind
"Uncaught (in promise) TypeError: Cannot read properties of null (reading 'style')".

What am i doing wrong?
is my code wrong?
or did I mess up when creating the api key and such, so the stuff returned during the requests is nonsense?
Please help me, I'd appreciate it! :-)

PhistucK

unread,
Mar 12, 2023, 9:26:23 AM3/12/23
to bernd3, Chromium Extensions
StackOverflow can help you with that, generally, as this is a general web development problem.
By moving the script to <head>, you make it run before the rest of the HTML is parsed, so the elements it references by ID do not exist in the DOM yet.

PhistucK


--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/15fd22d2-010d-4170-9ddf-e78368e05eadn%40chromium.org.
Reply all
Reply to author
Forward
0 new messages