<!doctype html>

<br />
    
    <style>
        /* Scoped styles */
        #humanize-tool {
            font-family: 'Arial', sans-serif;
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        /* Main container */
        #humanize-tool .container {
            width: 100%;
            max-width: 1920px;
            margin: 0 auto;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
            background-color: #eeeeee; /* Background color */
            box-sizing: border-box;
            padding-top: 40px; /* Extra padding at the top */
            padding-bottom: 20px; /* Normal bottom padding */
        }

        /* Header container: Wider for more spacious feel */
        #humanize-tool .header-container {
            text-align: center;
            margin-bottom: 20px;
            width: 100%;
            height: auto;
            overflow: visible;
            display: flex;
            justify-content: center;
            align-items: center;
            margin-left: -20px; /* Adjust container to be wider at the top */
            margin-right: -20px; /* Adjust container to be wider at the top */
        }

        /* Text animation for header */
        .typing-animation {
            display: inline-block;
            color: black;
            font-size: 25px;  /* Moderate font size */
            font-weight: medium;
            white-space: nowrap;
            line-height: 1.2;
            letter-spacing: 1px; /* Slightly increased letter-spacing for readability */
        }

        #humanize-tool .textarea-container {
            display: flex;
            justify-content: space-between;
            gap: 20px;
            flex-wrap: wrap;
        }

        #humanize-tool .textarea-container div {
            flex: 1;
            display: flex;
            flex-direction: column;
            box-sizing: border-box;
        }

        #humanize-tool textarea,
        #humanize-tool #humanizedParagraph {
            width: 100%;
            height: 300px;
            padding: 10px;
            font-size: 16px;
            border: 1px solid #ccc;
            border-radius: 5px;
            box-sizing: border-box;
            white-space: pre-wrap;
            overflow-y: auto;
            resize: none;
            font-family: 'Arial', sans-serif;
        }

        /* Ensure that the input box stays the same size */
        #humanize-tool textarea {
            color: #1e232b;
        }

        #humanize-tool textarea::placeholder {
            color: #ccc;
        }

        #humanize-tool #humanizedParagraph {
            background: linear-gradient(90deg, #870205, #210101);
            color: white;
            height: 300px;
            overflow-y: auto;
            white-space: pre-wrap;
            font-family: 'Arial', sans-serif;
            word-wrap: break-word;
        }

        #humanize-tool .controls {
            margin-top: 10px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        #humanize-tool .controls .left-section {
            flex: 1;
            text-align: left;
            font-size: 14px;
            color: #870205;
        }

        #humanize-tool .controls .right-section {
            flex: 1;
            text-align: right;
        }

        /* Button Styles with Fully Rounded Left and Right Corners */
        #humanize-tool #humanizeBtn,
        #humanize-tool #copyBtn {
            padding: 12px 24px;
            font-size: 14px;
            border: none;
            border-radius: 50px;  /* Fully rounded left and right corners */
            cursor: pointer;
            background: linear-gradient(90deg, #870205, #210101);
            color: white;
            transition: background-color 0.3s ease;
            min-width: 120px;  /* Adjust to maintain button size */
            text-align: center;
        }

        #humanize-tool #humanizeBtn:hover,
        #humanize-tool #copyBtn:hover {
            background: linear-gradient(90deg, #210101, #870205); /* Reverse gradient on hover */
        }

        #humanize-tool #copyBtn:disabled {
            background-color: #c1c1c1;
            cursor: not-allowed;
        }

        #humanize-tool #outputText {
            display: none;
        }

        #humanize-tool .gen-counter-container {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 10px;
            background: none;
        }

        #humanize-tool #genCounter,
        #humanize-tool .word-count {
            font-size: 14px;
            color: #870205;
        }

        /* Mobile responsiveness */
        @media (max-width: 768px) {
            #humanize-tool .container {
                width: 95%; /* Container width for mobile */
                padding: 10px; /* Less padding on mobile */
            }

            #humanize-tool .header-container {
                margin-top: 20px; /* Add slight margin to position the header slightly lower */
            }

            #humanize-tool .textarea-container {
                flex-direction: column; /* Stack text areas on top of each other */
                gap: 10px; /* Reduce gap between textarea and output area */
            }

            #humanize-tool textarea,
            #humanize-tool #humanizedParagraph {
                height: 250px; /* Reduced height for mobile */
            }
        }
    </style>



<div id="humanize-tool">
    <div class="container">
        <div class="header-container">
            <div class="typing-animation" id="headerText"></div> <!-- Header text where animation happens -->
        </div>
        <div class="textarea-container">
            <div>
                <textarea id="inputText" placeholder="Paste your text here..."></textarea>
                <div class="controls">
                    <div class="left-section">
                        <div class="word-count" id="inputWordCount">0 words</div>
                    </div>
                    <div class="right-section">
                        <button id="humanizeBtn">Humanize</button>
                    </div>
                </div>
            </div>
            <div id="outputText">
                <div id="humanizedParagraph"></div>
                <div class="gen-counter-container">
                    <div id="genCounter">...Gen</div>
                    <button id="copyBtn" disabled>Copy Result</button>
                </div>
            </div>
        </div>
    </div>
</div>






<script>
    (function () {
        let genCount = 0;
        const phrases = [
            "Humanize Your Text . . .",
            "Unlimited Access . . .",
            "Privacy Guaranteed . . .",
            "No Login Required . . ."
        ];
        let currentPhraseIndex = 0;
        const headerElement = document.getElementById('headerText');

        // Function for typing animation
        function displayTypingEffect(element, text, speed = 100, callback = null) {
            let index = 0;
            element.textContent = '';  // Clear previous text

            function type() {
                if (index < text.length) {
                    element.textContent += text.charAt(index);
                    index++;
                    setTimeout(type, speed);
                } else if (callback) {
                    callback();
                }
            }
            type();
        }

        // Function to start the header typing animation
        function startTypingHeader() {
            displayTypingEffect(headerElement, phrases[currentPhraseIndex], 100, function () {
                currentPhraseIndex++;
                if (currentPhraseIndex < phrases.length) {
                    startTypingHeader();
                } else {
                    currentPhraseIndex = 0;  // Reset the index
                    startTypingHeader();  // Restart the animation
                }
            });
        }

        // Start header animation immediately and loop it
        startTypingHeader();

        const synonyms = new Map();

        // Function to load synonyms from an external API
        async function loadSynonyms() {
            try {
                const response = await fetch('https://api.jsonsilo.com/public/229a1bc7-04a0-4a59-85f7-c6ca8310b13e');
                const data = await response.json();
                for (const [word, synonymList] of Object.entries(data)) {
                    synonyms.set(word.toLowerCase(), synonymList);
                }
            } catch (error) {
                console.error('Error loading synonyms:', error);
            }
        }

        // Load synonyms on page load
        loadSynonyms();

        // Regular expression to match URLs, emails, and any domain-like patterns with dot
        const urlRegex = /(?:https?:\/\/|www\.)\S+\.\S+|\S+@\S+\.\S+|\S+\.\S+/g;
        let domainPartsSet = new Set(); // To store domain words that we need to preserve

        // Function to process the text and preserve domain parts
        function processText(text) {
            const placeholders = [];
            let match;

            // Clear the domain parts set before processing new text
            domainPartsSet.clear();

            // Helper function to extract domain parts from a string
            function extractDomainParts(domain) {
                const domainParts = domain.split('.'); // Split the domain by dot
                domainParts.forEach(part => {
                    domainPartsSet.add(part.toLowerCase()); // Add domain parts to the set
                });
            }

            // Loop through and replace URLs/emails with placeholders, and capture domain parts
            while ((match = urlRegex.exec(text)) !== null) {
                const fullUrl = match[0];

                if (fullUrl.includes('@')) {
                    // Email domain extraction (after '@')
                    const emailDomain = fullUrl.split('@')[1];
                    extractDomainParts(emailDomain);
                } else {
                    // For URLs, extract domain parts (after 'http(s)://')
                    const urlDomain = fullUrl.replace(/^https?:\/\//, '').split('/')[0];
                    extractDomainParts(urlDomain);
                }

                // Replace URL with placeholder
                placeholders.push(fullUrl);
                text = text.replace(fullUrl, `{{URL_PLACEHOLDER_${placeholders.length - 1}}}`);
            }

            // Function to apply appropriate capitalization to the synonym based on the original word's case
            function applyCase(originalWord, synonym) {
                if (originalWord === originalWord.toUpperCase()) {
                    // If the original word is all uppercase, return the synonym in all uppercase
                    return synonym.toUpperCase();
                } else if (originalWord === originalWord.charAt(0).toUpperCase() + originalWord.slice(1).toLowerCase()) {
                    // If the original word has the first letter capitalized, capitalize the synonym's first letter
                    return synonym.charAt(0).toUpperCase() + synonym.slice(1).toLowerCase();
                } else {
                    // If the original word is all lowercase, return the synonym in all lowercase
                    return synonym.toLowerCase();
                }
            }

            // Split the input text by word boundaries and replace synonyms
            const words = text.split(/\b/);
            const processedText = words.map(word => {
                const lowerWord = word.toLowerCase();
                
                // If the word is part of a domain (from the domain parts set), don't replace it
                if (domainPartsSet.has(lowerWord)) {
                    return word; // Preserve domain parts (i.e., don't replace)
                }

                // If it's a synonym, replace it
                if (synonyms.has(lowerWord)) {
                    const synonymList = synonyms.get(lowerWord);
                    const randomSynonym = synonymList[Math.floor(Math.random() * synonymList.length)];

                    // Apply the original word's case to the synonym
                    return applyCase(word, randomSynonym);
                }

                return word;
            }).join('');

            // Restore the URLs/emails with their original content
            let resultText = processedText;
            placeholders.forEach((placeholder, index) => {
                resultText = resultText.replace(`{{URL_PLACEHOLDER_${index}}}`, placeholder);
            });

            return resultText;
        }

        let isTyping = false;
        let typingTimeout;

        // Function to animate typing effect for output text
        function typeOutText(element, text, speed) {
            // Disable the copy button while typing
            document.getElementById('copyBtn').disabled = true;

            if (isTyping) {
                clearTimeout(typingTimeout);
                element.textContent = '';
                isTyping = false;
            }

            isTyping = true;
            let index = 0;
            element.textContent = '';

            function type() {
                if (index < text.length) {
                    element.textContent += text.charAt(index);
                    index++;
                    element.scrollTop = element.scrollHeight;
                    typingTimeout = setTimeout(type, speed);
                } else {
                    isTyping = false;
                    smoothScrollBackToTop(); // Scroll back to the top smoothly

                    // Enable the copy button once typing finishes
                    document.getElementById('copyBtn').disabled = false;
                }
            }
            type();
        }

        // Function to smooth scroll the output text back to the starting point
        function smoothScrollBackToTop() {
            const outputElement = document.getElementById('humanizedParagraph');
            outputElement.scrollTo({
                top: 0,
                behavior: 'smooth',
            });
        }

        // Function to update word count
        function updateWordCount(text) {
            const wordCount = text.trim().split(/\s+/).filter(word => word.length > 0).length;
            document.getElementById('inputWordCount').textContent = `${wordCount} words`;
        }

        // Humanize button click event
document.getElementById('humanizeBtn').addEventListener('click', () => {
    const inputText = document.getElementById('inputText').value;
    if (inputText.trim() === "") {
        // If input text is empty, show a warning
        alert("Please enter text to Humanize");
        return; // Prevent further execution
    }

    const humanizedText = processText(inputText);
    const outputElement = document.getElementById('humanizedParagraph');
    document.getElementById('outputText').style.display = 'block';
    document.getElementById('copyBtn').disabled = false;
    genCount++;
    document.getElementById('genCounter').textContent = `Gen: ${genCount}`;
    document.getElementById('humanizeBtn').textContent = 'Enhance';

    // Start typing effect on the output text (Fresh Start)
    typeOutText(outputElement, humanizedText, -50);

    // Update word count for the input text
    updateWordCount(inputText);
});

        // Copy button event
        document.getElementById('copyBtn').addEventListener('click', () => {
            const outputText = document.getElementById('humanizedParagraph').textContent;
            navigator.clipboard.writeText(outputText).then(() => {
                alert('Copy Success!');
            });
        });

        // Reset input text and output on input change
        document.getElementById('inputText').addEventListener('input', () => {
            // Reset output text and button states
            document.getElementById('outputText').style.display = 'none';
            document.getElementById('humanizeBtn').textContent = 'Humanize';
            document.getElementById('copyBtn').disabled = true;
            genCount = 0;
            document.getElementById('genCounter').textContent = `Gen: ${genCount}`;

            // Reset word count for the input text
            updateWordCount(document.getElementById('inputText').value);
        });
    })();
</script>

<p style="font-size: 0.875rem; line-height: 1.25rem; color: #6b7280; text-align: center; margin-top: 1rem;">
   By using  <a href="https://www.aitohuman.net/" style="color: #ef4444; text-decoration: none;">aitohuman.net</a>, you are agree to our <a href="https://www.aitohuman.net/p/terms-and-conditions.html" style="color: #ef4444; text-decoration: none;">Terms.</a>.
</p>

</!doctype>