I'm looking at creating a Chrome extension that could (for example) hook into Google Drive, insert a DOM element somewhere (e.g. the "Activity Pane"), and display some additional information when a user selects a file.
Presumably Google Drive uses some kind of event-driven UI model - e.g. "when user clicks the preview image for this file, load the "Activity" details for that file and display them in the pane). However, it looks like none of this is documented anywhere (and obviously Google obfuscates its client-side Javascript).
Is there some kind of public API for these events that I can hook into to execute callbacks? Something like:
googleDriveUi.on("fileSelect", function(file) {
alert("You have selected " + file.filename);
});
I realize I could achieve the same result by implementing my own UI frontend and then hooking into the Google Drive backend API. I don't really want to do this if it could be avoided - the Google Drive UI is already pretty good, so there's no need to reinvent the wheel.
An alternative would be to listen to web request events. For example, I see that when a file is clicked in Drive, a request is made to http://{google}/appsactivity/v1.1internal/activities?{etcetc}. An extension can probably listen to requests made to this URL - but presumably Google could change the specific request endpoint at any time, so this would be a pretty flaky solution.
Any other thoughts would be appreciated.
There's no public API to the front end UI events. Some options:
A. The Google Apps Activity API is public and supported. You could get changes formally by making requests there (assuming you had sniffed a file.id by some client-side, undocumented, flaky means).
B. The "right way" is to use the Drive REST API Open Files ("Open with") integration interface but this is dependent on the user having authorised/installed/connected an app via OAuth.
C. Instead of writing an entire front end UI you could just use the Google Picker API. This will give you full control of "the user has selected file.id=xyz".
Option B or C are the closest you can get with full and formally supported APIs.
If you would like Google to add the functionality you need, you can review and/or file a feature request for the Drive API.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With