File size: 3,103 Bytes
1e321e7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
document.addEventListener('DOMContentLoaded', () => {
    const inputText = document.getElementById('inputText');
    const outputText = document.getElementById('outputText');
    const humanizeBtn = document.getElementById('humanizeBtn');
    const copyBtn = document.getElementById('copyBtn');

    humanizeBtn.addEventListener('click', () => {
        const text = inputText.value.trim();
        if (!text) {
            alert('Please enter some text to humanize!');
            return;
        }

        // Simulate processing (in a real app, this would call an API)
        humanizeBtn.disabled = true;
        humanizeBtn.textContent = 'Processing...';
        
        setTimeout(() => {
            const humanized = humanizeText(text);
            outputText.value = humanized;
            humanizeBtn.disabled = false;
            humanizeBtn.textContent = 'Humanize It!';
        }, 1000);
    });

    copyBtn.addEventListener('click', () => {
        if (!outputText.value) {
            alert('No text to copy!');
            return;
        }
        outputText.select();
        document.execCommand('copy');
        copyBtn.textContent = 'Copied!';
        setTimeout(() => {
            copyBtn.textContent = 'Copy Text';
        }, 2000);
    });
});

// Simple text transformation examples
function humanizeText(text) {
    // Replace formal words with more casual ones
    const replacements = {
        "utilize": "use",
        "commence": "start",
        "terminate": "end",
        "approximately": "about",
        "subsequent": "next",
        "prior to": "before",
        "in order to": "to",
        "with regard to": "about",
        "on a regular basis": "regularly",
        "at this point in time": "now"
    };

    // Add contractions
    const contractions = {
        "I am": "I'm",
        "you are": "you're",
        "we are": "we're",
        "they are": "they're",
        "cannot": "can't",
        "do not": "don't",
        "does not": "doesn't",
        "will not": "won't",
        "should not": "shouldn't"
    };

    // Apply replacements
    let result = text;
    for (const [formal, casual] of Object.entries(replacements)) {
        result = result.replace(new RegExp(formal, 'gi'), casual);
    }

    // Apply contractions
    for (const [full, contraction] of Object.entries(contractions)) {
        result = result.replace(new RegExp(full, 'gi'), contraction);
    }

    // Add some randomness to make it feel more human
    const randomHumanTouches = [
        "You know,",
        "Well,",
        "Actually,",
        "I mean,",
        "Basically,",
        "So,"
    ];

    // Add random human touch to about 30% of sentences
    const sentences = result.split('. ');
    for (let i = 0; i < sentences.length; i++) {
        if (Math.random() < 0.3 && sentences[i].length > 20) {
            const randomIndex = Math.floor(Math.random() * randomHumanTouches.length);
            sentences[i] = randomHumanTouches[randomIndex] + ' ' + sentences[i].toLowerCase();
        }
    }
    result = sentences.join('. ');

    return result;
}