Sharepoint - How can i add a custom tab to a ribbon at runtime using javascript/ECMAscript?

Thanks @Gilgamesh because your code has been very useful to me to understand how the whole stuff works! Even if everything wasn't correct, at least it's been helpful during the last 3 days while I was working on it.

Because it's so complicated to create buttons into a Sharepoint ribbon I decided to create a Javascript helper to do it: https://github.com/Aymkdn/RibbonPlus/

I hope it will help others to quickly and easily create tabs and buttons into their Sharepoint ribbon, without being crazy !