Skip to content

Instantly share code, notes, and snippets.

@goranefbl
Created May 28, 2025 11:40
Show Gist options
  • Save goranefbl/493ac57be483d0b5b518d8685a0a9d2d to your computer and use it in GitHub Desktop.
Save goranefbl/493ac57be483d0b5b518d8685a0a9d2d to your computer and use it in GitHub Desktop.
copy link
<script>
document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('.wpgens-raf-simple-shortcode').forEach(function (el) {
el.addEventListener('click', function (e) {
e.preventDefault();
const textToCopy = el.href;
navigator.clipboard.writeText(textToCopy).then(() => {
const originalText = el.textContent;
el.textContent = 'Copied!';
setTimeout(() => {
el.textContent = originalText;
}, 2000);
}).catch(err => {
console.error('Failed to copy text: ', err);
});
});
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment