Hacker News new | ask | show | jobs
by nbush 4356 days ago
Cool, I love counterintuitive (and even counterproductive) solutions just for their own sake. I tried to do a similar thing with text a while ago: http://nbush.github.io/headache/
3 comments

"Tired of people stealing your content? Looking to make copying HTML text a huge pain for your users? Sick and tired of useful, well-made Python scripts? Headache will make it so users cannot select, copy or paste html text without getting a bunch of garbage as well. Try copying this sentence. No, seriously, try it. Yeah that's right. Now try pasting it somewhere.

Now the only way you can steal my sweet, sweet content is by writing it out letter by letter or writing your own noble script that filters out all the junk. Checkmate.

You might say that this solution is unintuitive, massively inefficient and completely unnecessary. Well that's not the true Hacker Spirit now, is it? " ;)

As a challenge I wanted to see how hard it would be to circumvent this. Here's a bookmarklet: javascript:void(function(s,i){for(i=0;i<s.length;i++)if(window.getComputedStyle(s[i]).color=='transparent')s[i].style.display='none'}(document.getElementsByTagName('span')))

That should be one line with no spaces if gets line wrapped.

Nice work! Here's another solution posted in an earlier thread: javascript:d=document.createElement("div");d.innerHTML="<style>span:nth-child(odd) {display:none;}</style>";document.body.appendChild(d);

I don't think there's any easy way for the obfuscation to stay ahead of JS reversal. Thanks for taking a look!

This is clever! I think it can be circumvented by removing all spans in a paragraph with more than 1 character.
Thanks! Yeah, there are many JS ways around this, but it would be more than enough to stop most people... including myself in most cases.