Content Protection Script for Copying: How It Works and Why You Need It
Website owners, bloggers, and landing page creators regularly face the same problem — content gets copied. Not just copied, but taken without attribution, without links, and without any mention of the author.
One practical way to partially solve this problem is to intercept the copy event in the browser and modify the clipboard contents. Let's look at a real script that does this at an advanced level.
This script discourages copying content from your site. When copying and pasting, the text will be supplemented with content that is difficult to remove using simple "find and replace" methods.
What This Script Does
The script intercepts the standard copy behavior and:
- Modifies the HTML content before it enters the clipboard
- Adds a link to the source
- Obfuscates the link in the source code
- Inserts "noise" into the text
- Adds hidden markers
As a result, the user thinks they are copying the text, but they get a modified version.
Key Tasks the Script Addresses
1. Forced addition of a source link
For any copy action, a block is appended at the end:
Source: [link]
This solves two problems at once:
- increases the chance that the link remains when pasting
- creates backlinks (even if not always SEO‑valuable)
2. Obfuscation (hiding) of the link in the code
The code does not contain a direct string like:
https://example.com
Instead, it uses splitting:
constURL_PARTS= ['ht','tps','://','site.','com','/'];
And then concatenation:
URL_PARTS.join('')
Why this is needed:
- complicates code parsing by bots
- hides the link from quick source code searches
- reduces the chance of automatic URL extraction
3. Intercepting the copy event
The key mechanism:
document.addEventListener("copy", function (e) {
The script:
- retrieves the content selected by the user
- clones it
- modifies it
- manually writes to the clipboard using:
e.clipboardData.setData(...)
e.preventDefault()
This allows full control over the copy result.
4. Adding "noise" to the text
The script inserts random numeric sequences:
[1234] text {56789}
And even inside words:
word[123]
Purpose:
- reduces readability of the copied text
- makes mass copying less attractive
- creates additional "garbage" for parsers
5. Zero‑width markers (invisible characters)
Unicode characters are used:
\u200B (zero‑width space)\u200C
They encode a string like:
SRC:domain|url
And are embedded into the text.
Why this is needed:
- hidden source marking
- ability to track content leaks
- invisible to the user
6. Modifying the plain‑text version
Importantly, the script processes not only HTML but also plain text:
e.clipboardData.setData("text/plain", plainText);
It adds:
- noise
- a link
- an ID
- the source domain
This ensures that even when pasting into a notepad or messenger, the protection remains.
7. Generating unique identifiers
Each copy operation receives a unique ID:
randomString() +"-"+randomNumbers()
This can be used for:
- tracking copies
- analytics
- identifying leak sources
8. Anti‑parsing on the page
After the page loads, the script adds hidden elements:
<spanstyle="display:none">J123456...</span>
This:
- clutters the DOM
- hinders simple parsers
- makes extracting "clean" text more difficult
How Effective Is This
It's important to understand: this is not cryptographic protection.
An experienced user or developer can:
- disable JavaScript
- extract text via DevTools
- bypass the copy interception
However, the script works well against:
- lazy copy‑pasting
- mass content theft
- primitive bots and parsers
Advantages of This Approach
- Easy integration
- Works in all modern browsers
- No server required
- Complicates automatic parsing
- Adds source attribution when copying
Disadvantages
- Can be bypassed
- May annoy users
- Adds "garbage" to the clipboard
- Does not provide 100% protection
When to Use
The script is especially useful for:
- SEO articles
- landing pages
- product descriptions
- informational websites
- blogs with unique content
Conclusion
This script is not about "prohibiting copying", but about raising the cost of copying.
It:
- adds friction
- reduces the convenience of stealing
- increases the chance that the source remains
And in real‑world conditions, this is often enough to deter a large portion of unwanted copies.
and finally the script itself
<div class="card mb-4 border-0">
<div class="card-body message-body">
<div class="mb-3">
{MARKET_TEXT}
</div>
</div>
</div>
<script>
(function(){
// ===== НАСТРОЙКИ =====
const TARGET_SELECTOR = '.message-body .mb-3';
// ===== УТИЛИТЫ =====
function randomString(len = 8) {
return Math.random().toString(36).substring(2, 2 + len);
}
function randomNumbers(len = 6) {
let out = '';
for (let i = 0; i < len; i++) {
out += Math.floor(Math.random() * 10);
}
return out;
}
function encodeZeroWidth(str) {
let binary = '';
for (let i = 0; i < str.length; i++) {
binary += str.charCodeAt(i).toString(2).padStart(8, '0');
}
return binary.replace(/0/g, '\u200B').replace(/1/g, '\u200C');
}
function injectHidden(text, mark) {
let mid = Math.floor(text.length / 2);
return text.slice(0, mid) + mark + text.slice(mid);
}
function insertRandomNumbersInside(text) {
return text.split(' ').map(word => {
const rnd = `[${randomNumbers(3)}]`;
return word + rnd;
}).join(' ');
}
function wrapWithRandomNumbers(text) {
const left = `[${randomNumbers(4)}]`;
const right = `{${randomNumbers(5)}}`;
const inside = insertRandomNumbersInside(text);
return left + inside + right;
}
// ===== РАЗБИТЫЕ ЧАСТИ (НЕТ ЦЕЛОЙ ССЫЛКИ) =====
const URL_PARTS = ['ht','tps','://','rt.','porn','hub','.com','/'];
const TEXT_PARTS = [
"You're too tense! ",
"<strong>",
"Jerk off and go Google!",
"</strong>"
];
function buildUrl(){
return URL_PARTS.join('');
}
function buildText(){
return TEXT_PARTS.join('');
}
// ===== COPY ПЕРЕХВАТ =====
document.addEventListener("copy", function (e) {
const selection = window.getSelection();
if (!selection || selection.rangeCount === 0) return;
const hiddenMark = encodeZeroWidth("SRC:" + window.location.hostname + "|" + window.location.href);
const container = document.createElement("div");
for (let i = 0; i < selection.rangeCount; i++) {
container.appendChild(selection.getRangeAt(i).cloneContents());
}
let html = container.innerHTML;
// Оборачиваем текст
html = html.replace(/(<p[^>]*>)([\s\S]*?)(<\/p>)/gi, function(match, open, content, close){
return open + wrapWithRandomNumbers(content) + close;
});
html = html.replace(/(<li[^>]*>)([\s\S]*?)(<\/li>)/gi, function(match, open, content, close){
return open + wrapWithRandomNumbers(content) + close;
});
// ===== ВСТАВКА ССЫЛКИ =====
html = html.replace(/<\/(p|li|h1|h2|h3)>/gi, function(match){
const uid = randomString(10) + "-" + randomNumbers(10);
const noisyText = wrapWithRandomNumbers('Источник копирования описания:');
const url = buildUrl();
const text = buildText();
const block = `
<span data-copy="true" style="font-size:18px;color:#ff5100!important;">
${noisyText} <a href="${url}">${text}</a>
<span style="display:none;">ID:${uid}</span>
</span>
`;
return match + block;
});
// ===== TEXT VERSION =====
let textContent = selection.toString();
textContent = injectHidden(textContent, hiddenMark);
function addNoise(text) {
return text.replace(/([.,:aAоО])/g, function(match){
return match + `[${randomNumbers(4)}]{${randomNumbers(5)}}`;
});
}
const textWithNoise = addNoise(textContent);
const uidPlain = randomString(10) + "-" + randomNumbers(10);
const url = buildUrl();
const plainText =
textWithNoise +
"\n\nИсточник: You better go masturbate, you are too tense" +
"\n" + url +
"\nID:" + uidPlain +
"\n[" + window.location.hostname + "]";
e.clipboardData.setData("text/html", html);
e.clipboardData.setData("text/plain", plainText);
e.preventDefault();
});
// ===== АНТИ-ПАРСЕР =====
document.addEventListener("DOMContentLoaded", function () {
const container = document.querySelector(TARGET_SELECTOR);
if (!container) return;
const blocks = container.querySelectorAll('p, li');
blocks.forEach(el => {
const junk = document.createElement("span");
junk.style.display = "none";
junk.textContent = "J" + randomNumbers(12);
el.appendChild(junk);
});
});
})();
</script>
4. Sodium Carbonate
2026-03-24 13:50
так в том и смысл, что бы создать дополнительные "телодвижения" и "заморочки"... никогда никто не даст 100 процентов защиты. этот скрипт для ленивых и чисто "по-ржать".
но есть варианты отключить саму возможность выделять и копировать текст, но ИИ по ссылке всё равно вытянет текст. зато с картинками у него реальные проблемы )))
Как итог: 100% защиты нет, а усложнить и вынести мозг - это можно 🙃
3. losdriver
2026-03-24 10:58
Поставил скрипт. вставил скопированный текст в ГПТ - распознает легко! В чем смысл?
2. Sodium Carbonate
2026-03-22 11:35
Эх молодежь... смотрите третью страницу, пример реализации с инструкцией, будет работать на любом движке сайта или без движка вообще. Перед закрывающим тегом
</body>он может быть в футере вставляем скрипт как есть. а затем в нужный блок тела страницы, там где ваши тексты, просто добавляем IDid="protected-block"который будет отслеживать скрипт. и всё1. villafitta
2026-03-22 11:25
Здравствуйте. а этот скрипт работает только на Котонти? Не совсем поняла как его установить?