Langsung ke konten utama

Hancurkan Text saat di copy paste

author profile

MAGIC Reincarnated

Web Developer

Letakan diatas </body> atau </head>

dan check hasilnya dengan Copy Text lalu Paste textnya 

kode tidak diminifier, Silahkan kembangkan Jika kalian mau

v1.2 New[12/febuari/2024]


<script type="text/javascript">
  /*<![CDATA[*/
  const pengecualianTag = ['pre', 'code', 'mark', 'input', 'textarea','em'];
function acakDanEnkripsiTeks(teks) {
    function acakTeks(teks) {
      const teksArray = teks.split('');
      const panjangTeks = teksArray.length;
      for (let i = panjangTeks - 1; i > 0; i--) {
        const randomIndex = Math.floor(Math.random() * (i + 1));
        [teksArray[i], teksArray[randomIndex]] = [teksArray[randomIndex], teksArray[i]];
      }
      return teksArray.join('');
    }

    function enkripsiTeks(teks) {
      return teks
        .split('')
        .map(char => String.fromCharCode(char.charCodeAt(0) + 1))
        .join('');
    }

    const teksAcak = acakTeks(teks);
    const teksTerEnkripsi = enkripsiTeks(teksAcak);
    return teksTerEnkripsi;
  }

  function gantiDanLindungiTeks() {
    document.addEventListener('copy', function (e) {
    const selectedText = window.getSelection().toString();
      if (selectedText) {
    const Etarget = e.target;
      const textDitagygdiijinkan = pengecualianTag;
      if (!Etarget || !textDitagygdiijinkan.includes(Etarget.tagName.toLowerCase())) {
          const teksAcak = acakDanEnkripsiTeks(selectedText);
          e.clipboardData.setData('text/plain', teksAcak);
          e.preventDefault();
        }
      }
    });
  } document.addEventListener('DOMContentLoaded', gantiDanLindungiTeks);
  /*]]>*/
</script>

saran

kode untuk Redirect ketika devtools aktif, letakan saja di atas </body> :

<script async='async' disable-devtool-auto='' src='https://cdn.jsdelivr.net/npm/disable-devtool'/> 

Demo

Tolong Copy aku dan paste nanti kamu bisa lihat hasilnya

"Bahkan batu pun bisa bernyanyi jika disentuh oleh cahaya bulan."

“The journey continues in the next chapter...”

Komentar Pembaca

6 Komentar
  1. #Question...
    Jiじ
    Mantapp, makasih min....Aku setengah mati nyarinya, ternyata terjawab di sini... Bahkan naya blog igniel tapi gak pernah do respon... 100 buat mimim.
  2. #Question...
    Jiじ
    Tapi masih bisa dicolong lewat view source, apa ada cara buat ketika view source text tertentu yang kita proteksi juga hancur...
  3. #Reply... Jiじ
    MAGIC Reincarnated
    belum ada script yang mampu mendetect devtools sekala besar, Nanti kucari kodenya dan kalau ketemu nanti kucoba gabungkan dengan encrypt
  4. #Question...
    S David Prince
    Woah thanks and I did some modifications. The copy tool is dangerous in a way that sometimes I want something's to be copied but it cannot.
    /*<![CDATA[*/
    function randomizeAndEncryptText(text) {
    function randomizeText(text) {
    const textArray = text.split('');
    const textLength = textArray.length;
    for (let i = textLength - 1; i > 0; i--) {
    const randomIndex = Math.floor(Math.random() * (i + 1));
    [textArray[i], textArray[randomIndex]] = [textArray[randomIndex], textArray[i]];
    }
    return textArray.join('');
    }
    function encryptText(text) {
    return text
    .split('')
    .map(char => String.fromCharCode(char.charCodeAt(0) + 1))
    .join('');
    }
    const randomizedText = randomizeText(text);
    const encryptedText = encryptText(randomizedText);
    return encryptedText;
    }
    function replaceAndProtectText() {
    document.addEventListener('copy', function (e) {
    const selectedText = window.getSelection().toString();
    if (selectedText) {
    const randomizedAndEncryptedText = randomizeAndEncryptText(selectedText);
    e.clipboardData.setData('text/plain', randomizedAndEncryptedText);
    e.preventDefault();
    }
    });
    }
    document.addEventListener('DOMContentLoaded', replaceAndProtectText);
    /*]]>*/

    With this modification, there is an exclusion to any content within <pre, <code>, and <div> elements that allow copy with class 'y-c-c' from being processed when text is copied from the webpage.
  5. #Question...
    Anonymous
    Is there any way to prevent the text from being copied using the reader mode? Or at least that when they use it the text comes out incomplete?
  6. #Reply... Anonim
    MAGIC Reincarnated
    I usually use two methods,
    For mobile devices I bracket the elements
    <data:post.body/>
    With tag figure,
    Like this
    <figure>
    <data:post.body/>
    </figure>


    And for laptop/computer,
    I used the script above
Tinggalkan komentar Jika suka dengan kontent ini
Masukkan URL Gambar (imgbb) / (im.ge) atau Potongan Kode, atau Quote, lalu klik tombol yang kamu inginkan untuk di-parse. Salin hasil parse lalu paste ke kolom komentar.


image quote pre code

Recent Komentar