File size: 31,210 Bytes
66a1967
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79f78e8
 
66a1967
 
 
 
 
 
 
 
 
 
 
 
 
79f78e8
66a1967
 
79f78e8
66a1967
 
 
79f78e8
 
 
 
 
 
 
 
 
 
 
 
 
 
66a1967
 
 
 
 
 
 
 
 
 
79f78e8
 
 
 
 
 
 
 
 
 
 
66a1967
 
79f78e8
66a1967
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79f78e8
66a1967
79f78e8
 
 
 
 
 
 
 
 
 
 
 
 
 
66a1967
79f78e8
66a1967
79f78e8
 
 
 
 
 
 
 
66a1967
79f78e8
66a1967
79f78e8
 
 
 
 
 
 
 
 
 
 
 
 
 
66a1967
 
79f78e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66a1967
 
79f78e8
 
 
 
 
 
 
 
 
66a1967
 
79f78e8
 
66a1967
 
79f78e8
 
 
 
 
 
 
 
 
 
 
 
 
66a1967
 
 
79f78e8
66a1967
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>NeonScraper | Dark Web Explorer</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">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        neon: {
                            blue: '#00f2ff',
                            purple: '#9d00ff',
                            pink: '#ff00f2',
                            green: '#00ff9d'
                        },
                        dark: {
                            900: '#0a0a0a',
                            800: '#1a1a1a',
                            700: '#2a2a2a',
                            600: '#3a3a3a'
                        }
                    },
                    fontFamily: {
                        'sans': ['Inter', 'ui-sans-serif', 'system-ui'],
                        'mono': ['Fira Code', 'ui-monospace', 'SFMono-Regular']
                    }
                }
            }
        }
    </script>
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Fira+Code:wght@400;500&display=swap');
        
        body {
            background-color: #0a0a0a;
            color: #e5e5e5;
            font-family: 'Inter', sans-serif;
        }
        
        .neon-glow {
            box-shadow: 0 0 10px rgba(157, 0, 255, 0.7), 
                        0 0 20px rgba(157, 0, 255, 0.5),
                        0 0 30px rgba(157, 0, 255, 0.3);
        }
        
        .neon-text {
            text-shadow: 0 0 5px rgba(157, 0, 255, 0.7),
                         0 0 10px rgba(157, 0, 255, 0.5);
        }
        
        .input-glow:focus {
            box-shadow: 0 0 5px rgba(0, 242, 255, 0.7),
                        0 0 10px rgba(0, 242, 255, 0.5);
            border-color: rgba(0, 242, 255, 0.5);
        }
        
        .tor-status {
            animation: pulse 2s infinite;
        }
        
        @keyframes pulse {
            0% { opacity: 1; }
            50% { opacity: 0.7; }
            100% { opacity: 1; }
        }
        
        .result-card {
            transition: all 0.3s ease;
            border-left: 3px solid transparent;
        }
        
        .result-card:hover {
            transform: translateY(-2px);
            border-left: 3px solid #9d00ff;
        }
        
        .loader {
            border: 3px solid rgba(157, 0, 255, 0.3);
            border-top: 3px solid #9d00ff;
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }
        
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
    </style>
