Gmail extension/gadget API - how to add a button to the compose toolbar?
The Gmail Labs have special permissions because they are written by Google Employees, unfortunately we mortals don't have such power. There is a way around it of course and you've correctly pointed out that it is to make a Chrome Extension or a UserScript. If you choose to do a Chrome Extension it will just be a wrapper for a UserScript anyway
You will have to create and inject the button programmatically. This will involve quite a bit of scouring the Gmail source code (spoiler: it's ugly).
Without more details about what you want to do, I won't be able to provide much more help but I can help you with one problem right away. You have to make your script wait until the Gmail loading process is done which is a bit of a challenge. This is the solution I'm currently using in Minimalist:
function bootstrap() { target = document.querySelectorAll('.vt:not(.SFzvCe)'); if (document.querySelectorAll('html.xiu1Fc, html.aao')[0] == null) { return; } if (target.length > 0) { // loaded, do stuff } else { window.setTimeout(bootstrap, 200); }}window.addEventListener('DOMSubtreeModified', bootstrap);
That version waits for the chat to fully load. Let me know if you have any other questions: @anstosa