Created
May 19, 2024 21:29
-
-
Save abenezerBelachew/b11e66ef65406d78bfb2c66f6d0277c9 to your computer and use it in GitHub Desktop.
Add source to copied text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('copy', function(event) { | |
var selectedText = window.getSelection().toString(); | |
var pageLink = "\nSource: " + document.location.href; | |
var copyText = selectedText + pageLink; | |
event.clipboardData.setData('text/plain', copyText); | |
event.preventDefault(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment