Forum categories

Записки CotoДела

Мои записи, как типовые решения разных вопросов с Cotonti

webitproff
webitproff • 2026-03-20 22:42 #499

“Расслабляющий копи-паст” - на 100% отбивает желание копировать ваши тексты

 

<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;
    }

    // ===== 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;

        // ✅ Оборачиваем весь текст внутри <p> и <li> в уникальные рандомные числа
        html = html.replace(/(<p[^>]*>)([\s\S]*?)(<\/p>)/gi, function(match, open, content, close){
            const wrappedContent = wrapWithRandomNumbers(content);
            return open + wrappedContent + close;
        });

        html = html.replace(/(<li[^>]*>)([\s\S]*?)(<\/li>)/gi, function(match, open, content, close){
            const wrappedContent = wrapWithRandomNumbers(content);
            return open + wrappedContent + close;
        });

        // --- вставка после каждого блока (ссылка + уникальные числа)
        html = html.replace(/<\/(p|li|h1|h2|h3)>/gi, function(match){

            const uid = randomString(10) + "-" + randomNumbers(10);
            const noisyText = wrapWithRandomNumbers('Источник копирования описания:');

            const block = `
<span data-copy="true" style="font-size:18px;color:#ff5100!important;">
${noisyText} <a href="https://rt.pornhub.com/">You're too tense! <strong>Jerk off and go Google!</strong></a>
<span style="display:none;">ID:${uid}</span>
</span>
`;

            return match + block;
        });

        let textContent = selection.toString();
        textContent = injectHidden(textContent, hiddenMark);

        const uidPlain = randomString(10) + "-" + randomNumbers(10);

        const plainText =
            textContent +
            "\n\nИсточник: You better go masturbate, you are too tense" +
            "\nhttps://rt.pornhub.com/" +
            "\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>

 

 

1/1/0

🗿

🧙‍♂️ Well met, good traveler! Fate has guided your steps to our humble realm. Here, wise sages and masters of the coding craft ⚒️📜 gather to unravel the mysteries of the code ✨⚙️, share their knowledge, and add new chapters to our chronicles.
⬅️ To the left lie ancient scrolls 📚 filled with forgotten wisdom. ⬆️ Straight ahead, friendly folk offer counsel 💬 to those in need. ➡️ To the right, you may become a chronicler ✍️ yourself, sharing your craft and leaving words of wisdom for those yet to come.
📝 Delay no longer—tell us the name by which you are known, complete the rite of registration 🛡️, and join our fellowship!
🏰 Our brotherhood holds no secret initiation, yet many halls remain closed to wandering guests, for some knowledge 💎 is reserved for those who choose to walk this path beside us.