a jelikož se ten skript blbě kopíruje a vyžaduje další úpravy, vytáhl jsem z komentářů a poupravil tuhle verzi
function ribbon_init() {
    var ribbon = (SP.Ribbon.PageManager.get_instance()).get_ribbon();
    alert(SP.Ribbon.PageManager.get_instance());
    createTab(ribbon);
}
function createTab(ribbon) {
    var tab = new CUI.Tab(ribbon, 'Sample.Tab', 'Sample', 'Tab Description', 'Sample.Tab.Command', false, '', null, null);
    ribbon.addChild(tab); 
    var group = new CUI.Group(ribbon, 'Sample.Tab.Group', 'Sample Actions', 'Group Description', 'Sample.Group.Command', null);
    tab.addChild(group);
    var layout = new CUI.Layout(ribbon, 'Sample.Layout', 'The Layout');
    group.addChild(layout);
    var section = new CUI.Section(ribbon, 'Sample.Section', 2, 'Top'); //2==OneRow
    layout.addChild(section);
    var controlProperties = new CUI.ControlProperties();
    controlProperties.Command = 'Sample.Button.Command';
    controlProperties.Id = 'Sample.ControlProperties';
    controlProperties.TemplateAlias = 'o1';
    controlProperties.ToolTipDescription = 'Use this button';
    controlProperties.Image32by32 = '/_layouts/images/placeholder32x32.png';
    controlProperties.ToolTipTitle = 'A Button';
    controlProperties.LabelText = 'Something';
    var button = new CUI.Controls.Button(ribbon, 'Sample.Button', controlProperties);
    var controlComponent = button.createComponentForDisplayMode('Large');
    var row1 = section.getRow(1);
    row1.addChild(controlComponent);
    group.selectLayout('The Layout');
    SelectRibbonTab('Sample.Tab', true);
}
SP.SOD.executeOrDelayUntilScriptLoaded(function () {
    var pm = SP.Ribbon.PageManager.get_instance();
    pm.add_ribbonInited(function () {
        ribbon_init();
        /* Register classes and initialize page component */
        SamplePageComponent.registerClass('SamplePageComponent', CUI.Page.PageComponent);
        SamplePageComponent.initializePageComponent();
        //NotifyScriptLoadedAndExecuteWaitingJobs('SamplePageComponent.js');
    });
}, "sp.ribbon.js");
try
{
    /* Initialize the page component members */
    SamplePageComponent = function () {
        SamplePageComponent.initializeBase(this);
    }
    SamplePageComponent.initializePageComponent = function () {
        var ribbonPageManager = SP.Ribbon.PageManager.get_instance();
        if (null !== ribbonPageManager) {
            var rbnInstance = SamplePageComponent.get_instance();
            ribbonPageManager.addPageComponent(rbnInstance);
        }
    }
    SamplePageComponent.get_instance = function () {
        if (SamplePageComponent.instance == null) {
            SamplePageComponent.instance = new SamplePageComponent();
        }
        return SamplePageComponent.instance;
    }
    SamplePageComponent.prototype = {
        /* Create an array of handled commands with handler methods */
        init: function () {
            var buttonEnabled = false;
            this._handledCommands = new Object();
            this._handledCommands['Sample.Tab.Command'] = { enable: function () { return true; }, handle: function (commandId, props, seq) { /* do action */ } };
            this._handledCommands['Sample.Group.Command'] = { enable: function () { return true; }, handle: function (commandId, props, seq) { /* do action */ } };
            this._handledCommands['Sample.Button.Command'] = { enable: function () { return true; }, handle: function (commandId, props, seq) { /* do action */ } };
            this._commands = ['Sample.Tab.Command', 'Sample.Group.Command', 'Sample.Button.Command'];
            $('#buttonEnable').click(function () {
                buttonEnabled = !buttonEnabled;
                var ribbon = SP.Ribbon.PageManager.get_instance().get_ribbon();
                ribbon.setFocusOnRibbon();
                ribbon.pollForStateAndUpdate();
                SelectRibbonTab('Sample.Tab', true);
            });
        },
        getFocusedCommands: function () { return []; },
        getGlobalCommands: function () { return this._commands; },
        canHandleCommand: function (commandId) {
            var handlerFn = this._handledCommands[commandId].enable;
            if (typeof (handlerFn) == 'function') {
                return handlerFn();
            }
            return true;
        },
        handleCommand: function (commandId, properties, sequence) {
            return this._handledCommands[commandId].handle(commandId, properties, sequence);
        },
        isFocusable: function () { return false; },
        yieldFocus: function () { return false; },
        receiveFocus: function () { return true; },
        handleGroup: function () { }
    }
}
catch(error)
{
    alert(error);
}