Some websites now use a JavaScript service from Tynt that appends text to copied content. I am using Wordpress and want some Javascript that Prevent users to copy whole content. I want to limit number of characters and put read more link on Copied text. Is there any Javascript Solution. I am currently using this code, but it is not working properly.
var selection = window.getSelection(),
pagelink = '<br /><br /> Read more at: ' + document.location.href,
copytext = selection.substring(0,200) + pagelink,
newdiv = document.createElement('div');
var range = selection.getRangeAt(0);
newdiv.style.position = 'absolute';
newdiv.style.left = '-99999px';
document.body.appendChild(newdiv);
newdiv.innerHTML = copytext;
selection.selectAllChildren(newdiv);
window.setTimeout(function () {
document.body.removeChild(newdiv);
selection.removeAllRanges();
selection.addRange(range);
}, 100);
}
document.addEventListener('copy', addLink);
Kindly Modify or provide new code.