Hancurkan Text saat di copy paste
Letakan diatas </body> atau </head>
dan check hasilnya dengan Copy Text lalu Paste textnya
kode tidak diminifier, Silahkan kembangkan Jika kalian mauv1.2 New[12/febuari/2024]
javascript
<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> :
javascript
<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
/*<![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.
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