Html Anti Copy
Table of Contents
Typos preserved from the original source. Also see it at Tabnews ↗.
nimble install htmlAntiCopy
Below the original post.
In this post we'll see in action an library that prohibits you to copy HTML text, even on devtools!
See this example, try to copy the following text:
HelRGGlo8 WoIr8iWld! 2QXUPQDSuch interesting thing right?
Let's see how to reproduce
To generate a shuffled text like above is very simple, just call `shuffle`, let's see:
import pkg/htmlAntiCopy let shuffled = shuffle "Try to copy me! Let's see if you're a real hacker :P"
But now we need an usable output, so we can use `toHtml`:
let html = shuffled.toHtml echo html
Easy as that!
Why?
This method doesn't block expert users to copy, it's intended to prevent bots and regular users to copy some text content.
How it works?
Now you may be curious to see how it works, right? So let's check it out!
The output of this program is an HTML, as you saw in the name, here's an small example of an possible output for shuffling "Hi":
<style> div.abc i:nth-child(2) { font-size: 0; } </style> <div class="abc"> <i>H</i> <i>l</i> <i>i</i> </div>
So, what it does is add random chars inside the text and wrap each char in a
italic element inside a container with a random class, because the tag name is small.
Then an CSS hides the random generated chars by index!
It's also possible to increase "shuffle level" to increase the random chars in the text!
Let's increase a little bit!
HEnBMkAK9HExim_z5GubgHEeoIA_xHYM9YzZMrEJ PoJjtPY5FD bYiwXpmtRGt3IejYJem7RSHpea_erG_nMqYl3L VlVammQT_e0308XxxJNQZVk DqA0SJXqsos9AgryCfkkrXj624F7jiLUZy4ubASBuQViSFghX3TxFkQfysdxenzOZA1adcpC1xJj9oDDhPFewgFheOEQhgh_EECJcRh8 xGf Fz4C4MOtQzyGcIbmbcKAQve2DmyyhE4cG6DEm5Q6TG1VWEHbrbJg9LR4PnxKv6ptXmy5lxH Wl31LAXFo BAH FyyKsgDeiIpkZU TGhDFh61dA1kJwGRaxTUpq0Li8v2d0nX_h4l60 JWM2yXEebBa_9LbbvmhaWkSeeiMBaoGZ6srS?T5l3O0JFun time
Let's play a bit with this!
Can I bypass it?
Yes, every technology has a flaw, in this case, we saw that we choose which char will be hid with CSS, so, in order to bypass it, you can parse the CSS selector to get the random chars indexes and remove if from HTML.
But it's very specific, bots and common users wouldn't be able to copy.
Or just use OCR, but to try prevent it, the text needs to be partially unreadable and this affects the user experience.
Finalization
If you want to know more about this library, see the project repo at thisago/htmlAntiCopy ↗ (GitHub)