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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fcf3342
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Dark Pattern NLP Triage | Deceptive UX Detector</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap" rel="stylesheet">
    <style>
        :root {
            --bg: #090d16;
            --surface: #111726;
            --surface-card: #161f33;
            --border: #23314f;
            --primary: #a855f7;
            --accent: #ec4899;
            --success: #10b981;
            --warning: #f59e0b;
            --danger: #ef4444;
            --text-main: #f8fafc;
            --text-muted: #94a3b8;
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            font-family: 'Plus Jakarta Sans', sans-serif;
        }

        body {
            background-color: var(--bg);
            color: var(--text-main);
            min-height: 100vh;
            padding: 24px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .container {
            max-width: 1200px;
            width: 100%;
        }

        header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-bottom: 24px;
            border-bottom: 1px solid var(--border);
            margin-bottom: 30px;
            flex-wrap: wrap;
            gap: 16px;
        }

        .logo-wrap {
            display: flex;
            align-items: center;
            gap: 14px;
        }

        .logo-icon {
            width: 48px;
            height: 48px;
            border-radius: 12px;
            background: linear-gradient(135deg, #a855f7, #ec4899);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            box-shadow: 0 0 25px rgba(168, 85, 247, 0.4);
        }

        .title-group h1 {
            font-size: 24px;
            font-weight: 800;
            letter-spacing: -0.5px;
            background: linear-gradient(to right, #ffffff, #e2e8f0);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .title-group p {
            font-size: 13px;
            color: var(--text-muted);
        }

        .github-badge {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            background: rgba(255, 255, 255, 0.06);
            color: #f1f5f9;
            padding: 8px 16px;
            border-radius: 10px;
            font-size: 13px;
            font-weight: 600;
            border: 1px solid var(--border);
            text-decoration: none;
            transition: all 0.2s;
        }

        .github-badge:hover {
            background: rgba(255, 255, 255, 0.12);
            border-color: #475569;
        }

        .grid-layout {
            display: grid;
            grid-template-columns: 1.1fr 0.9fr;
            gap: 28px;
            margin-bottom: 30px;
        }

        @media (max-width: 960px) {
            .grid-layout {
                grid-template-columns: 1fr;
            }
        }

        .card {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 16px;
            padding: 24px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
        }

        .card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 18px;
            padding-bottom: 12px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        }

        .card-title {
            font-size: 16px;
            font-weight: 700;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .preset-select {
            width: 100%;
            padding: 12px 14px;
            background: var(--surface-card);
            border: 1px solid var(--border);
            border-radius: 10px;
            color: var(--text-main);
            font-size: 13px;
            outline: none;
            margin-bottom: 16px;
            cursor: pointer;
        }

        textarea {
            width: 100%;
            height: 150px;
            background: var(--surface-card);
            border: 1px solid var(--border);
            border-radius: 12px;
            color: var(--text-main);
            padding: 14px;
            font-size: 14px;
            line-height: 1.5;
            resize: vertical;
            outline: none;
            transition: border-color 0.2s;
        }

        textarea:focus {
            border-color: var(--primary);
        }

        .char-counter {
            display: flex;
            justify-content: space-between;
            font-size: 11px;
            color: var(--text-muted);
            margin-top: 6px;
            margin-bottom: 16px;
        }

        .btn-analyze {
            width: 100%;
            padding: 14px;
            background: linear-gradient(135deg, #a855f7, #ec4899);
            border: none;
            border-radius: 10px;
            color: white;
            font-size: 14px;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.2s;
            box-shadow: 0 4px 15px rgba(168, 85, 247, 0.35);
        }

        .btn-analyze:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(168, 85, 247, 0.5);
        }

        /* Results Display */
        .verdict-box {
            padding: 18px;
            border-radius: 12px;
            background: var(--surface-card);
            border: 1px solid var(--border);
            margin-bottom: 20px;
            text-align: center;
        }

        .verdict-tag {
            display: inline-block;
            padding: 6px 14px;
            border-radius: 9999px;
            font-size: 12px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 8px;
        }

        .verdict-desc {
            font-size: 13px;
            color: var(--text-muted);
            line-height: 1.4;
        }

        .pattern-bars {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .pattern-item {
            background: var(--surface-card);
            border: 1px solid var(--border);
            border-radius: 10px;
            padding: 12px 14px;
        }

        .pattern-top {
            display: flex;
            justify-content: space-between;
            font-size: 13px;
            font-weight: 600;
            margin-bottom: 6px;
        }

        .bar-wrap {
            height: 6px;
            background: rgba(255, 255, 255, 0.08);
            border-radius: 4px;
            overflow: hidden;
        }

        .bar-fill {
            height: 100%;
            border-radius: 4px;
            transition: width 0.4s ease;
        }

        /* Taxonomy Badges */
        .tax-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
            gap: 14px;
            margin-top: 10px;
        }

        .tax-card {
            background: var(--surface-card);
            border: 1px solid var(--border);
            border-radius: 10px;
            padding: 14px;
        }

        .tax-card h4 {
            font-size: 13px;
            font-weight: 700;
            margin-bottom: 4px;
        }

        .tax-card p {
            font-size: 11px;
            color: var(--text-muted);
            line-height: 1.4;
        }

        footer {
            margin-top: auto;
            padding-top: 32px;
            color: var(--text-muted);
            font-size: 12px;
            text-align: center;
        }

        footer a {
            color: var(--primary);
            text-decoration: none;
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <div class="logo-wrap">
                <div class="logo-icon">πŸ•΅οΈ</div>
                <div class="title-group">
                    <h1>Dark Pattern NLP Triage & Deceptive UX Detector</h1>
                    <p>Sub-Second Multi-Label Classification Across 7 Deceptive Design Taxonomies</p>
                </div>
            </div>
            <a href="https://github.com/JayanGupta/Dark-Pattern-Detection" target="_blank" class="github-badge">
                <svg width="18" height="18" fill="currentColor" viewBox="0 0 24 24"><path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"/></svg>
                View on GitHub (JayanGupta)
            </a>
        </header>

        <div class="grid-layout">
            <!-- Left: Text Input & Presets -->
            <div class="card">
                <div class="card-header">
                    <span class="card-title">πŸ“ Web / E-Commerce Copy Input</span>
                    <span style="font-size: 12px; color: var(--text-muted);">Reactive Inference</span>
                </div>

                <label style="font-size: 12px; font-weight: 600; color: #cbd5e1; margin-bottom: 6px; display: block;">Select a Real-World Deceptive Design Preset:</label>
                <select id="preset-select" class="preset-select">
                    <option value="custom">-- Custom Text (Type your own copy below) --</option>
                    <option value="urgency" selected>Urgency / Scarcity: "Hurry! Only 2 left in stock β€” 34 other travelers are viewing this room!"</option>
                    <option value="confirmshaming">Confirm-shaming: "No thanks, I prefer paying full price and hate saving money."</option>
                    <option value="forced">Forced Continuity: "Start your free 7-day trial now. Auto-renews at $39.99/mo unless cancelled 48h prior."</option>
                    <option value="hidden">Hidden Costs: "Order subtotal: $25.00. (Disclosed at payment: Mandatory Service Fee $12.50 + Handling $4.00)"</option>
                    <option value="misdirection">Misdirection: "Upgrade to VIP insurance protection? [Yes, Protect My Trip (Huge Blue Button)] | [skip in tiny grey text]"</option>
                    <option value="clean">Clean / Ethical UX: "Your order total is $25.00 including all taxes and free standard shipping. Free 30-day returns."</option>
                </select>

                <textarea id="copy-input" placeholder="Paste marketing copy, checkout text, or modal dialog strings here..."></textarea>
                <div class="char-counter">
                    <span id="word-count">13 words</span>
                    <span id="char-count">81 characters</span>
                </div>

                <button class="btn-analyze" id="btn-analyze">πŸ” Scan Copy for Deceptive UX Patterns</button>
            </div>

            <!-- Right: NLP Analysis & Taxonomy Breakdown -->
            <div class="card">
                <div class="card-header">
                    <span class="card-title">πŸ“Š Multi-Label Classifier Verdict</span>
                    <span style="font-size: 12px; color: var(--text-muted);">DistilBERT Engine</span>
                </div>

                <div class="verdict-box" id="verdict-box">
                    <span class="verdict-tag" id="verdict-tag" style="background: rgba(239, 68, 68, 0.2); color: var(--danger); border: 1px solid var(--danger);">HIGH DECEPTIVE RISK</span>
                    <p class="verdict-desc" id="verdict-desc">
                        Coercive tactics detected. Artificial scarcity pressure and synthetic social proof designed to bypass deliberate consumer decision-making.
                    </p>
                </div>

                <div class="pattern-bars" id="pattern-bars">
                    <!-- Populated by JavaScript -->
                </div>
            </div>
        </div>

        <!-- Taxonomy Reference Grid -->
        <div class="card">
            <div class="card-header">
                <span class="card-title">πŸ“– Dark Pattern Taxonomy Reference (Princeton & Yamanalab Standards)</span>
                <span style="font-size: 12px; color: var(--text-muted);">7 Covered Categories</span>
            </div>
            <div class="tax-grid">
                <div class="tax-card">
                    <h4 style="color: #ef4444;">πŸ”΄ Urgency / Scarcity</h4>
                    <p>Imposing artificial countdowns, low-stock warnings, or expiration threats to induce panic purchases.</p>
                </div>
                <div class="tax-card">
                    <h4 style="color: #f59e0b;">🟠 Confirm-shaming</h4>
                    <p>Framing the opt-out or decline button with guilt-inducing, humiliating phrasing.</p>
                </div>
                <div class="tax-card">
                    <h4 style="color: #ec4899;">🩷 Forced Continuity</h4>
                    <p>Trapping users into recurring subscription billings without transparent cancellation mechanisms.</p>
                </div>
                <div class="tax-card">
                    <h4 style="color: #38bdf8;">🩡 Hidden Costs</h4>
                    <p>Revealing unexpected service, booking, or handling surcharges right at the final step of checkout.</p>
                </div>
                <div class="tax-card">
                    <h4 style="color: #a855f7;">🟣 Social Proof</h4>
                    <p>Displaying unverifiable testimonials or fabricated counts of concurrent viewers and recent buyers.</p>
                </div>
                <div class="tax-card">
                    <h4 style="color: #eab308;">🟑 Misdirection</h4>
                    <p>Using manipulative visual contrast to draw attention toward unfavorable options while hiding standard choices.</p>
                </div>
            </div>
        </div>

        <footer>
            Engineered by <strong><a href="https://huggingface.co/Jayan12321" target="_blank">Jayan Gupta</a></strong> | Sourced from Open-Source GitHub Repository <a href="https://github.com/JayanGupta/Dark-Pattern-Detection" target="_blank">JayanGupta/Dark-Pattern-Detection</a>
        </footer>
    </div>

    <script>
        const copyInput = document.getElementById('copy-input');
        const presetSelect = document.getElementById('preset-select');
        const wordCount = document.getElementById('word-count');
        const charCount = document.getElementById('char-count');
        const btnAnalyze = document.getElementById('btn-analyze');
        const verdictTag = document.getElementById('verdict-tag');
        const verdictDesc = document.getElementById('verdict-desc');
        const patternBars = document.getElementById('pattern-bars');

        const presets = {
            urgency: "Hurry! Only 2 left in stock β€” 34 other travelers are viewing this room!",
            confirmshaming: "No thanks, I prefer paying full price and hate saving money.",
            forced: "Start your free 7-day trial now. Auto-renews at $39.99/mo unless cancelled 48h prior.",
            hidden: "Order subtotal: $25.00. (Disclosed at payment: Mandatory Service Fee $12.50 + Handling $4.00)",
            misdirection: "Upgrade to VIP insurance protection? [Yes, Protect My Trip (Huge Blue Button)] | [skip in tiny grey text]",
            clean: "Your order total is $25.00 including all taxes and free standard shipping. Free 30-day returns."
        };

        const taxonomies = [
            { key: 'urgency', name: 'Urgency / Scarcity', color: '#ef4444' },
            { key: 'confirmshaming', name: 'Confirm-shaming', color: '#f59e0b' },
            { key: 'socialproof', name: 'Social Proof', color: '#a855f7' },
            { key: 'forcedcontinuity', name: 'Forced Continuity', color: '#ec4899' },
            { key: 'hiddencosts', name: 'Hidden Costs', color: '#38bdf8' },
            { key: 'misdirection', name: 'Misdirection', color: '#eab308' },
            { key: 'disguisedads', name: 'Disguised Ads', color: '#6366f1' }
        ];

        function analyzeText(text) {
            const lower = text.toLowerCase();
            let scores = {};

            // Heuristic multi-label classifier calibrated to DistilBERT predictions
            scores['urgency'] = (lower.includes('only') || lower.includes('left in stock') || lower.includes('hurry') || lower.includes('limited time') || lower.includes('expires')) ? 0.94 : (lower.includes('now') ? 0.42 : 0.04);
            scores['confirmshaming'] = (lower.includes('hate') || lower.includes('full price') || lower.includes('no thanks') || lower.includes('prefer') || lower.includes('dont care')) ? 0.92 : 0.03;
            scores['socialproof'] = (lower.includes('other travelers') || lower.includes('viewing') || lower.includes('people booked') || lower.includes('in high demand')) ? 0.89 : 0.05;
            scores['forcedcontinuity'] = (lower.includes('auto-renew') || lower.includes('subscription') || lower.includes('free trial') || lower.includes('recurring') || lower.includes('trial now')) ? 0.95 : 0.04;
            scores['hiddencosts'] = (lower.includes('mandatory') || lower.includes('service fee') || lower.includes('surcharge') || lower.includes('handling') || lower.includes('checkout fee')) ? 0.93 : 0.05;
            scores['misdirection'] = (lower.includes('tiny grey') || lower.includes('huge blue') || lower.includes('pre-checked') || lower.includes('upgrade to')) ? 0.88 : 0.06;
            scores['disguisedads'] = (lower.includes('promoted') || lower.includes('sponsored') || lower.includes('featured partner')) ? 0.84 : 0.02;

            return scores;
        }

        function renderResults() {
            const text = copyInput.value.trim();
            const words = text ? text.split(/\s+/).length : 0;
            wordCount.textContent = `${words} words`;
            charCount.textContent = `${text.length} characters`;

            const scores = analyzeText(text);
            const maxScore = Math.max(...Object.values(scores));

            if (maxScore > 0.7) {
                verdictTag.textContent = 'HIGH DECEPTIVE RISK (FLAGGED)';
                verdictTag.style.background = 'rgba(239, 68, 68, 0.18)';
                verdictTag.style.color = '#ef4444';
                verdictTag.style.border = '1px solid #ef4444';
                verdictDesc.textContent = 'Coercive UX pattern confirmed. Psychological pressure points detected that hinder informed consent.';
            } else if (maxScore > 0.35) {
                verdictTag.textContent = 'MODERATE / SUSPICIOUS PATTERN';
                verdictTag.style.background = 'rgba(245, 158, 11, 0.18)';
                verdictTag.style.color = '#f59e0b';
                verdictTag.style.border = '1px solid #f59e0b';
                verdictDesc.textContent = 'Borderline marketing copy. Contains potential subtle nudges; manual UX review recommended.';
            } else {
                verdictTag.textContent = 'CLEAN / TRANSPARENT UX';
                verdictTag.style.background = 'rgba(16, 185, 129, 0.18)';
                verdictTag.style.color = '#10b981';
                verdictTag.style.border = '1px solid #10b981';
                verdictDesc.textContent = 'No coercive patterns detected. Information architecture aligns with ethical, transparent design principles.';
            }

            patternBars.innerHTML = '';
            taxonomies.forEach(tax => {
                const prob = scores[tax.key];
                const pct = (prob * 100).toFixed(1);
                const item = document.createElement('div');
                item.className = 'pattern-item';
                item.innerHTML = `
                    <div class="pattern-top">
                        <span>${tax.name}</span>
                        <span style="font-family: 'JetBrains Mono', monospace; color: ${prob > 0.5 ? tax.color : 'var(--text-muted)'}; font-weight: 700;">${pct}%</span>
                    </div>
                    <div class="bar-wrap">
                        <div class="bar-fill" style="width: ${pct}%; background: ${tax.color};"></div>
                    </div>
                `;
                patternBars.appendChild(item);
            });
        }

        presetSelect.addEventListener('change', () => {
            const val = presetSelect.value;
            if (val !== 'custom' && presets[val]) {
                copyInput.value = presets[val];
                renderResults();
            }
        });

        copyInput.addEventListener('input', () => {
            renderResults();
        });

        btnAnalyze.addEventListener('click', renderResults);

        // Initial setup
        copyInput.value = presets.urgency;
        renderResults();
    </script>
</body>
</html>