CSS-based anti-copy method

Discussion in 'Tech Discussion' started by noisypixy, Aug 25, 2017.

  1. noisypixy

    noisypixy Sacatunn que pen, que summum que tun.

    Joined:
    Jun 25, 2016
    Messages:
    716
    Likes Received:
    950
    Reading List:
    Link
    Yeah, and in the end everything is useless against OCR, so ¯\_(ツ)_/¯

    Oh, and 50% of my full-time job is scraping (the other 50% is making sense of that scraped data), so doing this kind of thing helps me to get more familiar with different approaches and sometimes learn new things (for example I didn't know of window.getComputedStyle before this thread; I learned it breaking this).
     
    XD and AliceShiki like this.
  2. lnv

    lnv ✪ Well-Known Hypocrite

    Joined:
    Jan 24, 2017
    Messages:
    7,702
    Likes Received:
    9,044
    Reading List:
    Link
    Not sure if you saw my edit:
    And yes you discover new things every day, that is how it works with all things... I remember doing things old school, then I found jquery and felt stupid I spent so much time doing everything manually. Saved me a bunch of time. And there is still a million things I probably haven't caught up to.

    As for OCR, well, you can probably grieve OCR to some extent too... For example, if someone uses print to create the OCR, you can set css page-break to grieve on that front. Also @media print
     
    noisypixy likes this.
  3. coyoteelabs

    coyoteelabs Well-Known Member

    Joined:
    May 18, 2016
    Messages:
    95
    Likes Received:
    122
    Reading List:
    Link
    Unfortunately, IE comes to ruin the fun.
    Internet Explorer (probably Edge as well) allows the selection of the pseudo elements text. Meaning a simple copy paste is enough to copy the text (select the text then CTRL+C to copy). No need for OCR to get it :(
     
  4. noisypixy

    noisypixy Sacatunn que pen, que summum que tun.

    Joined:
    Jun 25, 2016
    Messages:
    716
    Likes Received:
    950
    Reading List:
    Link
    Oh, nice catch mate. I'll add this to the "disadvantages" list.
     
    AliceShiki likes this.
  5. coyoteelabs

    coyoteelabs Well-Known Member

    Joined:
    May 18, 2016
    Messages:
    95
    Likes Received:
    122
    Reading List:
    Link
    The solution for this problem is to add random characters inside the span that are hidden with css. This way, when you copy the text, you slso get the hidden random characters. If you randomize the number of characters in each span, simple bots won't be able to simply drop them since they won't easily know if the char is good or not
     
    AliceShiki and noisypixy like this.
  6. coyoteelabs

    coyoteelabs Well-Known Member

    Joined:
    May 18, 2016
    Messages:
    95
    Likes Received:
    122
    Reading List:
    Link
    Here's a quick demo of the method I used to add random chars.

    https://jsfiddle.net/ymv567qn/#run

    The first 2 blocks of "abc" text have hidden characters added. Internet Explorer will copy all of them and will result in garbage. The other browsers will only copy the hidden characters.
     
    AliceShiki likes this.
  7. noisypixy

    noisypixy Sacatunn que pen, que summum que tun.

    Joined:
    Jun 25, 2016
    Messages:
    716
    Likes Received:
    950
    Reading List:
    Link
    The "bad" thing about this is that it has a simple "structure", so if you know everything inside the <i> is useless you can remove it with a single line of JavaScript.
    Code:
    document.querySelectorAll('.word i').forEach((el) => { el.textContent = '' });
    Still, if you sometimes include garbage inside the elements and sometimes include real letters, and sometimes even both (possibly playing with ::first-letter)(EDIT: nvm, ::first-letter conflicts with ::before+content) then it might turn interesting.
     
    AliceShiki likes this.
  8. coyoteelabs

    coyoteelabs Well-Known Member

    Joined:
    May 18, 2016
    Messages:
    95
    Likes Received:
    122
    Reading List:
    Link
    You can mix them. In some cases, use fakes, in other cases, use the real char (and don't apply anything with css in ::before content, in other case, use ::after.

    And if the encoding changes with each refresh, it will make it even more interesting
     
    AliceShiki likes this.
  9. noisypixy

    noisypixy Sacatunn que pen, que summum que tun.

    Joined:
    Jun 25, 2016
    Messages:
    716
    Likes Received:
    950
    Reading List:
    Link
    Yea tbh this is how most methods should be done (especially the "custom font" thing).

    (Btw using the custom font thing with this could be interesting as well :hmm:)
     
    AliceShiki likes this.
  10. lnv

    lnv ✪ Well-Known Hypocrite

    Joined:
    Jan 24, 2017
    Messages:
    7,702
    Likes Received:
    9,044
    Reading List:
    Link
    No, make it better. Multiple custom fonts. And some characters within those fonts will be invisible. If the fonts are generated in svg it could be completely random and almost impossible to process.
     
    AliceShiki and noisypixy like this.
  11. Pizz0011

    Pizz0011 Well-Known Member

    Joined:
    Jan 10, 2017
    Messages:
    497
    Likes Received:
    208
    Reading List:
    Link
    one question as I'm not against this due to the QI fun but i need to use a screen reader. text to speech sometimes due to the side effects of meds I have to take, i don't use windows but I use this bit of free software DSPEECH http://dimio.altervista.org/eng/ is it going to total screw using this up also, which sites are going to use this , as if it's not something i follow np , but if it is i'd like to know that i will not get a problem
     
  12. noisypixy

    noisypixy Sacatunn que pen, que summum que tun.

    Joined:
    Jun 25, 2016
    Messages:
    716
    Likes Received:
    950
    Reading List:
    Link
    Yes, totally.

    No idea. At most one or two, but I hope no one does.

    [​IMG]
     
    AliceShiki and Pizz0011 like this.
  13. Pizz0011

    Pizz0011 Well-Known Member

    Joined:
    Jan 10, 2017
    Messages:
    497
    Likes Received:
    208
    Reading List:
    Link
    cool , thanks for replying :) i hope no one will then