function saveButton(text) {

    // get object for given skill id
    chrome.storage.local.get([skillId], function(result) {
        if (result && result[skillId] && result[skillId].buttons) {
            localeButtons = result[skillId].buttons[locale];

            // push to existing or create new
            if (localeButtons) {
                if (!localeButtons.includes(text)) {
                    localeButtons.push(text);
                }
            } else {
                result[skillId].buttons[locale] = [text];
            }
            chrome.storage.local.set({[skillId]: result[skillId]}, function () {
                addButton(text);
            });
        } else if (result && result[skillId]) {
            result[skillId].buttons = {
                [locale]: [text]
            };
            chrome.storage.local.set({[skillId]: result[skillId]}, function () {
                addButton(text);
            });
        } else { // create new object for given skill id
            const obj = {
                buttons: {
                    [locale]: [text]
                },
                history: {
                    [locale]: []
                },
            };
            chrome.storage.local.set({[skillId]: obj}, function() {
                addButton(text);
            });
        }
    });
}
/**
 * Saves button to synced chrome storage
 * @param text
 */
Saves button to synced chrome storage
@param text
Saves button to synced chrome storage @param text
function saveButton(text) {
    chrome.storage.local.get([skillId], function(result) {
        if (result && result[skillId] && result[skillId].buttons) {
            localeButtons = result[skillId].buttons[locale];
            if (localeButtons) {
                if (!localeButtons.includes(text)) {
                    localeButtons.push(text);
                }
            } else {
                result[skillId].buttons[locale] = [text];
            }
            chrome.storage.local.set({[skillId]: result[skillId]}, function () {
                addButton(text);
            });
        } else if (result && result[skillId]) {
            result[skillId].buttons = {
                [locale]: [text]
            };
            chrome.storage.local.set({[skillId]: result[skillId]}, function () {
                addButton(text);
            });
        } else { 
            const obj = {
                buttons: {
                    [locale]: [text]
                },
                history: {
                    [locale]: []
                },
            };
            chrome.storage.local.set({[skillId]: obj}, function() {
                addButton(text);
            });
        }
    });
}
function saveButton ( text ) { chrome . storage . local . get ( [ skillId ] , function ( result ) { if ( result && result [ skillId ] && result [ skillId ] . buttons ) { localeButtons = result [ skillId ] . buttons [ locale ] ; if ( localeButtons ) { if ( ! localeButtons . includes ( text ) ) { localeButtons . push ( text ) ; } } else { result [ skillId ] . buttons [ locale ] = [ text ] ; } chrome . storage . local . set ( { [ skillId ] : result [ skillId ] } , function ( ) { addButton ( text ) ; } ) ; } else if ( result && result [ skillId ] ) { result [ skillId ] . buttons = { [ locale ] : [ text ] } ; chrome . storage . local . set ( { [ skillId ] : result [ skillId ] } , function ( ) { addButton ( text ) ; } ) ; } else { const obj = { buttons : { [ locale ] : [ text ] } , history : { [ locale ] : [ ] } , } ; chrome . storage . local . set ( { [ skillId ] : obj } , function ( ) { addButton ( text ) ; } ) ; } } ) ; }
Saves button to synced chrome storage
 @param text
Saves button to synced chrome storage @param text
// get object for given skill id // push to existing or create new // create new object for given skill id