Add copy buttons to all code blocks on any website
// ==UserScript==
// @name Auto Copy Code Blocks
// @namespace https://flowkit.dev
// @version 1.0
// @description Add copy buttons to all code blocks on any website
// @author FlowKit
// @match *://*/*
// @license MIT
// @grant none
// ==/UserScript==
(function() {
'use strict';
document.querySelectorAll('pre code, pre').forEach(b => {
const btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:4px 8px;background:#667eea;color:#fff;border:none;border-radius:4px;cursor:pointer;font-size:12px';
btn.onclick = () => { navigator.clipboard.writeText(b.textContent); btn.textContent = 'Copied!'; setTimeout(() => btn.textContent = 'Copy', 1500); };
b.parentElement.style.position = 'relative';
b.parentElement.appendChild(btn);
});
})();