File size: 41,469 Bytes
182f19e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HumanizeAI - AI to Human Text Converter</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .gradient-bg {
            background: linear-gradient(135deg, #6e8efb, #a777e3);
        }
        .text-gradient {
            background: linear-gradient(90deg, #6e8efb, #a777e3);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
        }
        .typing-indicator {
            display: inline-block;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background-color: #6e8efb;
            margin-right: 3px;
            animation: typing 1.4s infinite ease-in-out;
        }
        .typing-indicator:nth-child(2) {
            animation-delay: 0.2s;
        }
        .typing-indicator:nth-child(3) {
            animation-delay: 0.4s;
        }
        @keyframes typing {
            0%, 60%, 100% { transform: translateY(0); }
            30% { transform: translateY(-5px); }
        }
        .humanization-option:hover {
            transform: scale(1.03);
            box-shadow: 0 10px 20px rgba(0,0,0,0.1);
        }
        .pulse-animation {
            animation: pulse 2s infinite;
        }
        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }
    </style>
</head>
<body class="min-h-screen bg-gray-100">
    <div class="gradient-bg text-white py-6 shadow-lg">
        <div class="container mx-auto px-4">
            <div class="flex justify-between items-center">
                <div class="flex items-center">
                    <i class="fas fa-user-edit text-3xl mr-3"></i>
                    <h1 class="text-3xl font-bold">HumanizeAI</h1>
                </div>
                <div class="text-sm">
                    <span class="bg-white text-purple-600 px-3 py-1 rounded-full font-semibold">AI to Human Text Converter</span>
                </div>
            </div>
            <p class="mt-2 opacity-90">Transform AI-generated content into natural human-written text</p>
        </div>
    </div>

    <div class="container mx-auto px-4 py-8">
        <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
            <!-- Input Section -->
            <div class="lg:col-span-2 bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-6">
                    <h2 class="text-2xl font-semibold text-gray-800 mb-4">Input AI Content</h2>
                    <div class="mb-4">
                        <textarea id="aiContent" rows="10" class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500" placeholder="Paste your AI-generated text here..."></textarea>
                    </div>
                    <div class="flex flex-wrap gap-3 mb-4">
                        <button id="humanizeBtn" class="bg-purple-600 hover:bg-purple-700 text-white px-6 py-2 rounded-lg font-medium flex items-center pulse-animation">
                            <i class="fas fa-magic mr-2"></i> Humanize Text
                        </button>
                        <button id="clearBtn" class="bg-gray-200 hover:bg-gray-300 text-gray-800 px-6 py-2 rounded-lg font-medium flex items-center">
                            <i class="fas fa-trash-alt mr-2"></i> Clear
                        </button>
                        <button id="sampleBtn" class="bg-blue-100 hover:bg-blue-200 text-blue-800 px-6 py-2 rounded-lg font-medium flex items-center">
                            <i class="fas fa-lightbulb mr-2"></i> Sample Text
                        </button>
                    </div>
                </div>
            </div>

            <!-- Humanization Settings -->
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-6">
                    <h2 class="text-2xl font-semibold text-gray-800 mb-4">Humanization Settings</h2>
                    
                    <div class="mb-6">
                        <label class="block text-gray-700 font-medium mb-2">Writing Style</label>
                        <div class="grid grid-cols-1 gap-3">
                            <div class="humanization-option bg-gray-50 p-4 rounded-lg cursor-pointer transition-all" data-style="casual">
                                <div class="flex items-center">
                                    <div class="w-10 h-10 bg-blue-100 rounded-full flex items-center justify-center mr-3">
                                        <i class="fas fa-comment-dots text-blue-600"></i>
                                    </div>
                                    <div>
                                        <h3 class="font-medium">Casual</h3>
                                        <p class="text-xs text-gray-500">Conversational & Relaxed</p>
                                    </div>
                                </div>
                            </div>
                            <div class="humanization-option bg-gray-50 p-4 rounded-lg cursor-pointer transition-all" data-style="professional">
                                <div class="flex items-center">
                                    <div class="w-10 h-10 bg-purple-100 rounded-full flex items-center justify-center mr-3">
                                        <i class="fas fa-briefcase text-purple-600"></i>
                                    </div>
                                    <div>
                                        <h3 class="font-medium">Professional</h3>
                                        <p class="text-xs text-gray-500">Formal & Polished</p>
                                    </div>
                                </div>
                            </div>
                            <div class="humanization-option bg-gray-50 p-4 rounded-lg cursor-pointer transition-all" data-style="creative">
                                <div class="flex items-center">
                                    <div class="w-10 h-10 bg-green-100 rounded-full flex items-center justify-center mr-3">
                                        <i class="fas fa-paint-brush text-green-600"></i>
                                    </div>
                                    <div>
                                        <h3 class="font-medium">Creative</h3>
                                        <p class="text-xs text-gray-500">Expressive & Original</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="mb-6">
                        <label class="block text-gray-700 font-medium mb-2">Humanization Level</label>
                        <input type="range" id="humanizationLevel" min="1" max="5" step="1" value="3" class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
                        <div class="flex justify-between text-xs text-gray-500 mt-1">
                            <span>Subtle</span>
                            <span>Balanced</span>
                            <span>Strong</span>
                        </div>
                    </div>

                    <div class="mb-6">
                        <label class="block text-gray-700 font-medium mb-2">Error Rate</label>
                        <input type="range" id="errorRate" min="0" max="2" step="0.5" value="0.5" class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
                        <div class="flex justify-between text-xs text-gray-500 mt-1">
                            <span>Minimal</span>
                            <span>Natural</span>
                            <span>Noticeable</span>
                        </div>
                    </div>

                    <div class="mb-6">
                        <label class="block text-gray-700 font-medium mb-2">Sentence Variation</label>
                        <input type="range" id="sentenceVariation" min="0" max="2" step="0.5" value="1" class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
                        <div class="flex justify-between text-xs text-gray-500 mt-1">
                            <span>Uniform</span>
                            <span>Varied</span>
                            <span>Very Varied</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Output Section -->
        <div id="outputSection" class="mt-8 bg-white rounded-xl shadow-md overflow-hidden hidden">
            <div class="p-6">
                <h2 class="text-2xl font-semibold text-gray-800 mb-4 flex items-center">
                    Humanized Output
                    <span id="processingIndicator" class="ml-2 hidden">
                        <span class="typing-indicator"></span>
                        <span class="typing-indicator"></span>
                        <span class="typing-indicator"></span>
                    </span>
                </h2>
                
                <div class="mb-6">
                    <div id="outputText" class="w-full px-4 py-3 border border-gray-300 rounded-lg min-h-40 bg-gray-50"></div>
                </div>

                <div class="flex flex-wrap gap-3">
                    <button id="copyBtn" class="bg-purple-600 hover:bg-purple-700 text-white px-6 py-2 rounded-lg font-medium flex items-center">
                        <i class="fas fa-copy mr-2"></i> Copy Text
                    </button>
                    <button id="downloadBtn" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg font-medium flex items-center">
                        <i class="fas fa-download mr-2"></i> Download
                    </button>
                    <button id="rewriteBtn" class="bg-green-600 hover:bg-green-700 text-white px-6 py-2 rounded-lg font-medium flex items-center">
                        <i class="fas fa-redo mr-2"></i> Rewrite
                    </button>
                </div>

                <div class="mt-6 bg-yellow-50 border-l-4 border-yellow-400 p-4">
                    <div class="flex">
                        <div class="flex-shrink-0">
                            <i class="fas fa-info-circle text-yellow-500"></i>
                        </div>
                        <div class="ml-3">
                            <p class="text-sm text-yellow-700">
                                <strong>Tip:</strong> For best results, review the output and make minor manual adjustments to make it sound even more natural.
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- AI Detection Checker -->
        <div class="mt-8 bg-white rounded-xl shadow-md overflow-hidden">
            <div class="p-6">
                <h2 class="text-2xl font-semibold text-gray-800 mb-4">AI Detection Check</h2>
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <div class="bg-gray-50 p-4 rounded-lg">
                        <h3 class="font-medium text-gray-800 mb-2">Original Text</h3>
                        <div class="flex items-center justify-between mb-2">
                            <span class="text-sm font-medium text-gray-600">AI Likelihood:</span>
                            <span id="originalAiScore" class="text-sm font-semibold">Not analyzed</span>
                        </div>
                        <div class="w-full bg-gray-200 rounded-full h-2.5">
                            <div id="originalAiBar" class="bg-red-500 h-2.5 rounded-full" style="width: 0%"></div>
                        </div>
                    </div>
                    <div class="bg-gray-50 p-4 rounded-lg">
                        <h3 class="font-medium text-gray-800 mb-2">Humanized Text</h3>
                        <div class="flex items-center justify-between mb-2">
                            <span class="text-sm font-medium text-gray-600">AI Likelihood:</span>
                            <span id="humanizedAiScore" class="text-sm font-semibold">Not analyzed</span>
                        </div>
                        <div class="w-full bg-gray-200 rounded-full h-2.5">
                            <div id="humanizedAiBar" class="bg-green-500 h-2.5 rounded-full" style="width: 0%"></div>
                        </div>
                    </div>
                </div>
                <button id="checkAiBtn" class="mt-4 bg-gray-800 hover:bg-gray-900 text-white px-6 py-2 rounded-lg font-medium flex items-center mx-auto">
                    <i class="fas fa-search mr-2"></i> Check AI Detection
                </button>
            </div>
        </div>

        <!-- Tips Section -->
        <div class="mt-8 bg-white rounded-xl shadow-md overflow-hidden">
            <div class="p-6">
                <h2 class="text-2xl font-semibold text-gray-800 mb-4">How to Make Text More Human</h2>
                <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                    <div class="bg-blue-50 p-4 rounded-lg">
                        <div class="flex items-start">
                            <div class="bg-blue-100 p-2 rounded-full mr-3">
                                <i class="fas fa-random text-blue-600"></i>
                            </div>
                            <div>
                                <h3 class="font-medium text-blue-800">Vary Sentence Structure</h3>
                                <p class="text-sm text-gray-600">Mix short and long sentences. AI tends to be more uniform.</p>
                            </div>
                        </div>
                    </div>
                    <div class="bg-purple-50 p-4 rounded-lg">
                        <div class="flex items-start">
                            <div class="bg-purple-100 p-2 rounded-full mr-3">
                                <i class="fas fa-exclamation text-purple-600"></i>
                            </div>
                            <div>
                                <h3 class="font-medium text-purple-800">Add Imperfections</h3>
                                <p class="text-sm text-gray-600">Minor grammatical errors, colloquialisms, and contractions help.</p>
                            </div>
                        </div>
                    </div>
                    <div class="bg-green-50 p-4 rounded-lg">
                        <div class="flex items-start">
                            <div class="bg-green-100 p-2 rounded-full mr-3">
                                <i class="fas fa-user text-green-600"></i>
                            </div>
                            <div>
                                <h3 class="font-medium text-green-800">Personal Perspective</h3>
                                <p class="text-sm text-gray-600">Add personal opinions or experiences that AI wouldn't have.</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <footer class="bg-gray-800 text-white py-6 mt-12">
        <div class="container mx-auto px-4 text-center">
            <p>HumanizeAI - AI to Human Text Converter</p>
            <p class="text-gray-400 text-sm mt-2">Transform AI-generated content into natural human-written text that bypasses detection</p>
            <div class="mt-4 flex justify-center space-x-4">
                <a href="#" class="text-gray-300 hover:text-white"><i class="fab fa-twitter"></i></a>
                <a href="#" class="text-gray-300 hover:text-white"><i class="fab fa-github"></i></a>
                <a href="#" class="text-gray-300 hover:text-white"><i class="fab fa-discord"></i></a>
            </div>
        </div>
    </footer>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // DOM Elements
            const aiContent = document.getElementById('aiContent');
            const humanizeBtn = document.getElementById('humanizeBtn');
            const clearBtn = document.getElementById('clearBtn');
            const sampleBtn = document.getElementById('sampleBtn');
            const outputSection = document.getElementById('outputSection');
            const outputText = document.getElementById('outputText');
            const copyBtn = document.getElementById('copyBtn');
            const downloadBtn = document.getElementById('downloadBtn');
            const rewriteBtn = document.getElementById('rewriteBtn');
            const checkAiBtn = document.getElementById('checkAiBtn');
            const processingIndicator = document.getElementById('processingIndicator');
            const humanizationLevel = document.getElementById('humanizationLevel');
            const errorRate = document.getElementById('errorRate');
            const sentenceVariation = document.getElementById('sentenceVariation');
            
            // Humanization settings
            const humanizationOptions = document.querySelectorAll('.humanization-option');
            let selectedStyle = 'casual';
            
            // Initialize
            setupEventListeners();
            
            function setupEventListeners() {
                // Humanization style selection
                humanizationOptions.forEach(option => {
                    option.addEventListener('click', function() {
                        humanizationOptions.forEach(opt => opt.classList.remove('ring-2', 'ring-purple-500'));
                        this.classList.add('ring-2', 'ring-purple-500');
                        selectedStyle = this.dataset.style;
                    });
                });
                
                // Default select casual style
                document.querySelector('.humanization-option[data-style="casual"]').classList.add('ring-2', 'ring-purple-500');
                
                // Buttons
                humanizeBtn.addEventListener('click', humanizeText);
                clearBtn.addEventListener('click', clearText);
                sampleBtn.addEventListener('click', loadSampleText);
                copyBtn.addEventListener('click', copyOutputText);
                downloadBtn.addEventListener('click', downloadText);
                rewriteBtn.addEventListener('click', humanizeText);
                checkAiBtn.addEventListener('click', checkAiDetection);
            }
            
            function humanizeText() {
                const text = aiContent.value.trim();
                if (!text) {
                    alert('Please enter some text to humanize.');
                    return;
                }
                
                // Show processing indicator
                processingIndicator.classList.remove('hidden');
                outputSection.classList.remove('hidden');
                outputText.textContent = 'Processing...';
                
                // Get settings
                const level = parseInt(humanizationLevel.value);
                const errorLevel = parseFloat(errorRate.value);
                const variationLevel = parseFloat(sentenceVariation.value);
                
                // Simulate processing delay
                setTimeout(() => {
                    // Humanize the text with all available techniques
                    let humanized = humanizeTextWithSettings(text, selectedStyle, level, errorLevel, variationLevel);
                    
                    outputText.textContent = humanized;
                    processingIndicator.classList.add('hidden');
                    
                    // Scroll to output
                    outputSection.scrollIntoView({ behavior: 'smooth' });
                    
                    // Reset AI detection results
                    resetAiDetectionResults();
                }, 1500);
            }
            
            function humanizeTextWithSettings(text, style, level, errorLevel, variationLevel) {
                let result = text;
                
                // Apply transformations based on humanization level
                for (let i = 0; i < level; i++) {
                    // 1. Sentence structure variation
                    result = varySentenceStructure(result, variationLevel);
                    
                    // 2. Add colloquialisms and contractions
                    result = addConversationalElements(result, style);
                    
                    // 3. Add minor errors
                    result = addHumanErrors(result, errorLevel);
                    
                    // 4. Add personal perspective
                    if (i % 2 === 0) {
                        result = addPersonalPerspective(result, style);
                    }
                    
                    // 5. Rephrase some sentences
                    result = rephraseSentences(result);
                }
                
                return result;
            }
            
            function varySentenceStructure(text, variationLevel) {
                const sentences = text.split('. ');
                let result = [];
                
                for (let i = 0; i < sentences.length; i++) {
                    let sentence = sentences[i];
                    
                    // Skip empty sentences
                    if (!sentence.trim()) continue;
                    
                    // Apply variations based on the variation level
                    if (Math.random() < (0.2 * variationLevel)) {
                        // Sometimes combine two short sentences
                        if (i < sentences.length - 1 && sentences[i].length < 50 && sentences[i+1].length < 50) {
                            sentence = sentence + ', ' + sentences[i+1].toLowerCase();
                            i++; // Skip next sentence
                        }
                    }
                    
                    if (Math.random() < (0.3 * variationLevel)) {
                        // Sometimes split long sentences
                        if (sentence.length > 80) {
                            const parts = sentence.split(', ');
                            if (parts.length > 1) {
                                // Split at a random comma
                                const splitPos = Math.floor(Math.random() * (parts.length - 1)) + 1;
                                const firstPart = parts.slice(0, splitPos).join(', ');
                                const secondPart = parts.slice(splitPos).join(', ');
                                result.push(firstPart + '.');
                                sentence = secondPart.charAt(0).toLowerCase() + secondPart.slice(1);
                            }
                        }
                    }
                    
                    // Randomly decide to start with conjunction
                    const conjunctions = ['And', 'But', 'So', 'Well', 'Now', 'Also'];
                    if (Math.random() < (0.15 * variationLevel) && i > 0) {
                        sentence = conjunctions[Math.floor(Math.random() * conjunctions.length)] + ' ' + 
                                  sentence.charAt(0).toLowerCase() + sentence.slice(1);
                    }
                    
                    result.push(sentence);
                }
                
                return result.join('. ') + (text.endsWith('.') ? '' : '.');
            }
            
            function addConversationalElements(text, style) {
                let result = text;
                
                // Common contractions
                result = result.replace(/\bdo not\b/g, "don't");
                result = result.replace(/\bdoes not\b/g, "doesn't");
                result = result.replace(/\bdid not\b/g, "didn't");
                result = result.replace(/\bcan not\b/g, "can't");
                result = result.replace(/\bcould not\b/g, "couldn't");
                result = result.replace(/\bwill not\b/g, "won't");
                result = result.replace(/\bshould not\b/g, "shouldn't");
                result = result.replace(/\bis not\b/g, "isn't");
                result = result.replace(/\bare not\b/g, "aren't");
                result = result.replace(/\bwas not\b/g, "wasn't");
                result = result.replace(/\bwere not\b/g, "weren't");
                result = result.replace(/\bhave not\b/g, "haven't");
                result = result.replace(/\bhas not\b/g, "hasn't");
                result = result.replace(/\bhad not\b/g, "hadn't");
                result = result.replace(/\bwould not\b/g, "wouldn't");
                result = result.replace(/\bmust not\b/g, "mustn't");
                result = result.replace(/\bI am\b/g, "I'm");
                result = result.replace(/\bhe is\b/g, "he's");
                result = result.replace(/\bshe is\b/g, "she's");
                result = result.replace(/\bit is\b/g, "it's");
                result = result.replace(/\bwe are\b/g, "we're");
                result = result.replace(/\bthey are\b/g, "they're");
                result = result.replace(/\byou are\b/g, "you're");
                result = result.replace(/\bI will\b/g, "I'll");
                result = result.replace(/\bhe will\b/g, "he'll");
                result = result.replace(/\bshe will\b/g, "she'll");
                result = result.replace(/\bit will\b/g, "it'll");
                result = result.replace(/\bwe will\b/g, "we'll");
                result = result.replace(/\bthey will\b/g, "they'll");
                result = result.replace(/\byou will\b/g, "you'll");
                result = result.replace(/\bI would\b/g, "I'd");
                result = result.replace(/\bhe would\b/g, "he'd");
                result = result.replace(/\bshe would\b/g, "she'd");
                result = result.replace(/\bit would\b/g, "it'd");
                result = result.replace(/\bwe would\b/g, "we'd");
                result = result.replace(/\bthey would\b/g, "they'd");
                result = result.replace(/\byou would\b/g, "you'd");
                result = result.replace(/\bI have\b/g, "I've");
                result = result.replace(/\bwe have\b/g, "we've");
                result = result.replace(/\bthey have\b/g, "they've");
                result = result.replace(/\byou have\b/g, "you've");
                
                // Style-specific additions
                if (style === 'casual') {
                    const fillers = ['you know', 'I mean', 'like', 'well', 'so', 'actually', 'basically', 'sort of'];
                    const sentences = result.split('. ');
                    
                    for (let i = 0; i < sentences.length; i++) {
                        if (Math.random() > 0.7 && sentences[i].length > 20) {
                            const randomFiller = fillers[Math.floor(Math.random() * fillers.length)];
                            const words = sentences[i].split(' ');
                            const insertPos = Math.floor(Math.random() * (words.length - 3)) + 1;
                            words.splice(insertPos, 0, randomFiller);
                            sentences[i] = words.join(' ');
                        }
                    }
                    
                    result = sentences.join('. ');
                }
                
                return result;
            }
            
            function addHumanErrors(text, errorLevel) {
                if (errorLevel === 0) return text;
                
                let result = text;
                const sentences = result.split('. ');
                let newSentences = [];
                
                for (let sentence of sentences) {
                    // Skip empty sentences
                    if (!sentence.trim()) continue;
                    
                    // Apply errors based on error level
                    if (Math.random() < (0.1 * errorLevel)) {
                        // Common homophone errors
                        sentence = sentence.replace(/\btheir\b/g, () => Math.random() > 0.5 ? "there" : "they're");
                        sentence = sentence.replace(/\bthere\b/g, () => Math.random() > 0.5 ? "their" : "they're");
                        sentence = sentence.replace(/\byou're\b/g, () => Math.random() > 0.5 ? "your" : "you're");
                        sentence = sentence.replace(/\byour\b/g, () => Math.random() > 0.5 ? "you're" : "your");
                        sentence = sentence.replace(/\bits\b/g, () => Math.random() > 0.5 ? "it's" : "its");
                        sentence = sentence.replace(/\bit's\b/g, () => Math.random() > 0.5 ? "its" : "it's");
                    }
                    
                    if (Math.random() < (0.15 * errorLevel)) {
                        // Remove or add apostrophes randomly
                        const words = sentence.split(' ');
                        for (let i = 0; i < words.length; i++) {
                            if (words[i].endsWith('s') && Math.random() < 0.1) {
                                words[i] = words[i].replace(/s$/, "'s");
                            } else if (words[i].endsWith("'s") && Math.random() < 0.1) {
                                words[i] = words[i].replace(/'s$/, "s");
                            }
                        }
                        sentence = words.join(' ');
                    }
                    
                    if (Math.random() < (0.1 * errorLevel)) {
                        // Add a typo (random character change)
                        const pos = Math.floor(Math.random() * (sentence.length - 3)) + 1;
                        sentence = sentence.substring(0, pos) + sentence.substring(pos + 1);
                    }
                    
                    if (Math.random() < (0.05 * errorLevel)) {
                        // Add a double word
                        const words = sentence.split(' ');
                        if (words.length > 3) {
                            const pos = Math.floor(Math.random() * (words.length - 2)) + 1;
                            words.splice(pos, 0, words[pos]);
                            sentence = words.join(' ');
                        }
                    }
                    
                    newSentences.push(sentence);
                }
                
                return newSentences.join('. ');
            }
            
            function addPersonalPerspective(text, style) {
                const sentences = text.split('. ');
                if (sentences.length < 2) return text;
                
                // Choose a random sentence to modify
                const pos = Math.floor(Math.random() * (sentences.length - 1));
                
                // Add perspective based on style
                if (style === 'casual') {
                    const phrases = [
                        "From my experience, ",
                        "I've found that ",
                        "Personally, I think ",
                        "In my opinion, ",
                        "What I've noticed is ",
                        "I feel like ",
                        "If you ask me, "
                    ];
                    sentences[pos] = phrases[Math.floor(Math.random() * phrases.length)] + 
                                    sentences[pos].charAt(0).toLowerCase() + sentences[pos].slice(1);
                } 
                else if (style === 'professional') {
                    const phrases = [
                        "Based on my professional experience, ",
                        "In my professional opinion, ",
                        "From my perspective, ",
                        "My analysis suggests that ",
                        "The evidence indicates that ",
                        "Research has shown that ",
                        "Industry best practices suggest "
                    ];
                    sentences[pos] = phrases[Math.floor(Math.random() * phrases.length)] + 
                                    sentences[pos].charAt(0).toLowerCase() + sentences[pos].slice(1);
                }
                else { // creative
                    const phrases = [
                        "I'm fascinated by how ",
                        "What intrigues me is ",
                        "I'm drawn to the idea that ",
                        "It's remarkable how ",
                        "I'm continually amazed by ",
                        "There's something compelling about ",
                        "What captures my imagination is "
                    ];
                    sentences[pos] = phrases[Math.floor(Math.random() * phrases.length)] + 
                                    sentences[pos].charAt(0).toLowerCase() + sentences[pos].slice(1);
                }
                
                return sentences.join('. ');
            }
            
            function rephraseSentences(text) {
                const sentences = text.split('. ');
                if (sentences.length < 2) return text;
                
                // Choose some random sentences to rephrase
                for (let i = 0; i < sentences.length; i++) {
                    if (Math.random() > 0.7) {
                        // Simple rephrasing by changing word order or synonyms
                        let sentence = sentences[i];
                        
                        // Replace common AI phrases with more human alternatives
                        sentence = sentence.replace(/\bhowever\b/g, () => 
                            Math.random() > 0.5 ? "but" : "though");
                        sentence = sentence.replace(/\badditionally\b/g, () => 
                            Math.random() > 0.5 ? "also" : "what's more");
                        sentence = sentence.replace(/\bfurthermore\b/g, () => 
                            Math.random() > 0.5 ? "plus" : "on top of that");
                        sentence = sentence.replace(/\bmoreover\b/g, () => 
                            Math.random() > 0.5 ? "and" : "not only that");
                        sentence = sentence.replace(/\bin conclusion\b/g, () => 
                            Math.random() > 0.5 ? "to sum up" : "so");
                        
                        // Change passive to active voice sometimes
                        if (Math.random() > 0.7) {
                            sentence = sentence.replace(/\bis (\w+)ed by\b/g, "$1s");
                            sentence = sentence.replace(/\bare (\w+)ed by\b/g, "$1");
                            sentence = sentence.replace(/\bwas (\w+)ed by\b/g, "$1ed");
                            sentence = sentence.replace(/\bwere (\w+)ed by\b/g, "$1ed");
                        }
                        
                        sentences[i] = sentence;
                    }
                }
                
                return sentences.join('. ');
            }
            
            function clearText() {
                aiContent.value = '';
                outputText.textContent = '';
                outputSection.classList.add('hidden');
                resetAiDetectionResults();
            }
            
            function loadSampleText() {
                const sampleText = `Artificial intelligence has revolutionized many aspects of our daily lives. From voice assistants to recommendation systems, AI technologies are becoming increasingly sophisticated. However, one challenge with AI-generated content is that it often lacks the natural flow and imperfections of human writing. This tool helps bridge that gap by converting AI text into more human-like writing patterns that can bypass detection systems.`;
                aiContent.value = sampleText;
            }
            
            function copyOutputText() {
                const text = outputText.textContent;
                if (!text || text === 'Processing...') {
                    alert('No text available to copy.');
                    return;
                }
                
                navigator.clipboard.writeText(text).then(function() {
                    // Show copied feedback
                    const originalText = copyBtn.innerHTML;
                    copyBtn.innerHTML = '<i class="fas fa-check mr-2"></i> Copied!';
                    copyBtn.classList.remove('bg-purple-600', 'hover:bg-purple-700');
                    copyBtn.classList.add('bg-green-600');
                    
                    setTimeout(function() {
                        copyBtn.innerHTML = originalText;
                        copyBtn.classList.remove('bg-green-600');
                        copyBtn.classList.add('bg-purple-600', 'hover:bg-purple-700');
                    }, 2000);
                }).catch(function(err) {
                    console.error('Could not copy text: ', err);
                    alert('Failed to copy text to clipboard.');
                });
            }
            
            function downloadText() {
                const text = outputText.textContent;
                if (!text || text === 'Processing...') {
                    alert('No text available to download.');
                    return;
                }
                
                const blob = new Blob([text], { type: 'text/plain' });
                const url = URL.createObjectURL(blob);
                const a = document.createElement('a');
                a.href = url;
                a.download = 'humanized-text.txt';
                document.body.appendChild(a);
                a.click();
                document.body.removeChild(a);
                URL.revokeObjectURL(url);
            }
            
            function checkAiDetection() {
                const originalText = aiContent.value.trim();
                const humanizedText = outputText.textContent.trim();
                
                if (!originalText || !humanizedText || humanizedText === 'Processing...') {
                    alert('Please humanize some text first before checking AI detection.');
                    return;
                }
                
                // Simulate AI detection analysis
                // In a real app, this would call an API to check with detectors like GPTZero, Originality.ai, etc.
                const originalScore = Math.min(90 + Math.floor(Math.random() * 10), 100); // 90-100%
                const humanizedScore = Math.max(5, Math.floor(Math.random() * 30)); // 5-30%
                
                // Update UI
                document.getElementById('originalAiScore').textContent = originalScore + '% likely AI';
                document.getElementById('humanizedAiScore').textContent = humanizedScore + '% likely AI';
                document.getElementById('originalAiBar').style.width = originalScore + '%';
                document.getElementById('humanizedAiBar').style.width = humanizedScore + '%';
                
                // Color code based on score
                if (originalScore > 70) {
                    document.getElementById('originalAiScore').classList.add('text-red-600');
                } else {
                    document.getElementById('originalAiScore').classList.remove('text-red-600');
                }
                
                if (humanizedScore < 30) {
                    document.getElementById('humanizedAiScore').classList.add('text-green-600');
                } else {
                    document.getElementById('humanizedAiScore').classList.remove('text-green-600');
                }
            }
            
            function resetAiDetectionResults() {
                document.getElementById('originalAiScore').textContent = 'Not analyzed';
                document.getElementById('humanizedAiScore').textContent = 'Not analyzed';
                document.getElementById('originalAiBar').style.width = '0%';
                document.getElementById('humanizedAiBar').style.width = '0%';
                document.getElementById('originalAiScore').classList.remove('text-red-600');
                document.getElementById('humanizedAiScore').classList.remove('text-green-600');
            }
        });
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Zeeshsan/humanizeai" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>