</head>
<body class="min-h-screen bg-dark-900">
    <div class="container mx-auto px-4 py-8 max-w-6xl">
        <!-- Header -->
        <header class="flex items-center justify-between mb-12">
            <div class="flex items-center space-x-3">
                <div class="w-10 h-10 rounded-full bg-gradient-to-br from-neon-blue to-neon-purple flex items-center justify-center neon-glow">
                    <i class="fas fa-robot text-white text-xl"></i>
                </div>
                <h1 class="text-2xl font-bold text-white neon-text">Neon<span class="text-neon-purple">Scraper</span></h1>
            </div>
            <div class="flex items-center space-x-4">
                <button id="torCheckBtn" class="px-4 py-2 bg-dark-700 hover:bg-dark-600 rounded-lg flex items-center space-x-2 transition-colors">
                    <span class="text-sm font-medium">Check Tor Connection</span>
                    <i class="fas fa-shield-alt"></i>
                </button>
                <div id="torStatus" class="hidden px-3 py-1 rounded-full text-xs font-medium flex items-center space-x-1">
                    <span class="w-2 h-2 rounded-full"></span>
                    <span>Status</span>
                </div>
            </div>
        </header>
        
        <!-- Main Content -->
        <main>
            <div class="bg-dark-800 rounded-xl p-6 shadow-lg mb-8 neon-glow">
                <div class="flex flex-col md:flex-row md:items-end justify-between mb-6">
                    <div class="mb-4 md:mb-0">
                        <h2 class="text-xl font-bold mb-2">Dark Web Explorer</h2>
                        <p class="text-gray-400 text-sm">Enter a .onion URL or search term to begin scraping</p>
                    </div>
                    <div class="flex space-x-3">
                        <button id="settingsBtn" class="px-3 py-2 bg-dark-700 hover:bg-dark-600 rounded-lg">
                            <i class="fas fa-cog"></i>
                        </button>
                        <button id="helpBtn" class="px-3 py-2 bg-dark-700 hover:bg-dark-600 rounded-lg">
                            <i class="fas fa-question-circle"></i>
                        </button>
                    </div>
                </div>
                
                <div class="relative">
                    <div class="flex">
                        <input id="searchInput" type="text" placeholder="Enter .onion URL or search term..." 
                               class="input-glow flex-1 px-4 py-3 bg-dark-700 border border-dark-600 rounded-l-lg focus:outline-none focus:border-neon-blue transition-colors">
                        <button id="searchBtn" class="px-6 py-3 bg-gradient-to-r from-neon-purple to-neon-blue text-white font-medium rounded-r-lg hover:opacity-90 transition-opacity">
                            <i class="fas fa-search mr-2"></i> Search
                        </button>
                    </div>
                    <div class="mt-2 flex items-center space-x-4 text-xs text-gray-400">
                        <div class="flex items-center space-x-1">
                            <i class="fas fa-lock"></i>
                            <span>End-to-end encrypted</span>
                        </div>
                        <div class="flex items-center space-x-1">
                            <i class="fas fa-user-secret"></i>
                            <span>No logs kept</span>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- Tor Connection Required Warning -->
            <div id="torWarning" class="bg-dark-800 border-l-4 border-neon-purple rounded-lg p-4 mb-8 hidden">
                <div class="flex items-start">
                    <div class="flex-shrink-0 pt-1">
                        <i class="fas fa-exclamation-triangle text-neon-purple text-xl"></i>
                    </div>
                    <div class="ml-3">
                        <h3 class="text-lg font-medium text-white">Tor Connection Required</h3>
                        <div class="mt-2 text-sm text-gray-300">
                            <p>You must be connected to the Tor network to use this service. Please check your Tor connection and try again.</p>
                        </div>
                        <div class="mt-4">
                            <a href="https://www.torproject.org/download/" target="_blank" class="inline-flex items-center px-3 py-2 bg-neon-purple/20 border border-neon-purple rounded-md text-sm font-medium text-neon-purple hover:bg-neon-purple/30">
                                <i class="fas fa-download mr-2"></i> Download Tor Browser
                            </a>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- Results Section -->
            <div id="resultsSection" class="hidden">
                <div class="flex items-center justify-between mb-4">
                    <h3 class="text-lg font-medium">Search Results</h3>
                    <div class="text-sm text-gray-400">
                        <span id="resultCount">0</span> results found
                    </div>
                </div>
                
                <div id="resultsContainer" class="space-y-4">
                    <!-- Results will be inserted here -->
                </div>
                
                <div id="loadingIndicator" class="hidden py-12 flex flex-col items-center justify-center">
                    <div class="loader w-10 h-10 mb-4"></div>
                    <p class="text-neon-blue">Scraping the dark web...</p>
                    <p class="text-xs text-gray-400 mt-2">This may take some time depending on the site</p>
                </div>
                
                <div id="noResults" class="hidden py-12 text-center">
                    <i class="fas fa-search text-4xl text-gray-500 mb-4"></i>
                    <h4 class="text-lg font-medium text-gray-300">No results found</h4>
                    <p class="text-gray-500 mt-2">Try a different search term or URL</p>
                </div>
            </div>
            
            <!-- Sample Result (hidden by default) -->
            <div id="sampleResult" class="hidden">
                <div class="result-card bg-dark-800 rounded-lg p-4 hover:bg-dark-700 transition-colors">
                    <div class="flex items-start justify-between">
                        <div>
                            <h4 class="font-medium text-white mb-1">Example Result</h4>
                            <p class="text-xs text-neon-blue mb-2">http://example.onion</p>
                            <p class="text-sm text-gray-300 line-clamp-2">This is an example result that would show a preview of the scraped content from the dark web. The actual content would be replaced with real data when scraping occurs.</p>
                        </div>
                        <div class="flex space-x-2">
                            <button class="p-1 text-gray-400 hover:text-neon-blue">
                                <i class="fas fa-external-link-alt"></i>
                            </button>
                            <button class="p-1 text-gray-400 hover:text-neon-purple">
                                <i class="fas fa-bookmark"></i>
                            </button>
                        </div>
                    </div>
                    <div class="mt-3 pt-2 border-t border-dark-700 flex items-center justify-between">
                        <div class="flex space-x-3 text-xs text-gray-400">
                            <span class="flex items-center space-x-1">
                                <i class="fas fa-calendar-alt"></i>
                                <span>2023-07-15</span>
                            </span>
                            <span class="flex items-center space-x-1">
                                <i class="fas fa-tag"></i>
                                <span>Marketplace</span>
                            </span>
                        </div>
                        <div class="text-xs text-neon-green">
                            <span class="px-2 py-1 bg-neon-green/10 rounded">Verified</span>
                        </div>
                    </div>
                </div>
            </div>
        </main>
        
        <!-- Footer -->
        <footer class="mt-16 pt-8 border-t border-dark-700 text-center text-gray-500 text-sm">
            <div class="flex flex-col md:flex-row justify-center items-center space-y-2 md:space-y-0 md:space-x-6">
                <a href="#" class="hover:text-neon-purple transition-colors">Terms of Service</a>
                <a href="#" class="hover:text-neon-purple transition-colors">Privacy Policy</a>
                <a href="#" class="hover:text-neon-purple transition-colors">Disclaimer</a>
                <a href="#" class="hover:text-neon-purple transition-colors">Contact</a>
            </div>
            <p class="mt-4">© 2023 NeonScraper. All rights reserved.</p>
            <p class="mt-2 text-xs text-gray-600">This is a demonstration only. Use responsibly and legally.</p>
        </footer>
    </div>
    
    <!-- Settings Modal -->
    <div id="settingsModal" class="fixed inset-0 bg-black bg-opacity-70 flex items-center justify-center z-50 hidden">
        <div class="bg-dark-800 rounded-xl p-6 w-full max-w-md neon-glow">
            <div class="flex items-center justify-between mb-6">
                <h3 class="text-xl font-bold">Settings</h3>
                <button id="closeSettingsBtn" class="text-gray-400 hover:text-white">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            
            <div class="space-y-6">
                <div>
                    <h4 class="font-medium mb-3">Scraping Options</h4>
                    <div class="space-y-3">
                        <label class="flex items-center space-x-3">
                            <input type="checkbox" class="form-checkbox rounded bg-dark-700 border-dark-600 text-neon-purple">
                            <span>Enable JavaScript rendering</span>
                        </label>
                        <label class="flex items-center space-x-3">
                            <input type="checkbox" class="form-checkbox rounded bg-dark-700 border-dark-600 text-neon-purple" checked>
                            <span>Follow redirects</span>
                        </label>
                        <label class="flex items-center space-x-3">
                            <input type="checkbox" class="form-checkbox rounded bg-dark-700 border-dark-600 text-neon-purple">
                            <span>Download media files</span>
                        </label>
                    </div>
                </div>
                
                <div>
                    <h4 class="font-medium mb-3">Privacy Options</h4>
                    <div class="space-y-3">
                        <label class="flex items-center space-x-3">
                            <input type="checkbox" class="form-checkbox rounded bg-dark-700 border-dark-600 text-neon-purple" checked>
                            <span>Clear search history on exit</span>
                        </label>
                        <label class="flex items-center space-x-3">
                            <input type="checkbox" class="form-checkbox rounded bg-dark-700 border-dark-600 text-neon-purple">
                            <span>Use random user agents</span>
                        </label>
                    </div>
                </div>
                
                <div>
                    <h4 class="font-medium mb-2">Tor Proxy Settings</h4>
                    <div class="space-y-2">
                        <div>
                            <label class="block text-sm text-gray-400 mb-1">Host</label>
                            <input type="text" value="127.0.0.1" class="w-full px-3 py-2 bg-dark-700 border border-dark-600 rounded focus:outline-none focus:border-neon-blue">
                        </div>
                        <div>
                            <label class="block text-sm text-gray-400 mb-1">Port</label>
                            <input type="text" value="9050" class="w-full px-3 py-2 bg-dark-700 border border-dark-600 rounded focus:outline-none focus:border-neon-blue">
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="mt-8 flex justify-end space-x-3">
                <button id="cancelSettingsBtn" class="px-4 py-2 bg-dark-700 hover:bg-dark-600 rounded-lg">
                    Cancel
                </button>
                <button id="saveSettingsBtn" class="px-4 py-2 bg-neon-purple hover:bg-neon-purple/90 rounded-lg">
                    Save Settings
                </button>
            </div>
        </div>
    </div>
    
    <!-- Help Modal -->
    <div id="helpModal" class="fixed inset-0 bg-black bg-opacity-70 flex items-center justify-center z-50 hidden">
        <div class="bg-dark-800 rounded-xl p-6 w-full max-w-2xl neon-glow">
            <div class="flex items-center justify-between mb-6">
                <h3 class="text-xl font-bold">Help & Information</h3>
                <button id="closeHelpBtn" class="text-gray-400 hover:text-white">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            
            <div class="space-y-6">
                <div>
                    <h4 class="font-medium mb-3 text-neon-blue">Getting Started</h4>
                    <p class="text-gray-300 mb-3">NeonScraper allows you to safely explore and scrape content from the dark web through the Tor network.</p>
                    <ol class="list-decimal list-inside space-y-2 text-gray-300">
                        <li>Ensure you're connected to Tor (check status in top right)</li>
                        <li>Enter a .onion URL or search term in the input field</li>
                        <li>Click "Search" to begin scraping</li>
                        <li>View results and interact with them as needed</li>
                    </ol>
                </div>
                
                <div>
                    <h4 class="font-medium mb-3 text-neon-blue">Safety Guidelines</h4>
                    <ul class="list-disc list-inside space-y-2 text-gray-300">
                        <li>Never enter personal information</li>
                        <li>Don't download files unless you trust the source</li>
                        <li>Be aware that some sites may contain illegal content</li>
                        <li>Use VPN for additional anonymity if desired</li>
                        <li>This tool is for research purposes only</li>
                    </ul>
                </div>
                
                <div>
                    <h4 class="font-medium mb-3 text-neon-blue">Frequently Asked Questions</h4>
                    <div class="space-y-4">
                        <div>
                            <h5 class="font-medium text-gray-300">Why do I need Tor?</h5>
                            <p class="text-gray-400 text-sm mt-1">Tor is required to access .onion sites which are only available on the dark web. It also provides anonymity for your searches.</p>
                        </div>
                        <div>
                            <h5 class="font-medium text-gray-300">Is this legal?</h5>
                            <p class="text-gray-400 text-sm mt-1">Accessing the dark web itself is legal in most countries, but the legality depends on what you do with it. Always comply with local laws.</p>
                        </div>
                        <div>
                            <h5 class="font-medium text-gray-300">How are results verified?</h5>
                            <p class="text-gray-400 text-sm mt-1">Verified results come from known, reputable sources that have been vetted by our community.</p>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="mt-8 flex justify-end">
                <button id="closeHelpBtn2" class="px-4 py-2 bg-neon-purple hover:bg-neon-purple/90 rounded-lg">
                    Got it!
                </button>
            </div>
        </div>
    </div>
    
    <script>
        // DOM Elements
        const torCheckBtn = document.getElementById('torCheckBtn');
        const torStatus = document.getElementById('torStatus');
        const torWarning = document.getElementById('torWarning');
        const searchBtn = document.getElementById('searchBtn');
        const searchInput = document.getElementById('searchInput');
        const resultsSection = document.getElementById('resultsSection');
        const resultsContainer = document.getElementById('resultsContainer');
        const loadingIndicator = document.getElementById('loadingIndicator');
        const noResults = document.getElementById('noResults');
        const resultCount = document.getElementById('resultCount');
        const settingsBtn = document.getElementById('settingsBtn');
        const helpBtn = document.getElementById('helpBtn');
        const settingsModal = document.getElementById('settingsModal');
        const helpModal = document.getElementById('helpModal');
        const closeSettingsBtn = document.getElementById('closeSettingsBtn');
        const closeHelpBtn = document.getElementById('closeHelpBtn');
        const closeHelpBtn2 = document.getElementById('closeHelpBtn2');
        const cancelSettingsBtn = document.getElementById('cancelSettingsBtn');
        const saveSettingsBtn = document.getElementById('saveSettingsBtn');
        
        // State
        let isTorConnected = false;
        let searchInProgress = false;
        let torHost = '127.0.0.1';
        let torPort = '9050';
        
        // Event Listeners
        torCheckBtn.addEventListener('click', checkTorConnection);
        searchBtn.addEventListener('click', startSearch);
        searchInput.addEventListener('keypress', function(e) {
            if (e.key === 'Enter') startSearch();
        });
        settingsBtn.addEventListener('click', () => settingsModal.classList.remove('hidden'));
        helpBtn.addEventListener('click', () => helpModal.classList.remove('hidden'));
        closeSettingsBtn.addEventListener('click', () => settingsModal.classList.add('hidden'));
        closeHelpBtn.addEventListener('click', () => helpModal.classList.add('hidden'));
        closeHelpBtn2.addEventListener('click', () => helpModal.classList.add('hidden'));
        cancelSettingsBtn.addEventListener('click', () => settingsModal.classList.add('hidden'));
        saveSettingsBtn.addEventListener('click', saveSettings);
        
        // Functions
        async function checkTorConnection() {
            torCheckBtn.disabled = true;
            torCheckBtn.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i> Checking...';
            
            try {
                const response = await fetch('/check-tor', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json'
                    },
                    body: JSON.stringify({
                        host: torHost,
                        port: torPort
                    })
                });
                
                const data = await response.json();
                isTorConnected = data.connected;
                
                if (isTorConnected) {
                    torStatus.className = 'px-3 py-1 rounded-full text-xs font-medium flex items-center space-x-1 bg-neon-green/20 text-neon-green';
                    torStatus.innerHTML = '<span class="w-2 h-2 rounded-full bg-neon-green"></span><span>Tor Connected</span>';
                    torWarning.classList.add('hidden');
                } else {
                    torStatus.className = 'px-3 py-1 rounded-full text-xs font-medium flex items-center space-x-1 bg-red-500/20 text-red-500';
                    torStatus.innerHTML = '<span class="w-2 h-2 rounded-full bg-red-500"></span><span>Tor Disconnected</span>';
                    torWarning.classList.remove('hidden');
                }
            } catch (error) {
                console.error('Tor check failed:', error);
                isTorConnected = false;
                torStatus.className = 'px-3 py-1 rounded-full text-xs font-medium flex items-center space-x-1 bg-red-500/20 text-red-500';
                torStatus.innerHTML = '<span class="w-2 h-2 rounded-full bg-red-500"></span><span>Connection Error</span>';
                torWarning.classList.remove('hidden');
            }
            
            torStatus.classList.remove('hidden');
            torCheckBtn.disabled = false;
            torCheckBtn.innerHTML = '<span class="text-sm font-medium">Check Tor Connection</span><i class="fas fa-shield-alt ml-2"></i>';
        }
        
        async function startSearch() {
            if (searchInProgress) return;
            
            if (!isTorConnected) {
                torWarning.classList.remove('hidden');
                return;
            }
            
            const query = searchInput.value.trim();
            if (!query) return;
            
            // Show loading state
            searchInProgress = true;
            resultsSection.classList.remove('hidden');
            loadingIndicator.classList.remove('hidden');
            noResults.classList.add('hidden');
            resultsContainer.innerHTML = '';
            resultCount.textContent = '0';
            searchBtn.disabled = true;
            searchBtn.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i> Scraping';
            
            try {
                const response = await fetch('/scrape', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json'
                    },
                    body: JSON.stringify({
                        url: query,
                        host: torHost,
                        port: torPort
                    })
                });
                
                const data = await response.json();
                
                if (data.error) {
                    noResults.classList.remove('hidden');
                    noResults.innerHTML = `
                        <i class="fas fa-exclamation-triangle text-4xl text-red-500 mb-4"></i>
                        <h4 class="text-lg font-medium text-red-400">Scraping Error</h4>
                        <p class="text-gray-500 mt-2">${data.error}</p>
                    `;
                } else if (data.results && data.results.length > 0) {
                    resultCount.textContent = data.results.length;
                    displayResults(data.results);
                } else {
                    noResults.classList.remove('hidden');
                }
            } catch (error) {
                console.error('Search failed:', error);
                noResults.classList.remove('hidden');
                noResults.innerHTML = `
                    <i class="fas fa-exclamation-triangle text-4xl text-red-500 mb-4"></i>
                    <h4 class="text-lg font-medium text-red-400">Connection Error</h4>
                    <p class="text-gray-500 mt-2">Failed to connect to the dark web site. Please check your Tor connection.</p>
                `;
            }
            
            loadingIndicator.classList.add('hidden');
            searchInProgress = false;
            searchBtn.disabled = false;
            searchBtn.innerHTML = '<i class="fas fa-search mr-2"></i> Search';
        }
        
        function displayResults(results) {
            resultsContainer.innerHTML = '';
            
            results.forEach(result => {
                const resultElement = document.createElement('div');
                resultElement.className = 'result-card bg-dark-800 rounded-lg p-4 hover:bg-dark-700 transition-colors';
                resultElement.innerHTML = `
                    <div class="flex items-start justify-between">
                        <div class="flex-1">
                            <h4 class="font-medium text-white mb-1">${escapeHtml(result.title || 'Untitled')}</h4>
                            <p class="text-xs text-neon-blue mb-2">${escapeHtml(result.url)}</p>
                            <p class="text-sm text-gray-300">${escapeHtml(result.description || 'No description available')}</p>
                        </div>
                        <div class="flex space-x-2 ml-4">
                            <button class="p-1 text-gray-400 hover:text-neon-blue" onclick="openInNewTab('${escapeHtml(result.url)}')">
                                <i class="fas fa-external-link-alt"></i>
                            </button>
                            <button class="p-1 text-gray-400 hover:text-neon-purple">
                                <i class="fas fa-bookmark"></i>
                            </button>
                        </div>
                    </div>
                    <div class="mt-3 pt-2 border-t border-dark-700 flex items-center justify-between">
                        <div class="flex space-x-3 text-xs text-gray-400">
                            <span class="flex items-center space-x-1">
                                <i class="fas fa-calendar-alt"></i>
                                <span>${new Date().toISOString().split('T')[0]}</span>
                            </span>
                            <span class="flex items-center space-x-1">
                                <i class="fas fa-tag"></i>
                                <span>${result.type || 'Unknown'}</span>
                            </span>
                        </div>
                        ${result.verified ? '<div class="text-xs text-neon-green"><span class="px-2 py-1 bg-neon-green/10 rounded">Verified</span></div>' : ''}
                    </div>
                `;
                resultsContainer.appendChild(resultElement);
            });
        }
        
        function escapeHtml(unsafe) {
            if (!unsafe) return '';
            return unsafe
                .toString()
                .replace(/&/g, "&amp;")
                .replace(/</g, "&lt;")
                .replace(/>/g, "&gt;")
                .replace(/"/g, "&quot;")
                .replace(/'/g, "&#039;");
        }
        
        function openInNewTab(url) {
            window.open(url, '_blank');
        }
        
        function saveSettings() {
            // Get settings from modal inputs
            const hostInput = document.querySelector('#settingsModal input[type="text"]:nth-child(1)');
            const portInput = document.querySelector('#settingsModal input[type="text"]:nth-child(2)');
            
            if (hostInput && portInput) {
                torHost = hostInput.value;
                torPort = portInput.value;
            }
            
            settingsModal.classList.add('hidden');
            // Re-check connection with new settings
            checkTorConnection();
        }
        
        // Initialize with Tor check
        window.addEventListener('DOMContentLoaded', checkTorConnection);
    </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=flitrx/dws2" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>