function addCopyButtons () {
  Array.from(qsAll('pre')).forEach(pre => pre.insertAdjacentHTML('afterbegin', BUTTON))

  Array.from(qsAll('.copy-button')).forEach(button =>
    button.addEventListener('click', () => {
      navigator.clipboard.writeText(button.parentElement.querySelector('code').textContent)
      button.classList.add('clicked')
      setTimeout(() => button.classList.remove('clicked'), 3000)
    })
  )
}
/**
 * Find pre tags, add copy buttons, copy <code> content on click.
 */
Find pre tags, add copy buttons, copy  content on click.
Find pre tags add copy buttons copy content on click .
function addCopyButtons () {
  Array.from(qsAll('pre')).forEach(pre => pre.insertAdjacentHTML('afterbegin', BUTTON))
  Array.from(qsAll('.copy-button')).forEach(button =>
    button.addEventListener('click', () => {
      navigator.clipboard.writeText(button.parentElement.querySelector('code').textContent)
      button.classList.add('clicked')
      setTimeout(() => button.classList.remove('clicked'), 3000)
    })
  )
}
function addCopyButtons ( ) { Array . from ( qsAll ( 'pre' ) ) . forEach ( pre => pre . insertAdjacentHTML ( 'afterbegin' , BUTTON ) ) Array . from ( qsAll ( '.copy-button' ) ) . forEach ( button => button . addEventListener ( 'click' , ( ) => { navigator . clipboard . writeText ( button . parentElement . querySelector ( 'code' ) . textContent ) button . classList . add ( 'clicked' ) setTimeout ( ( ) => button . classList . remove ( 'clicked' ) , 3000 ) } ) ) }
Find pre tags, add copy buttons, copy <code> content on click.
Find pre tags add copy buttons copy <code > content on click .