Last active
May 18, 2018 06:21
-
-
Save pagetronic/f65aa82d82964f2b7757077063f05437 to your computer and use it in GitHub Desktop.
Add source link to copy/paste copyfuckers
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
var copy = function () { | |
var article = document.getElementById('article'); | |
if (article != null) { | |
article.addEventListener('copy', function (e) { | |
e.preventDefault(); | |
try { | |
var selection = window.getSelection(); | |
e.clipboardData.setData('text/plain', $('<div/>').html(selection + "").text() + "\n\n" + 'Source: ' + document.location.href); | |
e.clipboardData.setData('text/html', selection + '<br /><br />Source: <a href="' + document.location.href + '">' + document.title + '</a>'); | |
} catch (err) { | |
} | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment