Yo,
Alright been noodling on this one for a while: How copy/cut styled text without bringing along any style baggage (background-color, color, etc)?
Couple of routes of attacks that have been foiled:
Anyway, thoughts? Seems like it would be very useful for sites that have white background colors.
Given current browser capabilities, you can intercept the copy event, get the selection without style, and put that into the clipboard.
I've tested this code with Chrome/Safari/Firefox. Believe is should work on MS browsers as well.
document.addEventListener('copy', function(e) {
const text_only = document.getSelection().toString();
const clipdata = e.clipboardData || window.clipboardData;
clipdata.setData('text/plain', text_only);
clipdata.setData('text/html', text_only);
e.preventDefault();
});