Adding copy to clipboard button to every google code prettify pre blocks in blogger
It's a 2 part process: The script part to find all the pre blocks having code in it and append a copy button to it dynamically. The style part to place our copy button at the specified location(on top right of every code block in this case) The script part: <script> var pre = document.getElementsByTagName('pre'); for (var i = 0; i < pre.length; i++) { var button = document.createElement('button'); button.className = 'copy-button'; button.textContent = 'Copy'; var s = pre[i].innerText; button.setAttribute("data-clipboard-text",s); pre[i].appendChild(button); } var clipboard = new Clipboard('.copy-button'); clipboard.on('success', function(e) { console.info('Action:', e.action); console.info('Text:', e.text); console.info('Trigger:', e.trigg