-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
638 lines (552 loc) · 16.6 KB
/
Copy pathindex.html
File metadata and controls
638 lines (552 loc) · 16.6 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="LinkZero: the safest link shortener on the web. No tracking, no accounts, no agenda.">
<meta name="keywords" content="link shortener, url shortener, privacy, no tracking, free">
<meta name="theme-color" content="#00e5a0">
<meta property="og:type" content="website">
<meta property="og:url" content="https://lk0.org/">
<meta property="og:title" content="LinkZero">
<meta property="og:description" content="The safest link shortener on the web. No tracking, no accounts, no agenda.">
<meta property="og:image" content="https://lk0.org/icon.png">
<meta name="twitter:image" content="https://lk0.org/icon.png">
<meta name="twitter:card" content="summary_large_image">
<title>The Safest Link Shortener on the Web | LinkZero</title>
<link rel="icon" href="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='32'%20height='32'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%2300e5a0'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M10%2013a5%205%200%200%200%207.54.54l3-3a5%205%200%200%200-7.07-7.07l-1.72%201.71'/%3E%3Cpath%20d='M14%2011a5%205%200%200%200-7.54-.54l-3%203a5%205%200%200%200%207.07%207.07l1.71-1.71'/%3E%3C/svg%3E" type="image/svg+xml">
<link rel="canonical" href="https://lk0.org/">
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "WebSite",
"name": "LinkZero",
"url": "https://lk0.org/"
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Organization",
"name": "LinkZero",
"url": "https://lk0.org/",
"description": "The safest link shortener on the web. No tracking, no accounts, no agenda."
}
</script>
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit" defer></script>
<style>
*, *::before, *::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
:root {
--bg: #0d0f0e;
--surface: #141714;
--border: #222623;
--border-focus: #00e5a0;
--text: #e8ede9;
--text-muted: #6b7a6d;
--accent: #00e5a0;
--accent-dim: #00b37d;
--error: #ff6b6b;
--font-mono: monospace;
--font-sans: sans-serif;
--radius: 6px;
--max-width: 640px;
}
html {
font-size: 16px;
}
body {
background: var( --bg );
color: var( --text );
font-family: var( --font-sans );
min-height: 100vh;
display: flex;
flex-direction: column;
}
a {
color: var( --accent );
text-decoration: none;
}
a:hover, a:focus {
text-decoration: underline;
}
.skip-link {
position: absolute;
top: -100%;
left: 0;
background: var( --accent );
color: var( --bg );
padding: 8px 16px;
font-family: var( --font-mono );
font-size: 13px;
z-index: 100;
}
.skip-link:focus {
top: 0;
}
#header {
width: 100%;
max-width: var( --max-width );
padding: 5% 24px 0;
margin: 0 auto;
}
#logo {
font-family: var( --font-mono );
font-size: 20px;
font-weight: 600;
color: var( --text );
letter-spacing: -0.5px;
}
#logo a {
color: #fff;
}
#logo span {
color: var( --accent );
}
#content {
flex: 1;
max-width: var( --max-width );
margin: 0 auto;
width: 100%;
padding: 48px 24px 64px;
}
.tagline {
font-family: var( --font-mono );
font-size: 12px;
color: var( --text-muted );
text-transform: uppercase;
letter-spacing: 2px;
margin-bottom: 32px;
}
.form-wrap {
background: var( --surface );
border: 1px solid var( --border );
border-radius: var( --radius );
padding: 24px;
}
.input-row {
display: flex;
flex-direction: column;
gap: 8px;
}
.btn-row {
display: flex;
gap: 8px;
}
#url-input {
flex: 1;
background: var( --bg );
border: 1px solid var( --border );
border-radius: var( --radius );
color: var( --text );
font-family: var( --font-mono );
font-size: 14px;
padding: 12px 14px;
outline: none;
transition: border-color 0.15s;
min-width: 0;
}
#url-input::placeholder {
color: var( --text-muted );
}
#url-input:focus {
border-color: var( --border-focus );
}
.action-btn {
flex: 1;
background: var( --accent );
border: none;
border-radius: var( --radius );
color: var( --bg );
cursor: pointer;
font-family: var( --font-mono );
font-size: 13px;
font-weight: 600;
padding: 12px 20px;
margin-top: 8px;
white-space: nowrap;
transition: background 0.15s, opacity 0.15s;
letter-spacing: 0.3px;
}
.action-btn:hover, .action-btn:focus {
background: var( --accent-dim );
}
.action-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
#turnstile-container {
text-align: center;
margin-top: 8px;
}
#status {
margin-top: 24px;
font-family: var( --font-mono );
font-size: 13px;
display: none;
}
#status.error {
color: var( --error );
}
.result-row {
display: flex;
align-items: center;
gap: 10px;
background: var( --bg );
border: 1px solid var( --border );
border-radius: var( --radius );
padding: 10px 14px;
}
.result-url {
flex: 1;
color: var( --accent );
font-size: 15px;
font-weight: 500;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.copy-btn {
background: none;
border: 1px solid var( --border );
border-radius: var( --radius );
color: var( --text-muted );
cursor: pointer;
font-family: var( --font-mono );
font-size: 11px;
padding: 5px 10px;
transition: border-color 0.15s, color 0.15s;
white-space: nowrap;
letter-spacing: 0.5px;
}
.copy-btn:hover, .copy-btn:focus {
border-color: var( --accent );
color: var( --accent );
}
.copy-btn.copied {
border-color: var( --accent );
color: var( --accent );
}
#footer {
max-width: var( --max-width );
margin: 0 auto;
width: 100%;
padding: 0 24px 48px;
}
.faq-header {
font-family: var( --font-mono );
font-size: 16px;
text-transform: uppercase;
letter-spacing: 2px;
color: var( --text-muted );
margin: 20px 0;
padding-top: 20px;
border-top: 1px solid var( --border );
}
details {
border-bottom: 1px solid var( --border );
}
summary {
cursor: pointer;
list-style: none;
padding: 16px 0;
font-family: var( --font-mono );
font-size: 14px;
font-weight: 500;
color: var( --text );
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
user-select: none;
}
summary::-webkit-details-marker {
display: none;
}
summary::after {
content: '+';
color: var( --text-muted );
font-size: 18px;
font-weight: 400;
flex-shrink: 0;
transition: transform 0.15s;
}
details[open] summary::after {
transform: rotate( 45deg );
}
.faq-body {
padding-bottom: 16px;
font-size: 15px;
line-height: 1.7;
color: var( --text-muted );
}
.faq-body p + p {
margin-top: 10px;
}
.footer {
font-family: var( --font-mono );
font-size: 12px;
color: var( --text-muted );
text-align: center;
padding: 15% 10% 10%;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip: rect( 0, 0, 0, 0 );
white-space: nowrap;
}
@media ( max-width: 480px ) {
.btn-row {
flex-direction: column;
}
}
</style>
</head>
<body>
<a href="#content" class="skip-link">Skip to content</a>
<header id="header">
<h1 id="logo"><a href="./" title="LinkZero">Link<span>Zero</span></a></h1>
</header>
<main id="content">
<p class="tagline">No tracking · No accounts · No agenda</p>
<div class="form-wrap">
<div class="input-row">
<label for="url-input" class="sr-only">URL to shorten or unshorten</label>
<input type="url" id="url-input" placeholder="https://example.com/some/long/url" autocomplete="off" spellcheck="false">
</div>
<div class="btn-row">
<button type="button" id="shorten-btn" class="action-btn">Shorten</button>
<button type="button" id="unshorten-btn" class="action-btn">Unshorten</button>
</div>
<div id="turnstile-container"></div>
<div id="status" role="status" aria-live="polite"></div>
</div>
</main>
<footer id="footer">
<h2 class="faq-header">FAQ</h2>
<details>
<summary>Are shortened links safe?</summary>
<div class="faq-body">
<p>No. You should avoid ever clicking on a shortened link (especially from an unknown source) because you can't see where it actually goes. If you receive one, you should unshorten it to inspect it first.</p>
<p>That said, if using a link shortener is unavoidable, you can at least use one that isn't working against you. LinkZero is the safest option available and it collects no data about you or the people who click your links, it has no ad network, no resale business, and no incentive to do anything other than forward one URL to another.</p>
</div>
</details>
<details>
<summary>Can I shorten any URL?</summary>
<div class="faq-body">
<p>Almost. URLs that use dangerous patterns or known malware, phishing, and scam domains are blocked. Legitimate URLs should pass without issue.</p>
</div>
</details>
<details>
<summary>Can I unshorten a link?</summary>
<div class="faq-body">
<p>Yes. Paste any shortened link and click Unshorten to reveal the final destination without your browser ever visiting it. The lookup is performed by our server, so your IP address is never exposed to the destination or any trackers embedded in the redirect chain.</p>
</div>
</details>
<details>
<summary>Do links expire?</summary>
<div class="faq-body">
<p>No. Links are permanent. Since nothing is tracked, there's no activity data to expire them on, and no reason to delete them.</p>
</div>
</details>
<details>
<summary>Can I choose a custom short code?</summary>
<div class="faq-body">
<p>No. Codes are randomly generated. Custom aliases create moderation burden, and random codes are more resistant to enumeration.</p>
</div>
</details>
<details>
<summary>What data do you collect?</summary>
<div class="faq-body">
<p>None. Only the mapping between a short URL and its destination are stored. That's it. No IP addresses, no click counts, no timestamps, no referrers, no cookies, no analytics. When you shorten a link, we don't know who you are. When someone clicks it, we don't know who they are either.</p>
</div>
</details>
<details>
<summary>Can I report a malicious link?</summary>
<div class="faq-body">
<p>Yes. <a href="mailto:abuse@lk0.org">Email us</a> with the short URL and why you believe it's malicious. If warranted, it'll be removed.</p>
</div>
</details>
<details>
<summary>Why should I trust you?</summary>
<div class="faq-body">
<p>You shouldn't. You shouldn't trust anything or anyone blindly. The code is public on <a href="https://github.com/0projects/linkzero" target="_blank" rel="noopener noreferrer">GitHub</a>, so you can verify exactly what it does and doesn't do, but that still means you have to trust the server. You can always self-host if you'd rather remove trust from the equation altogether.</p>
<p>With that out of the way, I can tell you the reason I created this tool is the same reason I often build my own solution, because nothing elegant nor privacy-friendly enough existed yet. I build tools I need to use myself.</p>
</div>
</details>
<p class="footer"><a href="https://github.com/0projects/linkzero" target="_blank">LinkZero (LK0.org)</a> · <a href="mailto:abuse@lk0.org">Report a Link</a></p>
</footer>
<script>
const SITE_KEY = '0x4AAAAAADEyoMk060CmD-2t';
const input = document.getElementById( 'url-input' );
const btn = document.getElementById( 'shorten-btn' );
const unshortenBtn = document.getElementById( 'unshorten-btn' );
const status = document.getElementById( 'status' );
let widgetId = null;
let widgetContainer = null;
let pendingAction = null;
let cachedToken = null;
function renderTurnstile() {
if ( typeof turnstile === 'undefined' ) return;
widgetContainer = document.getElementById( 'turnstile-container' );
widgetId = turnstile.render( widgetContainer, {
sitekey: SITE_KEY,
theme: 'dark',
execution: 'execute',
// appearance: 'execute',
appearance: 'interaction-only',
callback: onTurnstileSuccess,
'error-callback': onTurnstileError,
'expired-callback': onTurnstileExpired
} );
}
function onTurnstileSuccess( token ) {
if ( pendingAction === 'unshorten' ) {
submitUnshorten( token );
pendingAction = null;
} else if ( pendingAction === 'shorten' ) {
submitUrl( token );
pendingAction = null;
} else {
cachedToken = token;
}
}
function onTurnstileError() {
setError( 'Verification failed. Please try again.' );
btn.disabled = false;
unshortenBtn.disabled = false;
}
function onTurnstileExpired() {
cachedToken = null;
if ( widgetId !== null ) turnstile.reset( widgetId );
}
function setError( msg ) {
status.className = 'error';
status.textContent = msg;
status.style.display = 'block';
}
function showResult( shortUrl ) {
status.className = '';
status.style.display = 'block';
const row = document.createElement( 'div' );
row.className = 'result-row';
const link = document.createElement( 'a' );
link.className = 'result-url';
link.href = shortUrl;
link.target = '_blank';
link.rel = 'noopener noreferrer';
link.textContent = shortUrl;
const copy = document.createElement( 'button' );
copy.type = 'button';
copy.className = 'copy-btn';
copy.textContent = 'COPY';
copy.addEventListener( 'click', () => {
navigator.clipboard.writeText( shortUrl ).then( () => {
copy.textContent = 'COPIED';
copy.classList.add( 'copied' );
setTimeout( () => {
copy.textContent = 'COPY';
copy.classList.remove( 'copied' );
}, 2000 );
} );
} );
row.appendChild( link );
row.appendChild( copy );
status.appendChild( row );
}
async function submitUrl( token ) {
try {
const res = await fetch( '/api/shorten', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify( { url: input.value.trim(), turnstileToken: token } )
} );
const data = await res.json();
btn.disabled = false;
if ( data.error ) {
setError( data.error );
} else {
showResult( 'https://lk0.org/' + data.slug );
input.value = '';
}
} catch( e ) {
setError( 'Something went wrong. Please try again.' );
btn.disabled = false;
}
if ( widgetId !== null ) {
turnstile.reset( widgetId );
}
}
async function submitUnshorten( token ) {
try {
const res = await fetch( '/api/unshorten', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify( { url: input.value.trim(), turnstileToken: token } )
} );
const data = await res.json();
if ( data.error ) {
setError( data.error );
} else {
showResult( data.url );
}
} catch( e ) {
setError( 'Something went wrong. Please try again.' );
}
unshortenBtn.disabled = false;
if ( widgetId !== null ) {
turnstile.reset( widgetId );
}
}
function executeWithToken( action, disabledBtn ) {
const url = input.value.trim();
if ( !url ) {
setError( 'Please enter a URL.' );
return;
}
status.className = '';
status.textContent = '';
status.style.display = 'none';
disabledBtn.disabled = true;
if ( typeof turnstile === 'undefined' || widgetId === null ) {
setError( 'Verification unavailable. Please reload and try again.' );
disabledBtn.disabled = false;
return;
}
if ( cachedToken ) {
const token = cachedToken;
cachedToken = null;
if ( action === 'unshorten' ) {
submitUnshorten( token );
} else {
submitUrl( token );
}
} else {
pendingAction = action;
turnstile.execute( widgetContainer );
}
}
unshortenBtn.addEventListener( 'click', () => executeWithToken( 'unshorten', unshortenBtn ) );
btn.addEventListener( 'click', () => executeWithToken( 'shorten', btn ) );
input.addEventListener( 'keydown', ( e ) => {
if ( e.key === 'Enter' ) btn.click();
} );
window.addEventListener( 'load', () => {
if ( typeof turnstile !== 'undefined' ) {
renderTurnstile();
} else {
document.querySelector( 'script[src*="turnstile"]' ).addEventListener( 'load', renderTurnstile );
}
if ( window.location.search.includes( '404=1' ) ) {
setError( 'That short link does not exist.' );
}
} );
</script>
</body>
</html>