Show HN: Gmail.js – JavaScript API for Gmail

  • Unfortunately this type of hacking isn't really sustainable. Even small tweaks to the Gmail UI often change the DOM in very unpredictable ways. When they released the new compose feature, pretty much every single Gmail Chrome extension broke.

    We haven't really announced it yet, but I've been working on a new email platform with some friends to solve a lot of these issues. It's essentially Rails/Meteor for email features, and lets you skip past hacking Gmail or writing a full IMAP client.

    It's called Inbox, and we're aiming to open source it in January. Ping me if you're interested in playing with it early. :)

  • It would be amazing if this were a service. Easier said than done, I know -- but, basically this but have it check a JSON file every few hours and gets the updated selectors.

    (For people who don't know, all GMail's classes and IDs are things like '.xb3', and they change often.)

    Having worked on Mozilla Add-ons for a long time, one of the biggest problems was by the time any G-Mail add-on was approved, it was already out of date again. API calls, when done correctly, are allowed by both Chrome and Firefox -- this could be a good solution.

    (You could easily charge a few bucks for this, and even contact Firefox + Chrome about making sure the reviewers allow it. Market it as "cutting down on their time" since there will be less to review.)

  • Interesting - and a very good job given what you have to work with. Surely its incredibly brittle, though? As soon as they release a new version of Gmail it's going to fail.

    But then, I suppose that's how most Chrome extensions work.

  • Thanks for making the library, glad to see you put lots of time into the docs too. Hopefully the can of worms you've opened doesn't drive you crazy, personally I would've stopped the second I found myself writing something like this...

    $($($($('.nH .if').children()[1]).children()).children()[1]).children()[1]

    :)

    [1]https://github.com/KartikTalwar/gmail.js/blob/master/src/gma...

  • Author of Gmailr here, which apparently inspired this project. Kudos! Glad to see someone taking the ball and running with it. I haven't had time to update Gmailr lately, as it is something that needs active maintenance. The main challenge here is that Gmail will have continue to have bursts of updates that break extension libraries, with relatively long periods of stability.

  • I'm curious why you'd use the DOM instead of making API calls to the server. If Google can do it as part of their UI surely a 3rd party script can too. Is the API more complex than the frequently changing DOM?

  • Hi Kartik, Gmelius (http://gmelius.com) developer here! Great stuff. Will be glad to help you maintain the API up-to-date, if you wish so :)

  • This is pretty useful. A couple months ago I started making a free self-hosted version of Boomerang for Gmail, but lost interest because I felt like I would have to devote most of my time to gmail's idiosyncrasies. Maybe it's time to get back to work.

    Is there a way to add navigation events (eg. user opened email) to the observe gmail.observe API? Right now it looks like I would have to poll gmail.check.is_inside_email.

  • These projects are already pretty advanced versions of this:

    https://github.com/jamesyu/gmailr and https://github.com/joscha/gmailui

    In fact gmailr is used in "Cloudy" - one of the more advanced gmail plugins.

  • I use Selenium tests that run on a cron job to check for elements on third-party websites. This works great and I am able to keep the extension mostly up to date. One of the issues I have come up against is when a third-party A/B tests. I usually have to hack around and find an account with the B portion to make sure everything works.

  • Your name sounded very familiar, finally realized from where after reading the recent opendata email! Great job on this and the OpenDataUW API stuff. I am also admiring the PHP Scraper Class as I was planning on writing something similar.

  • This is awesome.

  • I'd love to use this but I can't figure out what's the action/event for when I open an email to read it. I'm sure it's there, I just can't see it ..

  • Did you know there is a remote API for Gmail which is compatible with Exchange, Outlook.com, yahoo mail and every other mail provider out there?

    It's called IMAP/SMTP!

  • This looks awesome. You should make a demo extension and open source it to show some of the applications that can be built on top of it.

  • Similar in some ways to api that is in streak.com

  • Been looking for something like this! Perfect. Thanks for the effort!

  • You probably know more about Gmail then you ever wanted to, right?

  • I would love if someone make it to work by using oAuth in js.

  • undefined

  • I don't understand the potential..