-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.html
More file actions
1743 lines (1671 loc) · 83.4 KB
/
Copy pathindex.html
File metadata and controls
1743 lines (1671 loc) · 83.4 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
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
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Cross-Origin-Opener-Policy" content="same-origin" />
<meta http-equiv="Cross-Origin-Embedder-Policy" content="credentialless" />
<title>Video Downloader for Bluesky</title>
<meta property="og:title" content="Video Downloader for Bluesky" />
<meta name="twitter:title" content="Video Downloader for Bluesky" />
<meta name="description" content="Download (and convert!) Bluesky videos with ease!" />
<meta property="og:description" content="Download (and convert!) Bluesky videos with ease!" />
<meta name="twitter:description" content="Download (and convert!) Bluesky videos with ease!" />
<link rel="canonical" href="https://down.blue/" />
<meta property="og:url" content="https://down.blue/" />
<meta property="og:type" content="website" />
<meta property="og:image" content="https://down.blue/og.png" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="og:image:alt" content="down.blue — a Bluesky (and Atmosphere) video downloader" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="https://down.blue/og.png" />
<link rel="stylesheet" href="assets/tailwind-4.3.3.css" />
<style>
/* down.blue components, built on the joseli.to design system tokens that
scripts/tailwind-input.css compiles into the stylesheet above. Nothing
here invents a value: every colour, rule, gap and font is a token. */
/* CM Sans has a smaller x-height than a system ui font, so the 15px step
reads smaller than it did on system-ui. The design system's rule is to
take the 17px step for running copy; only the size moves, the leading
stays where the --type-body shorthand put it. */
body { font-size: var(--text-title-sm); }
/* The wordmark: the name in Computer Modern, the suffix carried by the
project ink. The ink fills a block behind `.blue` rather than colouring
the letters — the same treatment every other ink surface gets, and the
only one that clears WCAG on both papers.
It runs past the top of the type scale (52px) on purpose: this is a
one-page tool and the masthead is the only display type it has. */
.db-wordmark {
margin: var(--space-10) 0 var(--space-6);
font: var(--weight-normal) clamp(var(--text-display-1), 13vw, 116px)/1.1 var(--font-display);
letter-spacing: var(--tracking-display);
color: var(--text-1);
text-align: center;
}
/* inline-block so the block is sized by line-height rather than by Computer
Modern's very tall ascent/descent, which would float it off the letters. */
.db-wordmark-suffix {
display: inline-block;
line-height: 0.92;
padding: 0.06em 0.07em 0.1em;
background: var(--project-ink);
color: var(--project-ink-contrast);
}
/* Meta lines, tags and labels: typewriter, uppercase, tracked out. */
.db-meta { font: var(--type-meta); text-transform: uppercase; letter-spacing: var(--tracking-meta); color: var(--text-3); }
.db-micro { font: var(--type-label); text-transform: uppercase; letter-spacing: var(--tracking-meta); }
/* Running machine output and fine print: typewriter, but readable. */
.db-note { font: var(--type-code); color: var(--text-3); }
/* One rule decides the face, everywhere: anything set in CAPS is typewriter,
anything read as a sentence is the reader's own UI font, and Computer
Modern serif is reserved for the wordmark. So every box title — panel
head, callout spine — is the same object, and no box invents its own. */
.db-panel { border: var(--border); background: var(--surface-card); box-shadow: var(--shadow-2); }
.db-panel-head {
display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
margin: 0; padding: var(--box-head-pad); border-bottom: var(--border);
background: var(--project-ink); color: var(--project-ink-contrast);
font: var(--weight-bold) var(--text-caption)/1.4 var(--font-mono);
letter-spacing: var(--tracking-meta); text-transform: uppercase;
}
/* Buttons carry only their type and colour. The movement — lift toward the
light on hover, slam flat into the shadow on press — comes from the design
system's .neo-press, which the markup adds, so the offsets are never
computed here. Colour no longer changes on hover: the block moves instead.
Links still invert, and base.css exempts anything with a `neo` class from
that rule, which is why these do not need to opt out by hand. */
.db-btn {
display: inline-flex; align-items: center; justify-content: center; gap: var(--space-3);
border: var(--border); background: var(--surface-page); color: var(--text-1);
box-shadow: var(--shadow-2);
font: var(--weight-semibold) var(--text-body-sm)/1.25 var(--font-body);
padding: 9px 12px; cursor: pointer; text-align: center; text-decoration: none;
}
a.db-btn, a.db-btn:visited, a.db-btn:hover { color: var(--text-1); text-decoration: none; }
.db-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.db-btn-primary, a.db-btn-primary, a.db-btn-primary:visited, a.db-btn-primary:hover {
background: var(--project-ink); border-color: var(--project-ink); color: var(--project-ink-contrast);
}
.db-btn-danger { background: var(--ink-red); border-color: var(--ink-red); color: var(--on-red); }
.db-btn-sm { padding: 4px 7px; font-size: var(--text-meta); box-shadow: var(--shadow-1); }
/* Picking a format is a step, not a toolbar, so it gets its own rule and
title. None of the three is filled: a filled button here reads as "already
chosen" and is exactly why the step was easy to walk past.
The margin above separates the step from the one before it; the padding
below the rule only has to clear the legend, which the browser hangs on
the border line. */
.db-choice { border: 0; margin: var(--space-7) 0 0; padding: var(--space-5) 0 0; border-top: var(--border); }
/* The legend sits in the gap it punches in the fieldset's top border, which
turns the rule into a labelled one. That is the native behaviour and the
right look here, so the padding makes the gap deliberate. */
.db-choice-title {
padding: 0 var(--space-5) 0 0; margin: 0;
font: var(--weight-bold) var(--text-caption)/1.4 var(--font-mono);
text-transform: uppercase; letter-spacing: var(--tracking-meta); color: var(--text-1);
}
.db-btn-mode {
flex-direction: column; align-items: flex-start; gap: var(--space-2);
padding: var(--space-5); text-align: left; width: 100%;
}
.db-mode-label { font: var(--weight-semibold) var(--text-body)/1.25 var(--font-body); }
.db-input {
width: 100%; border: var(--border); background: var(--surface-page); color: var(--text-1);
box-shadow: var(--shadow-1); font: var(--type-body); padding: 8px 10px;
}
.db-input::placeholder { color: var(--text-3); }
/* 0–50% download, 50–100% conversion. 80ms so it steps rather than glides. */
.db-progress { border: var(--border); height: 18px; background: var(--surface-page); }
.db-progress-fill { height: 100%; background: var(--project-ink); transition: width var(--motion-fast) var(--easing); }
.db-status { font: var(--type-code); color: var(--text-2); }
.db-status-error { color: var(--status-error); font-weight: var(--weight-bold); }
/* The spine carries a mark instead of a word here: the note is an aside, and
a vertical "DID YOU KNOW?" shouted as loudly as a panel title read like
one. The block is still the same ink block; only its content changed.
Body is one step down from --type-body — face follows role, size follows
hierarchy, and this text ranks below the tool itself. */
.db-callout { border: var(--border); box-shadow: var(--shadow-2); display: grid; grid-template-columns: max-content 1fr; }
.db-callout-spine {
display: grid; place-items: center; width: 34px;
background: var(--project-ink); color: var(--project-ink-contrast);
}
.db-callout-body { padding: var(--space-5) var(--space-6); font: var(--type-dek); color: var(--text-2); }
/* Imagery is screened like newsprint. Posts with no thumbnail get an empty
dot field, inked with one of the sixteen, picked from the post id.
The post's choice arrives as --halftone-ink (inline, from Vue) and only
feeds --halftone-dot on paper: in the dark theme every dot collapses to
amber, because that theme is monochrome and sixteen hues would wreck it.
The indirection is what lets a plain rule beat an inline style. */
.db-halftone {
--halftone-dot: var(--halftone-ink, var(--ink-graphite));
/* Paints its own paper: the tile behind it is filled with the project ink
for the duotone, and ink dots on ink would be invisible. */
background-color: var(--surface-page);
background-image: radial-gradient(var(--halftone-dot) var(--halftone-dot-size), transparent 0);
background-size: 7px 7px;
}
:root[data-theme="dark"] .db-halftone { --halftone-dot: var(--ink-amber); }
/* A real thumbnail is screened the way the system screens photographs:
grayscale, contrast pushed, multiplied onto the ink. Highlights come back
as the ink, shadows go to black — a two-colour duotone, amber in the dark
theme for free. `isolation` keeps the blend inside the tile instead of
letting it reach the page. Hover restores the full-colour frame, because
a history row still has to be recognisable. The whole card is the target,
not just the image: focus-within also covers reaching the row by keyboard. */
.db-thumb-btn { background: var(--project-ink); isolation: isolate; }
/* Ink on paper, not paper on ink: highlights have to come back as the paper
and shadows as the ink, or a mostly-white frame turns into a dark slab and
stops matching the empty placeholder beside it. That means the operator
follows the paper, same as the dot screen below.
Sized here, not with utilities: the design system's unlayered
`img { height: auto }` beats Tailwind's layered h-full. */
.db-thumb {
width: 100%; height: 100%; max-width: none; object-fit: cover; object-position: center;
filter: grayscale(1) contrast(1.35); mix-blend-mode: screen;
}
:root[data-theme="dark"] .db-thumb { mix-blend-mode: multiply; }
/* Then the paper punches back through on the same 7px pitch as the empty
placeholder, so a screened frame and a missing one read as one family.
The operator has to follow the paper: white paper lightens through
`screen`, black paper darkens through `multiply`. Using either alone
would make the dots vanish in the other theme. */
.db-thumb-btn:has(.db-thumb)::after {
content: ""; position: absolute; inset: 0; pointer-events: none;
background-image: radial-gradient(var(--surface-page) var(--halftone-dot-size), transparent 0);
background-size: 7px 7px;
mix-blend-mode: screen;
}
:root[data-theme="dark"] .db-thumb-btn:has(.db-thumb)::after { mix-blend-mode: multiply; }
/* The card sits inside a panel that already casts, and two nested blocks
must never both cast — so it rests flat and earns its shadow only while
you are on it. .neo-lift supplies the travel; neo-sm keeps the hover step
at 5px rather than jumping to 8px, which on a tile this size reads as a
pop rather than a lift. The thumbnail button inside casts nothing, ever. */
.db-card { box-shadow: none; }
.db-card:hover .db-thumb, .db-card:focus-within .db-thumb {
filter: none; mix-blend-mode: normal;
}
.db-card:hover .db-thumb-btn::after, .db-card:focus-within .db-thumb-btn::after { opacity: 0; }
.db-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
/* Third-party marks keep their own colour; the system only squares them off. */
.db-chip {
display: inline-block; border: var(--border); padding: 5px 9px;
font: var(--type-label); text-transform: uppercase; letter-spacing: var(--tracking-meta); text-decoration: none;
box-shadow: var(--shadow-1);
}
.db-chip-pix, a.db-chip-pix:visited { background: #77B6A8; color: #000; }
/* APOIA.se sets its mark in white, but white on their orange is 3.7:1 —
below AA at this size. Black on the same orange is 5.6:1. */
.db-chip-apoiase, a.db-chip-apoiase:visited { background: #EC4B3C; color: #000; }
.db-chip-coffee, a.db-chip-coffee:visited { background: #FFDD00; color: #000; }
.db-chip-sponsors, a.db-chip-sponsors:visited { background: #EA4AAA; color: #000; }
</style>
<script>
// Dark mode is opt-in and manual — never prefers-color-scheme. Applied here,
// before first paint, so the amber theme does not flash white on load.
if (localStorage.getItem("theme") === "dark") document.documentElement.dataset.theme = "dark";
</script>
<script src="lib/ffmpeg-0.12.7.min.js"></script>
<script src="lib/mux-7.0.3.min.js"></script>
<script src="lib/vue-3.5.34.min.js"></script>
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect x='14' y='14' width='86' height='86' fill='%23000'/%3E%3Crect width='86' height='86' fill='%23000'/%3E%3Crect x='6' y='6' width='74' height='74' fill='%23018281'/%3E%3Cpath d='M43 19v28M28 36l15 15 15-15M25 67h36' fill='none' stroke='%23fff' stroke-width='7' stroke-linecap='square'/%3E%3C/svg%3E" />
<link rel="apple-touch-icon" href="apple-touch-icon.png" />
</head>
<body>
<div id="app">
<div class="mx-auto max-w-[880px] px-6 pb-16">
<div class="flex flex-wrap items-center justify-end gap-2 pt-4">
<button @click="toggleLang" :lang="lang === 'pt' ? 'en' : 'pt-BR'" class="db-btn db-btn-sm neo-press neo-sm">{{ lang === 'pt' ? 'english' : 'português' }}</button>
<button @click="toggleTheme" class="db-btn db-btn-sm neo-press neo-sm">
<svg v-if="theme === 'dark'" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<circle cx="12" cy="12" r="4" />
<path d="M12 2v2" /><path d="M12 20v2" /><path d="m4.93 4.93 1.41 1.41" /><path d="m17.66 17.66 1.41 1.41" />
<path d="M2 12h2" /><path d="M20 12h2" /><path d="m6.34 17.66-1.41 1.41" /><path d="m19.07 4.93-1.41 1.41" />
</svg>
<svg v-else width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401" />
</svg>
<span>{{ theme === 'dark' ? t.themeLight : t.themeDark }}</span>
</button>
</div>
<main>
<h1 class="db-wordmark">down<span class="db-wordmark-suffix">.blue</span></h1>
<section class="db-panel mt-15 mb-6">
<h2 class="db-panel-head">
<span>{{ t.panelTitle }}</span>
</h2>
<div class="p-4">
<p class="mb-5" @click="toggleNetwork"><strong>{{ heroStrong }}</strong> {{ heroRest }}</p>
<form @submit.prevent="findVideo" class="flex flex-wrap gap-2">
<input ref="postUrlInput" v-model="postUrl" type="text" inputmode="url" autocomplete="off" class="db-input min-w-0 flex-1"
:aria-label="t.urlLabel" :placeholder="t.placeholder" required />
<button v-if="postUrl" type="button" @click="clearPostUrl" :disabled="loadingMode !== null"
class="db-btn shrink-0 px-3 neo-press" :aria-label="t.clearBtn" :title="t.clearBtn">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M18 6 6 18" /><path d="m6 6 12 12" />
</svg>
</button>
<button type="submit" :disabled="loadingMode !== null" class="db-btn db-btn-primary shrink-0 px-3 neo-press"
:aria-label="t.findBtn" :title="t.findBtn">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M12 15V3" /><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /><path d="m7 10 5 5 5-5" />
</svg>
</button>
</form>
<p class="db-note mt-4">{{ t.privacy }}</p>
<!-- Bluesky native video: the same video in three formats. fieldset so
the grouping reaches assistive tech, not just the eye. -->
<fieldset v-if="videoSource && videoSource.kind === 'bluesky-video'" class="db-choice">
<legend class="db-choice-title">{{ t.pickMode }}</legend>
<p class="db-note mb-4">{{ t.pickModeHint }}</p>
<div class="grid gap-2 sm:grid-cols-3">
<button @click="downloadOriginalRaw" :disabled="loadingMode !== null" class="db-btn db-btn-mode neo-press">
<span class="db-mode-label">{{ t.btnRaw }}</span>
<span class="db-micro">{{ t.btnRawSub }}</span>
</button>
<button @click="downloadOriginalAsMp4" :disabled="loadingMode !== null" class="db-btn db-btn-mode neo-press">
<span class="db-mode-label">{{ t.btnFullMp4 }}</span>
<span class="db-micro">{{ t.btnFullMp4Sub }}</span>
</button>
<button @click="download720pMp4" :disabled="loadingMode !== null" class="db-btn db-btn-mode neo-press">
<span class="db-mode-label">{{ t.btn720 }}</span>
<span class="db-micro">{{ t.btn720Sub }}</span>
</button>
</div>
</fieldset>
<!-- GIF: download options -->
<div v-if="videoSource && videoSource.kind === 'gif'" class="mt-4">
<div v-if="videoSource.mp4Url" class="grid gap-2 sm:grid-cols-2">
<button @click="downloadGif(true)" :disabled="loadingMode !== null" class="db-btn db-btn-primary neo-press">
{{ t.btnGifMp4 }}
</button>
<button @click="downloadGif()" :disabled="loadingMode !== null" class="db-btn neo-press">
{{ t.btnGif }}
</button>
</div>
<button v-else @click="downloadGif()" :disabled="loadingMode !== null" class="db-btn db-btn-primary w-full neo-press">
{{ t.btnGif }}
</button>
</div>
<!-- Feedback follows the action that causes it. While the post is
being fetched neither action block is rendered, so this still
lands directly under the form. -->
<div v-if="progressBarVisible" class="db-progress mt-6" role="progressbar" :aria-valuenow="Math.round(progress)"
aria-valuemin="0" aria-valuemax="100" :aria-label="t.progressLabel">
<div class="db-progress-fill" :style="{ width: progress + '%' }"></div>
</div>
<!-- The live region stays mounted: one created together with its text is
often not announced. Only the message inside it comes and goes. -->
<div role="status" aria-live="polite">
<p v-if="status" class="db-status mt-4" :class="{ 'db-status-error': statusIsError }">
<span v-if="statusIsError" aria-hidden="true">✕ </span>{{ status }}
</p>
</div>
<a v-if="downloadReady && downloadLink && downloadName" :href="downloadLink" :download="downloadName"
class="db-btn mt-4 w-full neo-press">{{ t.saveFile }} ({{ downloadName }})</a>
<!-- Subtitle download (after HLS path) -->
<a v-if="subtitleUrl" :href="subtitleUrl" class="db-btn mt-2 w-full neo-press"
:download="`${subtitleLang}.vtt`">{{ t.subtitlesPrefix }} ({{ subtitleLang }}.vtt)</a>
<!-- Video Preview -->
<div class="mt-4" v-if="videoPreviewVisible">
<video :key="downloadLink" :poster="videoPoster" controls class="mx-auto block w-full max-w-lg border border-strong bg-[#000]"
preload="metadata">
<source :src="downloadLink" type="video/mp4" />
<track :label="subtitleLang" kind="subtitles" v-if="subtitleUrl" :srclang="subtitleLang" :src="subtitleUrl" default />
</video>
</div>
<!-- GIF Preview -->
<div class="mt-4" v-if="gifPreviewVisible">
<img :key="postCid" :src="downloadLink" :alt="t.gifAlt" class="mx-auto block w-full max-w-lg border border-strong" />
</div>
</div>
</section>
<!-- History -->
<section class="db-panel mb-6" v-if="urlHistory.length > 0">
<h2 class="db-panel-head">
<span>{{ t.historyTitle }}</span>
<span>{{ filteredHistory.length }}/{{ urlHistory.length }}</span>
</h2>
<div class="border-b border-hairline p-3">
<input v-model="historyQuery" type="search" :aria-label="t.searchHistory" :placeholder="t.searchHistory" class="db-input" />
</div>
<p v-if="filteredHistory.length === 0" class="db-meta p-9 text-center">{{ t.noResults }}</p>
<div class="grid grid-cols-1 gap-3 p-3 sm:grid-cols-2 lg:grid-cols-3">
<article v-for="(item, index) in paginatedHistory" :key="getHistoryItemUrl(item) || index"
class="db-card flex min-w-0 flex-col border border-strong neo-lift neo-sm">
<button @click="fillAndFind(item)" :title="t.reopen" :disabled="loadingMode !== null"
tabindex="-1" aria-hidden="true" class="db-thumb-btn relative block w-full overflow-hidden border-b border-strong"
style="aspect-ratio: 16 / 9;">
<img v-if="getThumbnailUrl(item)" :src="getThumbnailUrl(item)"
alt="" loading="lazy"
crossorigin="anonymous" referrerpolicy="no-referrer"
class="db-thumb absolute inset-0"
@error="handleThumbnailError(getHistoryItemData(item).postId)" />
<span v-else class="db-halftone absolute inset-0 block"
:style="thumbnailPlaceholderStyle(getHistoryItemData(item).postId)"></span>
</button>
<div class="flex min-w-0 flex-1 flex-col gap-2 p-2">
<p class="db-meta truncate text-text-1">@{{ getHistoryItemData(item).username }}</p>
<p v-if="getHistoryItemData(item).text" class="db-clamp-3 text-body-sm text-text-2">
{{ getHistoryItemData(item).text }}
</p>
<div class="mt-auto flex items-center justify-between gap-2 border-t border-hairline pt-2">
<a :href="normalizedHistoryUrl(item)" class="db-micro truncate" target="_blank" rel="noopener">{{ t.viewPost }}</a>
<div class="flex shrink-0 gap-1">
<button @click="fillAndFind(item)" :title="t.reopen" :aria-label="t.reopen" :disabled="loadingMode !== null" class="db-btn db-btn-sm neo-press neo-sm">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M12 15V3" /><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /><path d="m7 10 5 5 5-5" />
</svg>
</button>
<button @click="removeFromHistory(getHistoryItemUrl(item))" :title="t.removeHistory"
:aria-label="t.removeHistory" class="db-btn db-btn-sm db-btn-danger neo-press neo-sm">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M18 6 6 18" /><path d="m6 6 12 12" />
</svg>
</button>
</div>
</div>
</div>
</article>
</div>
<div v-if="hasMoreHistory" class="border-t border-hairline p-3 text-center">
<button @click="loadMoreHistory" class="db-btn neo-press">{{ t.showMore }}</button>
</div>
</section>
<aside class="db-callout mb-9">
<!-- lucide-static 0.542.0, info.svg. The label survives as aria-label. -->
<span class="db-callout-spine" role="img" :aria-label="t.didYouKnow" :title="t.didYouKnow">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<circle cx="12" cy="12" r="10" /><path d="M12 16v-4" /><path d="M12 8h.01" />
</svg>
</span>
<div class="db-callout-body">
{{ t.mentionPrefix }} <a href="https://bsky.app/profile/down.blue">@down.blue</a>
{{ t.mentionMiddle }} <a href="https://bsky.app/profile/down.blue/post/3l534dn26xp2j">{{ t.iosShortcut }}</a>.
</div>
</aside>
</main>
<footer class="pt-6">
<p class="db-meta mb-6 text-center">
{{ t.tagline }} ·
<a :href="t.bugFormUrl" target="_blank" rel="noopener">{{ t.foundBug }}</a> ·
{{ t.partOf }} <a href="https://notx.blue">notx.blue</a> {{ t.byAuthor }}
<a href="https://bsky.app/profile/joseli.to">@joseli.to</a> ·
<a href="https://github.com/breakzplatform/down.blue">{{ t.viewSource }}</a>
</p>
<p class="db-note mb-6 text-center">{{ t.fromBrazil }}</p>
<div class="mb-6 flex flex-wrap items-center justify-center gap-2">
<span class="db-micro mr-1 text-text-3">{{ t.support }}</span>
<a href="https://pix.joseli.to" target="_blank" rel="noopener" class="db-chip db-chip-pix neo-press neo-sm">Pix</a>
<a href="https://github.com/sponsors/breakzplatform" target="_blank" rel="noopener" class="db-chip db-chip-sponsors neo-press neo-sm">GitHub Sponsors</a>
<!-- Temporarily hidden support link
<a href="https://apoia.se/joselito" target="_blank" rel="noopener" class="db-chip db-chip-apoiase neo-press neo-sm">APOIA.se</a>
-->
<a href="https://buymeacoffee.com/joselito" target="_blank" rel="noopener" class="db-chip db-chip-coffee neo-press neo-sm">Buy me a Coffee</a>
</div>
<p class="db-note text-center">{{ t.respect }}</p>
</footer>
</div>
</div>
<script>
const { FFmpeg } = FFmpegWASM;
// Inlined from @ffmpeg/util — its UMD build is broken for <script> usage
// (factory body uses CommonJS require/exports). These two helpers are all we need.
async function fetchFile(input) {
let data;
if (typeof input === "string") {
data = await (await fetch(input)).arrayBuffer();
} else if (input instanceof File || input instanceof Blob) {
data = await input.arrayBuffer();
} else {
data = input;
}
return new Uint8Array(data);
}
const { createApp, markRaw } = Vue;
// The sixteen project inks of the joseli.to design system.
const INK_NAMES = [
"blue", "sky", "cyan", "teal", "green", "lime", "yellow", "amber",
"orange", "red", "pink", "magenta", "violet", "purple", "brown", "graphite",
];
const STRINGS = {
en: {
tagline: "Work in Progress. Expect bugs",
foundBug: "found one?",
bugFormUrl: "https://q.joseli.to/forms/notx-blue-bugs",
partOf: "part of",
byAuthor: "by",
viewSource: "View-source",
themeDark: "dark",
themeLight: "light",
panelTitle: "Download a video",
heroStrong: "Download Bluesky videos and GIFs directly in your browser!",
heroRest: "Enter a Bluesky post URL:",
placeholder: "https://bsky.app/profile/kaelltx.bsky.social/post/3l4aiybdeoo2q",
findBtn: "Download",
clearBtn: "Clear",
urlLabel: "Post URL",
progressLabel: "Download progress",
privacy: "Fast, secure, and private — no external services required. No data, logs or analytics collected.",
btnRaw: "Original (raw)",
btnRawSub: "as uploaded · no re-encode",
btnFullMp4: "Full quality MP4",
btnFullMp4Sub: "original re-encoded to MP4",
btn720: "720p MP4",
btn720Sub: "smaller · streaming quality",
btnGif: "Download GIF",
btnGifMp4: "Download MP4",
saveFile: "Save file",
subtitlesPrefix: "Download Subtitles",
gifAlt: "GIF Preview",
historyTitle: "Download History",
searchHistory: "Search history (handle, post id, text)...",
showMore: "Show more",
noResults: "No matching downloads",
viewPost: "View post →",
reopen: "Re-open",
removeHistory: "Remove from history",
didYouKnow: "Did you know?",
mentionPrefix: "You can mention",
mentionMiddle: "in a reply to a video post to get a download link instantly! You can also use the",
iosShortcut: "iOS Shortcut",
fromBrazil: "Directly from Brazil by Joselito, with much love and care. This site does not use any cookies or collect any data. This site is not related to Bluesky.",
support: "Support this project:",
respect: "Respect copyright and Bluesky's terms of service.",
statusValidating: "Validating post URL...",
statusLoading: "Loading post from Bluesky...",
statusAnalyzing: "Analyzing post content...",
statusResolvingPds: "Resolving author PDS...",
pickMode: "Choose how to download",
pickModeHint: "The same video in three formats. Picking one starts the download right away.",
statusDownloadingOriginal: "Downloading original blob...",
statusConverting: "Converting to MP4...",
statusLoadingFfmpeg: "Loading converter...",
statusDownloadingHls: "Downloading 720p video...",
statusDownloadingGif: "Downloading GIF...",
errInvalidUrl: "Please enter a valid Bluesky post URL",
errPostNotFound: "Post not found — it may have been deleted",
errAccessDenied: "Access denied — this post may be private",
errFetch: "Unable to fetch post from Bluesky",
errInvalidFormat: "Invalid Bluesky URL format",
errNetwork: "Network error — please check your connection",
errTimeout: "Request timed out — Bluesky may be slow to respond",
errProcessing: "Error processing post — please try again",
errYoutube: "YouTube videos are not supported",
errExternal: "External content not supported",
errOnlyBsky: "Only Bluesky native videos and GIFs are supported.",
errImagesPost: "This post contains images, not videos or GIFs.",
errQuotePost: "This is a quote post without video or GIF content.",
errQuoteUnavailable: "The quoted post is blocked, deleted or unavailable, so its video can't be reached.",
errTextPost: "This is a text post without video or GIF content.",
errNoVideo: "No video or GIF found in this post.",
errPdsResolve: "Could not resolve the author's PDS endpoint.",
errBlobFetch: "Could not download the original blob.",
errConvert: "Conversion failed.",
},
pt: {
tagline: "Em desenvolvimento. Bugs acontecem",
foundBug: "achou um?",
bugFormUrl: "https://q.joseli.to/forms/notx-blue-bugs-pt",
partOf: "parte do",
byAuthor: "por",
viewSource: "Ver código",
themeDark: "escuro",
themeLight: "claro",
panelTitle: "Baixar um vídeo",
heroStrong: "Baixe vídeos e GIFs do Bluesky direto no seu navegador!",
heroRest: "Cole a URL de um post do Bluesky:",
placeholder: "https://bsky.app/profile/kaelltx.bsky.social/post/3l4aiybdeoo2q",
findBtn: "Baixar",
clearBtn: "Limpar",
urlLabel: "URL do post",
progressLabel: "Progresso do download",
privacy: "Rápido, seguro e privado — não usa serviços externos. Nenhum dado, log ou analytics é coletado.",
btnRaw: "Original (raw)",
btnRawSub: "como foi enviado · sem reencode",
btnFullMp4: "MP4 qualidade total",
btnFullMp4Sub: "original reencodado em MP4",
btn720: "MP4 720p",
btn720Sub: "menor · qualidade de streaming",
btnGif: "Baixar GIF",
btnGifMp4: "Baixar MP4",
saveFile: "Salvar arquivo",
subtitlesPrefix: "Baixar legendas",
gifAlt: "Pré-visualização do GIF",
historyTitle: "Histórico de downloads",
searchHistory: "Buscar no histórico (handle, id do post, texto)...",
showMore: "Mostrar mais",
noResults: "Nenhum download encontrado",
viewPost: "Ver post →",
reopen: "Reabrir",
removeHistory: "Remover do histórico",
didYouKnow: "Você sabia?",
mentionPrefix: "Você pode mencionar",
mentionMiddle: "em uma resposta a um post de vídeo para receber o link de download na hora! Também dá pra usar o",
iosShortcut: "atalho do iOS",
fromBrazil: "Direto do Brasil pelo Joselito, com muito carinho. Este site não usa cookies nem coleta dados. Este site não tem relação com o Bluesky.",
support: "Apoie este projeto:",
respect: "Respeite direitos autorais e os termos de uso do Bluesky.",
statusValidating: "Validando URL do post...",
statusLoading: "Carregando post do Bluesky...",
statusAnalyzing: "Analisando o conteúdo do post...",
statusResolvingPds: "Resolvendo PDS do autor...",
pickMode: "Escolha como baixar",
pickModeHint: "O mesmo vídeo em três formatos. Ao escolher um, o download começa na hora.",
statusDownloadingOriginal: "Baixando blob original...",
statusConverting: "Convertendo para MP4...",
statusLoadingFfmpeg: "Carregando conversor...",
statusDownloadingHls: "Baixando vídeo 720p...",
statusDownloadingGif: "Baixando GIF...",
errInvalidUrl: "Cole uma URL válida de post do Bluesky",
errPostNotFound: "Post não encontrado — pode ter sido apagado",
errAccessDenied: "Acesso negado — este post pode ser privado",
errFetch: "Não foi possível buscar o post no Bluesky",
errInvalidFormat: "Formato de URL inválido",
errNetwork: "Erro de rede — confira sua conexão",
errTimeout: "Tempo esgotado — o Bluesky pode estar lento",
errProcessing: "Erro ao processar o post — tente de novo",
errYoutube: "Vídeos do YouTube não são suportados",
errExternal: "Conteúdo externo não suportado",
errOnlyBsky: "Apenas vídeos nativos e GIFs do Bluesky são suportados.",
errImagesPost: "Este post contém imagens, não vídeo ou GIF.",
errQuotePost: "Este é um post de citação sem vídeo ou GIF.",
errQuoteUnavailable: "O post citado está bloqueado, apagado ou indisponível, e o vídeo dele não pode ser acessado.",
errTextPost: "Este é um post de texto sem vídeo ou GIF.",
errNoVideo: "Nenhum vídeo ou GIF encontrado neste post.",
errPdsResolve: "Não consegui resolver o PDS do autor.",
errBlobFetch: "Não consegui baixar o blob original.",
errConvert: "Falha na conversão.",
},
};
// Dark mode is deliberately opt-in: the OS preference is never consulted.
function detectTheme() {
return localStorage.getItem("theme") === "dark" ? "dark" : "light";
}
// Easter egg: clicking the intro line swaps "Bluesky" for "Atmosphere".
function detectNetwork() {
try { return localStorage.getItem("network") === "Atmosphere" ? "Atmosphere" : "Bluesky"; }
catch { return "Bluesky"; }
}
function detectLang() {
const stored = localStorage.getItem("lang");
if (stored === "pt" || stored === "en") return stored;
const nav = (navigator.language || navigator.userLanguage || "en").toLowerCase();
return nav.startsWith("pt") ? "pt" : "en";
}
createApp({
data() {
return {
ffmpeg: null,
lang: detectLang(),
theme: detectTheme(),
network: detectNetwork(),
postUrl: "",
postCid: "",
status: "",
progress: 0,
progressBarVisible: false,
videoPreviewVisible: false,
gifPreviewVisible: false,
downloadLink: "",
downloadName: "",
downloadReady: false,
subtitleLang: "",
subtitleUrl: "",
urlHistory: [],
historyQuery: "",
historyPage: 1,
historyPageSize: 20,
historyMaxEntries: 5000,
currentPostData: null,
videoSource: null,
loadingMode: null,
pdsCache: {},
thumbnailErrors: {},
};
},
computed: {
t() { return STRINGS[this.lang]; },
heroStrong() { return this.withNetwork(this.t.heroStrong); },
heroRest() { return this.withNetwork(this.t.heroRest); },
// Errors and progress share one status line; the error strings are the
// only ones that need the error colour, so match against them directly.
statusIsError() {
if (!this.status) return false;
return Object.entries(this.t).some(([key, value]) => key.startsWith("err") && value === this.status);
},
filteredHistory() {
const q = this.historyQuery.trim().toLowerCase();
if (!q) return this.urlHistory;
return this.urlHistory.filter(item => {
const data = this.getHistoryItemData(item);
const haystack = `${data.username || ""} ${data.displayName || ""} ${data.postId || ""} ${data.text || ""} ${data.videoAlt || ""}`.toLowerCase();
return haystack.includes(q);
});
},
paginatedHistory() {
return this.filteredHistory.slice(0, this.historyPage * this.historyPageSize);
},
hasMoreHistory() {
return this.filteredHistory.length > this.paginatedHistory.length;
},
videoPoster() {
const source = this.videoSource;
if (source?.kind !== "bluesky-video" || !source.did || !source.cid) return null;
return videoThumbnailUrl(source.did, source.cid);
},
},
watch: {
historyQuery() { this.historyPage = 1; },
},
mounted() {
document.documentElement.lang = this.lang === "pt" ? "pt-BR" : "en";
document.documentElement.dataset.theme = this.theme;
this.loadHistory();
this.backfillHistoryThumbnails();
// markRaw: keep the FFmpeg instance out of Vue's reactive Proxy.
// The 0.12 class uses private fields (#x); a reactive Proxy wrapper
// breaks private member access ("Cannot read private member").
this.ffmpeg = markRaw(new FFmpeg());
this.ffmpeg.on("progress", ({ progress }) => {
const pct = Math.max(0, Math.min(1, Number(progress) || 0));
this.progress = 50 + Math.round(pct * 50);
});
const urlParams = new URLSearchParams(window.location.search);
const url = urlParams.get("url");
if (url) {
this.postUrl = url;
this.findVideo();
}
},
beforeUnmount() { this.cleanupBlobUrls(); },
methods: {
toggleLang() {
this.lang = this.lang === "pt" ? "en" : "pt";
localStorage.setItem("lang", this.lang);
document.documentElement.lang = this.lang === "pt" ? "pt-BR" : "en";
},
withNetwork(text) {
if (this.network === "Bluesky") return text;
// English needs "an" before the vowel; Portuguese "do" works for both.
return text.replaceAll("a Bluesky", "an Atmosphere").replaceAll("Bluesky", "Atmosphere");
},
toggleNetwork() {
this.network = this.network === "Bluesky" ? "Atmosphere" : "Bluesky";
try { localStorage.setItem("network", this.network); } catch {}
},
toggleTheme() {
this.theme = this.theme === "dark" ? "light" : "dark";
localStorage.setItem("theme", this.theme);
document.documentElement.dataset.theme = this.theme;
},
// ---- History ----
loadHistory() {
// Corrupt or unreadable storage must not abort startup; start empty instead.
let saved;
try { saved = JSON.parse(localStorage.getItem("urlHistory") || "[]"); }
catch { saved = []; }
if (!Array.isArray(saved)) saved = [];
const seen = new Set();
this.urlHistory = saved.slice(0, this.historyMaxEntries).flatMap(item => {
const raw = typeof item === "string" ? item : item && item.url;
let safe;
try { safe = this.extractProfileAndPost(raw).url; }
catch { return []; }
if (seen.has(safe)) return [];
seen.add(safe);
if (typeof item === "string") {
return [{ url: safe, timestamp: Date.now(), postData: this.extractPostDataFromUrl(safe) }];
}
return [{ ...item, url: safe }];
});
},
saveToHistory(url, postData = null) {
let safeUrl;
try { safeUrl = this.extractProfileAndPost(url).url; }
catch { return; }
const entry = { url: safeUrl, timestamp: Date.now(), postData: postData || this.extractPostDataFromUrl(safeUrl) };
const idx = this.urlHistory.findIndex(i => (typeof i === "string" ? i : i.url) === safeUrl);
if (idx !== -1) this.urlHistory.splice(idx, 1);
this.urlHistory.unshift(entry);
if (this.urlHistory.length > this.historyMaxEntries) this.urlHistory.length = this.historyMaxEntries;
try {
localStorage.setItem("urlHistory", JSON.stringify(this.urlHistory));
} catch (err) {
console.warn("localStorage full — trimming history", err);
while (this.urlHistory.length > 100) {
this.urlHistory.pop();
try {
localStorage.setItem("urlHistory", JSON.stringify(this.urlHistory));
break;
} catch {}
}
}
},
loadMoreHistory() {
this.historyPage += 1;
this.backfillHistoryThumbnails();
},
extractPostDataFromUrl(url) {
try {
const { profile, post } = this.extractProfileAndPost(url);
return { username: profile, displayName: profile, postId: post, avatar: null };
} catch {
return { username: "Unknown", displayName: "Unknown", postId: "Unknown", avatar: null };
}
},
removeFromHistory(url) {
this.urlHistory = this.urlHistory.filter(i => {
if (!i) return true;
return (typeof i === "string" ? i : i.url || "") !== url;
});
localStorage.setItem("urlHistory", JSON.stringify(this.urlHistory));
},
fillAndFind(historyItem) {
if (this.loadingMode !== null) return;
const raw = typeof historyItem === "string" ? historyItem : historyItem && historyItem.url;
let parsed;
try { parsed = this.extractProfileAndPost(raw); }
catch { return; }
this.postUrl = parsed.url;
this.findVideo();
},
getHistoryItemUrl(item) {
if (!item) return "";
return typeof item === "string" ? item : item.url || "";
},
getHistoryItemData(item) {
if (!item) return { username: "Unknown", displayName: "Unknown", postId: "Unknown", avatar: null };
if (typeof item === "string") return this.extractPostDataFromUrl(item);
if (item.postData) return item.postData;
if (item.url) return this.extractPostDataFromUrl(item.url);
return { username: "Unknown", displayName: "Unknown", postId: "Unknown", avatar: null };
},
// A post with no thumbnail gets an empty halftone field. The dot takes
// one of the sixteen inks, picked from the post id so the same post
// always screens the same colour. The dark theme ignores this and
// screens everything in amber — see .db-halftone.
thumbnailPlaceholderStyle(postId) {
if (!postId || typeof postId !== "string" || postId === "Unknown") {
return "--halftone-ink: var(--ink-graphite);";
}
let hash = 0;
for (let i = 0; i < postId.length; i++) {
hash = (((hash << 5) - hash) + postId.charCodeAt(i)) | 0;
}
return `--halftone-ink: var(--ink-${INK_NAMES[Math.abs(hash) % INK_NAMES.length]});`;
},
getThumbnailUrl(item) {
const data = this.getHistoryItemData(item);
if (!data || !data.videoDid || !data.videoCid) return null;
if (this.thumbnailErrors[data.postId]) return null;
return videoThumbnailUrl(data.videoDid, data.videoCid);
},
handleThumbnailError(postId) {
if (!postId) return;
this.thumbnailErrors[postId] = true;
},
async backfillHistoryThumbnails() {
if (this._backfillRunning) return;
this._backfillRunning = true;
const BACKFILL_VERSION = 2;
const targets = this.paginatedHistory.filter(item => {
if (!item || typeof item === "string") return true;
const data = item.postData || {};
const hasAllFields = data.videoDid && data.videoCid && data.text !== undefined && data.videoAlt !== undefined;
if (hasAllFields) return false;
if (item.backfillVersion === BACKFILL_VERSION) return false;
return true;
});
if (targets.length === 0) {
this._backfillRunning = false;
return;
}
let mutated = false;
for (const item of targets) {
const url = this.getHistoryItemUrl(item);
if (!url) continue;
try {
const { profile, post } = this.extractProfileAndPost(url);
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 10000);
const res = await fetch(
`https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread?uri=${encodeURIComponent(`at://${profile}/app.bsky.feed.post/${post}`)}&depth=0&parentHeight=0`,
{ signal: controller.signal }
);
clearTimeout(timeoutId);
if (typeof item === "string") {
const idx = this.urlHistory.indexOf(item);
if (idx === -1) continue;
const upgraded = { url: item, timestamp: Date.now(), postData: this.extractPostDataFromUrl(item), backfillVersion: BACKFILL_VERSION };
this.urlHistory.splice(idx, 1, upgraded);
mutated = true;
if (!res.ok) continue;
const data = await res.json();
this.applyBackfillData(upgraded, data.thread?.post);
} else {
item.backfillVersion = BACKFILL_VERSION;
delete item.backfillTried;
mutated = true;
if (!res.ok) continue;
const data = await res.json();
this.applyBackfillData(item, data.thread?.post);
}
} catch (err) {
if (typeof item !== "string") {
item.backfillVersion = BACKFILL_VERSION;
delete item.backfillTried;
mutated = true;
}
}
await new Promise(r => setTimeout(r, 200));
}
if (mutated) {
try {
localStorage.setItem("urlHistory", JSON.stringify(this.urlHistory));
} catch (err) {
console.warn("localStorage write failed during backfill", err);
}
}
this._backfillRunning = false;
},
applyBackfillData(entry, post) {
if (!post) return;
const info = this.extractVideoInfo(post);
if (!entry.postData) entry.postData = this.extractPostDataFromUrl(entry.url);
if (post.author) {
entry.postData.username = post.author.handle || entry.postData.username;
entry.postData.displayName = post.author.displayName || post.author.handle || entry.postData.displayName;
entry.postData.avatar = post.author.avatar || entry.postData.avatar || null;
}
entry.postData.text = post.record?.text || "";
if (info && info.kind === "bluesky-video") {
entry.postData.videoDid = info.did;
entry.postData.videoCid = info.cid;
entry.postData.videoAlt = info.alt || "";
}
},
// ---- URL parsing ----
// Accepts any Atmosphere client that shares Bluesky's /profile/<actor>/post/<rkey>
// route (bsky.app, deer.social, blacksky.community...) and raw at:// URIs.
// The host is never trusted: only actor and rkey survive, always rebuilt
// as a bsky.app URL, so an unknown host cannot reach history or an href.
extractProfileAndPost(postUrl) {
const input = String(postUrl ?? "").trim();
let rawProfile;
let rawPost;
let host = null;
const atUri = input.match(/^at:\/\/([^/]+)\/app\.bsky\.feed\.post\/([^/?#]+)\/?$/);
if (atUri) {
[, rawProfile, rawPost] = atUri;
} else {
let url;
try {
url = new URL(/^[a-z][a-z0-9+.-]*:/i.test(input) ? input : `https://${input}`);
} catch {
throw new Error("Invalid URL");
}
if (url.protocol !== "https:" && url.protocol !== "http:") {
throw new Error("Invalid URL");
}
const m = url.pathname.match(/^\/profile\/([^/]+)\/post\/([^/]+)\/?$/);
if (!m) throw new Error("Invalid URL format");
[, rawProfile, rawPost] = m;
host = url.hostname.replace(/\.$/, "").replace(/^www\./, "");
}
let profile;
let post;
try {
profile = decodeURIComponent(rawProfile);
post = decodeURIComponent(rawPost);
} catch {
throw new Error("Invalid URL format");
}
// Handle or DID, and a record key, per the AT Protocol syntax rules.
// No "%": a decoded value must rebuild into the same URL, or history drifts.
// "." and ".." are forbidden record keys and would walk the rebuilt path.
if (!/^[a-zA-Z0-9._:-]{1,253}$/.test(profile) || !/^[a-zA-Z0-9._:~-]{1,512}$/.test(post)
|| [".", ".."].includes(profile) || [".", ".."].includes(post)) {
throw new Error("Invalid URL format");
}
return {
profile,
post,
url: `https://bsky.app/profile/${profile}/post/${post}`,
// Came from another Atmosphere client or an at:// URI.
fromAtmosphere: host !== "bsky.app",
};
},
// History links bind this, never the stored string. Invalid entries have no href.
normalizedHistoryUrl(item) {
try { return this.extractProfileAndPost(this.getHistoryItemUrl(item)).url; }
catch { return null; }
},
// ---- Embed extraction (returns full Bluesky video info or fallback URL) ----
extractVideoInfo(post) {