let copyTrigger = document.getElementById('copy_body_button')
let copyContent = document.querySelector('main')
copyTrigger.addEventListener('click', () => {
// Create a new clipboard item
const item = new ClipboardItem({
// The clipboard item can hold multiple formats
// In this case we're encoding the body as HTML for use with CMD+V (paste)
'text/html': new Blob([copyContent.innerHTML], {
// And we're encoding a plaintext version for use with CMD+ALT+V (paste without formatting)
'text/plain': new Blob([copyContent.innerText], {
// Push it to the clipboard and handle success/failure signals
navigator.clipboard.write([item]).then(
console.log('Async: Copying to clipboard was successful!')
console.error('Async: Could not copy text: ', err)