Копирование текста в буфер обмена на js

Скопировать текст в буфер обмена очень просто, для этого достаточно воспользоваться Async Clipboard API

function copySentText(text) {
    navigator.clipboard.writeText(text).then(function() {
        showNotify('Successfully copied');
    }, function(err) {
        showErrorNotify('Error copied');
    });
}

function showNotify(message, from, background) {

    if (typeof from === 'undefined') {
        from = 'bottom';
    }

    if (typeof background === 'undefined') {
        background = '#111112';
    }
    $.notify({
        icon: 'logo.png',
        message: message,
    }, {
        icon_type: 'image',
        type: 'success',
        animate: {
            enter: 'animated bounceIn',
            exit: 'animated bounceOut'
        },
        placement: {
            from: from
        },
        template: ''
    });
}

function showErrorNotify(message, from, background) {
    background = '#000018';
    showNotify(message, from, background);
}