kartiktalwar / gmail.js Goto Github PK
View Code? Open in Web Editor NEWGmail JavaScript API
License: MIT License
Gmail JavaScript API
License: MIT License
Great job so far on this api, thank you! Noticed that gmail.dom .compose() seems to be missing in the master branch? I was looking for a way to programmatically pop open the compose screen and hopefully specify the subject,body, and recipients. Thanks for your help!
Hi there,
Is it possible to simulate refresh Gmail using this library?
I am using your js file to get the From emails of opened email(multiple threads), but i need to change the email id when user toggled a different thread like rapportive. I tried to use toogle_threads in this way
gmail.observe.on("toggle_threads", function(id, url, body) {
console.log("id:", id, "url:", url, 'body', body);
});
But it didnt worked
Greetings.!
We are a team of avid Google Chrome extension developers. There are a few Chrome extensions we’ve developed that are already in the Chrome store.
At the moment we are working on a new project - developing a Chrome extension for gMail, and we want to add a widget to the left side rail panel along with the Google Chat, Quick Links etc..
we want to know if there is a correct way of adding a Gadget / Widget to this part of the UI
If not; is it possible to notify the gMail internal JavaScript about the status of the Widget (i.e.whether its Open or Closed)
What we need is some JS interface points:
It would be deeply appreciated if you can shed some light on these matters.
When trying to get the compose_ids for compose windows that are "full-screen" (where the background is faded), the function returns a 0-length array.
Hi,
Currently there are two observers to handle email data at its creation.
By creation I mean one of these :
It would be nice to access relevant elements whenever the user starts editing an email. I know this looks UI-oriented, but as it actually triggers draft saving and whatnot as background routine, I'd have thought maybe there's something to track there.
Maybe my use case is a bit too specific, but I try to include a custom control in the body of the edited content (like a custom button), then perform extension-related things using the new content. Finally I try to take into account the new email in the thread right away.
So here we have three relevant things to wish an access for:
api.dom
;api.observe
, passing the new content ;What do you think of this?
Am I missing something already here, or asking too much?
Anyway I don't expect it to be obvious.
Thanks.
So this is a part extension of #39, where 'folded' emails don't contain the email's meta data when running api.get.email_data()
. The check for detecting deleted emails in #41 is checking the existence of the meta data. This intersection returns false positives.
Possible solution:
Sift through api.tracker.email_data
after calling api.get.email_data()
and detect what elements are present/not present in a deleted message vs undeleted message. Instead of doing the x[13] == undefined
check
If conversation view is enabled in gmail, this API is retuning the id of the first email in that thread (looks like the id from location hash)..It will be great if it can return the id of the email that is currently opened in the conversation..
(By default its the last email in the conversation)
There now exists a pre and post request callback but we need to document it
Would be nice to have triggers when an email is opened. Can be done by watching the http request that retrieves email content?
If I use a gmail.get.email_data()
inside an open_email
observer it works the first time but in subsequent email opens, the email_data() returns an empty object. Some sort of race condition perhaps?
For now, by looking at the code, only US English interface is supported as some elements are explicitly referred through their attributes values (like "Inbox").
However, when another locale is in use, some functionalities are supposed to fail.
For example, "Inbox" becomes "Boîte de réception" in French. This results, among other things, in a counting of inbox unread emails being 0 while there are some.
Does it seem a probable thing, in a near future, to support the interface regardless of the language? Maybe by refactoring all such attribute values and picking the actual values using an initial locale parameter.
That may not be a priority, but as I know I'll need that very soon, I might consider proposing a solution. If it's planned then, awesome.
Please add a function to delete emails. I have some folders with several tens of thousands of emails and gmail will always eventually respond with some error code if I try to delete them all at once.
A way to run a loop which 1. select all emails on a page 2. deletes them, until there are no more emails in this folder/label would finally help me to get rid of them.
The corresponding shortcut would be *a#
.
I have tried various ways to modify the body in gmail.observe.before('send_message'...
but am not having any luck. It seems that modifying the body prevents gmail from sending the message. Modifying the subject as per boilerplate works fine, however.
Is it possible to do this?
I'm writing a chrome extension and trying to incorporate Gmail.js.
I have jquery injected in the manifest under content scripts first, then gmail.js, then my content script - which has the following line at the top...
var gmail = Gmail();
For some reason, on trying to use gmail.get.user_email();
in chrome dev tools JS console, I get gmail is not defined though it is evident that the content script is executing based on effects of code blocks of other lines of the content script being seen in the view.
act=rtr
body:m=hash
Anyone else experiencing this error, and/or have a solution for it?
ReferenceError: GLOBALS is not defined
at Gmail (http://localhost:3000/js/mvc.js:45:130)
at Scope.$scope.listMessages (http://localhost:3000/js/mvc.js:47:17)
at http://localhost:3000/js/angular.js:10822:21
at http://localhost:3000/js/angular.js:19816:17
at Scope.$eval (http://localhost:3000/js/angular.js:12724:28)
at Scope.$apply (http://localhost:3000/js/angular.js:12822:23)
at Scope.$delegate.proto.$apply (:855:30)
at HTMLButtonElement. (http://localhost:3000/js/angular.js:19815:21)
at http://localhost:3000/js/angular.js:2890:10
at forEach (http://localhost:3000/js/angular.js:327:20) tracker.js:8
a.(anonymous function) tracker.js:8
(anonymous function) angular.js:10033
(anonymous function) angular.js:7394
Scope.$apply angular.js:12824
$delegate.proto.$apply VM2309:855
(anonymous function) angular.js:19815
(anonymous function) angular.js:2890
forEach angular.js:327
eventHandler angular.js:2889
d.util.hasFunction.f.(anonymous function)
I'm not sure if this is a known issue, but I don't see any notice of it so I'm posting an issue:
Attempting to inject via console throws the error below. It looks like gmail is blocking all third party scripts?
[Report Only] Refused to load the script 'https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'unsafe-eval' https://talkgadget.google.com/ https://www.googleapis.com/appsmarket/v2/installedApps/ https://www-gm-opensocial.googleusercontent.com/gadgets/js/ https://docs.google.com/static/doclist/client/js/ https://www.google.com/tools/feedback/ https://s.ytimg.com/yts/jsbin/ https://www.youtube.com/iframe_api https://ssl.google-analytics.com/ https://apis.google.com/_/scs/abc-static/ https://apis.google.com/js/ https://clients1.google.com/complete/ https://apis.google.com/_/scs/apps-static/_/js/ https://ssl.gstatic.com/inputtools/js/ https://ssl.gstatic.com/cloudsearch/static/o/js/ https://www.gstatic.com/feedback/js/ https://www.gstatic.com/common_sharing/static/client/js/ https://www.gstatic.com/og/_/js/".
Is it possible to grab the sender email from the inbox index view of the GMail interface?
We should use jQuery's .text()
for max compatibility.
I have put together some code for using gmail.js as part of a chrome extension. It all seems to work just fine, however none of the gmail.observe functions seem to do anything. I have tried entering them into the console just as you have outlined in the readme.
Example:
gmail.observe.on("star",function() {
console.log("it worked");
} );
When I then star an email, nothing happens. Am I using this wrong or is it a bug?
Just FYI you have this in your Readme.md and it's not actually a method
Hey,
We are looking to modify the dom of compose windows but it looks like the DOM function for Compose(s) is unavailable in the newest release?
> gmail.dom
< Object {inbox_content: function, inboxes: function, email_subject: function, email_body: function, email_contents: function…}
> gmail.dom.composes()
< TypeError: undefined is not a function
Per the Readme example, I've looked into the source code and found that the function for this is simply function () {
as opposed to function(id) {
.
There is an additional ')' on line 645 of gmail.js in the latest commit.
Hi there,
In #43 and #44 we dealt with email status, and the need to differentiate what's fully visible / partially visible / hidden / deleted in a conversation.
But I had not thought about the case when conversation view is off (via settings), in which each email is seen in separate views. But even then, metadata include the whole thread and what the user sees is not what is actually handled.
I don't remember if it's been mentioned before, but a is_in_current_view
email property would be nice.
Or maybe an alternative way of parsing emails (like api.get.current_email_data()
).
Maybe you should create a bower package?
I added this code (as per the readme file), and nothing is logged to the console window when I add or change recipients in a new compose window:
gmail.observe.on('recipient_change', function(match, recipients) {
console.log( 'recipients changed', match, recipients);
});
I get errors with certain functions. You might need to update the README.
Does Gmail support for multi account detection ?
A Gmail user can login to multiple accounts at a time and switch UI accordingly. We want to display some plugin data based on current gmail account.
How do we identify which email account is open right now, Dos the gmail.js object instance has ability to identify this when it would become a part of some chrome extension ?
"Get email data" is missing to, cc and bcc..Instead you have "people involved" ..Is this a limitation?
I'm log'd into gmail.. probably something super simple
I am using get.email_data, and the people_involved object has the correct recipients listed, but in the thread object for the same email (only one thread, new compose window), the To array only has the first recipient listed; none of the other recipients are there.
Please see this screenshot: http://cl.ly/image/1t1r2d1k0g0a
Thanks!
You may have heard that raplets inside of rapportive are being deprecated, I'm looking to build a drop in replacement chrome plugin which is compatible with the raplet spec, and this lib looks like it could do almost all of the heavy lifting. All it's needs is a way of observing when an email is hovered when inside a thread, either an email address in the to, cc, or bcc fields, or an email within the email body.
In gmail full screen view, for example when clicking on a "mailto:" link, the global var "VIEW_DATA" is not defined.
To see the full screen view, see https://mail.google.com/mail/u/0/?view=cm&fs=1&tf=1&source=mailto&[email protected]
Would you be able to give an example of how to use this and access the different parameters of the requests? I'm presuming it can be used to access the details of the most recently sent email?
Thanks for creating this btw, it is really useful!
Hi,
In a context of threaded emails, you can delete specific emails and thus they get removed from that thread.
However, when using gmail.get.email_data()
, all emails are considered, including the deleted ones.
That may be a good thing when it comes to handling all emails of a thread regardless of their deletion state.
But when it comes to actually parsing what's currently here on the interface, it's a problem.
I thought it could be an option, to ask for emails including or excluding the deleted ones.
In the process, I guess that would be a separate issue but as it's about deletion...
Is it / would it be possible to observe deletion events on individual emails, not entire threads?
Thanks. (:
I'm building an app that requires modifying email body. The url.cmml parameter represents the length of body string. If body is changed, url.cmml needs to be updated to new body length, otherwise gmail server will not send the email.
I saw the comments in api.tools.xhr_watcher():
// TODO: recreate the url if we want to support manipulating url args (is there a use case where this would be needed?)
However, url is passed in win.XMLHttpRequest.prototype.open(), while email body is passed in win.XMLHttpRequest.prototype.send(). If I modify the body, I only find out about body in send(), which happens after open().
Any ideas on how to handle this?
When reading an email, previous emails are folded (i.e. their content is hidden).
You can have two levels of folding: simple (for the first and penultimate ones, when more than 3 previous emails) and grouped for all those in between.
However the to
array isn't filled with recipients' email addresses for those in grouped folding.
Hello,
I have an observer for the send_message event where I can get data like the composeid and draftid. But for my use case, I would also want to get the email Id of the sent email.
Upon checking the xhr response for the send_message request the email id is indeed included. Is there a way to read and parse these responses like how xhr_watcher is doing?
Thanks,
Gino
I suggest keeping track of the version number of gmail.js, and making that accessible via the API, so users can do:
gmail = Gmail();
gmail.version // returns "1.0.0" or something similar
jQuery enables something similar with jQuery().jquery
.
Hey! Awesome lib...any chance when you get the threads to know which are open, and which aren't?
Also, any idea when the expand_email
event will be stable?
I'm attempting to write a chrome extension using Gmail.js. Thank you!
I use the sample code:
var gmsrc = document.createElement('script');
gmsrc.src = "https://xmailchrome.appspot.com/gmail.js";
document.getElementsByTagName('body')[0].appendChild(gmsrc);
console.log("Scripts loaded, Start playing ...");
But when I start playing it says: Uncaught reference error: Gmail is not defined.
In the chrome console, after the script is ran... Gmail is defined. Just not when the code below 'start playing' is ran.
Basically I just want to use the Gmail.js onload.
Thanks!
api.tracker.globals = GLOBALS;
Uncaught ReferenceError: GLOBALS is not defined. What should I be doing to fix this?
Gmail.js must be run in a content script for chrome extensions. How would I pass the information from Gmail.js to the popup of the main extension?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.