If you can do whatever you want as a browser plugin on top of Gmail, tracking and monitoring what is happening, you can take a look at this. He will not do what you ask, but he will take you somewhere along the way.
Gmailr
Unfortunately, you probably need a server. Even if you can work around issues between domains, the Gmail interface is mostly built dynamically with JavaScript when the page loads. Thus, the names of JavaScript functions will change literally all the time.
Almost everyone does something like what you describe (we provide an alternative Gmail interface, as well as emailga ) this route. I also know the OtherInbox guys, and they have a server component that uses the IMAP interface for most of their magic.
source share