-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpopup.js
More file actions
761 lines (657 loc) · 22.4 KB
/
Copy pathpopup.js
File metadata and controls
761 lines (657 loc) · 22.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
document.addEventListener("DOMContentLoaded", () => {
const $ = id => document.getElementById(id);
const POPUP_STATE_KEY = "popupState";
const QUICK_LINK_POLL_MS = 2000;
const LOCAL_FILE_INPUT_PREFIX = "[Local file] ";
const LOCAL_FILE_DROP_DEFAULT = "Drop a local image, video, or audio file here";
const LOCAL_MEDIA_UPLOAD_DB_NAME = "vrchat-local-media";
const LOCAL_MEDIA_UPLOAD_STORE = "uploads";
const LOCAL_MEDIA_UPLOAD_MAX_AGE_MS = 24 * 60 * 60 * 1000;
const LOCAL_MEDIA_BLOB_STAGE_MAX_BYTES = 512 * 1024 * 1024;
let selectedLocalUploadId = "";
let selectedLocalFileName = "";
let selectedLocalFileContentType = "";
let selectedLocalFileMarker = "";
let isPollingQuickLink = false;
const input = $("input");
const output = $("output");
const getBtn = $("get");
const pickFileBtn = $("pickFile");
const localFilePicker = $("localFilePicker");
const dropZone = $("dropZone");
const toggleSettingsBtn = $("toggleSettings");
const settingsBox = $("settings");
const toggleStreamingSettingsBtn = $("toggleStreamingSettings");
const streamingSettingsSection = $("streamingSettingsSection");
const streamSegmentDuration = $("streamSegmentDuration");
const spinner = $("spinner");
const status = $("status");
const usePublic = $("usePublic");
const useLocalApi = $("useLocalApi");
const useLocalApiToggle = $("useLocalApiToggle");
const localAddress = $("localAddress");
const localPort = $("localPort");
const globalUrl = $("globalUrl");
const refreshPublic = $("refreshPublic");
const clearAllCacheBtn = $("clearAllCache");
const globalError = $("globalError");
toggleSettingsBtn.addEventListener("click", () => {
settingsBox.style.display =
settingsBox.style.display === "block" ? "none" : "block";
});
toggleStreamingSettingsBtn.addEventListener("click", () => {
streamingSettingsSection.style.display =
streamingSettingsSection.style.display === "block" ? "none" : "block";
});
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function normalizePositiveInt(value, fallback) {
const parsed = Number.parseInt(String(value ?? ""), 10);
if (!Number.isFinite(parsed) || parsed < 1) {
return fallback;
}
return parsed;
}
function formatBytes(size) {
const value = Number(size);
if (!Number.isFinite(value) || value < 0) return "";
const units = ["B", "KB", "MB", "GB", "TB"];
let unitIndex = 0;
let scaled = value;
while (scaled >= 1024 && unitIndex < units.length - 1) {
scaled /= 1024;
unitIndex += 1;
}
const digits = scaled >= 100 || unitIndex === 0 ? 0 : scaled >= 10 ? 1 : 2;
return `${scaled.toFixed(digits)} ${units[unitIndex]}`;
}
function selectedLocalFileLabel(name, sizeText = "") {
return `${LOCAL_FILE_INPUT_PREFIX}${name}${sizeText ? ` (${sizeText})` : ""}`;
}
function isSupportedLocalFileMeta(name, type) {
const mime = String(type || "").toLowerCase();
if (
mime.startsWith("image/") ||
mime.startsWith("video/") ||
mime.startsWith("audio/")
) {
return true;
}
return /\.(jpe?g|png|webp|bmp|gif|tiff?|mp4|m4v|mov|mkv|avi|webm|ts|mts|m2ts|flv|mp3|m4a|aac|flac|ogg|oga|opus|wav|wma)$/i.test(
name || ""
);
}
function isSupportedLocalFile(file) {
if (!file) return false;
return isSupportedLocalFileMeta(file.name, file.type);
}
async function ensureReadableFileHandle(handle) {
if (!handle || handle.kind !== "file") {
throw new Error("Only local files are supported");
}
if (typeof handle.queryPermission === "function") {
let permission = await handle.queryPermission({ mode: "read" });
if (permission !== "granted" && typeof handle.requestPermission === "function") {
permission = await handle.requestPermission({ mode: "read" });
}
if (permission !== "granted") {
throw new Error("Read access to the selected local file was not granted");
}
}
return handle;
}
function updateDropZone(text) {
dropZone.textContent = text || LOCAL_FILE_DROP_DEFAULT;
}
function showSpinner(text) {
spinner.style.display = "block";
status.textContent = text || "";
}
function hideSpinner() {
spinner.style.display = "none";
}
function showError(msg) {
globalError.textContent = msg;
globalError.style.display = "block";
}
function clearError() {
globalError.textContent = "";
globalError.style.display = "none";
}
function openLocalMediaUploadDb() {
return new Promise((resolve, reject) => {
const req = indexedDB.open(LOCAL_MEDIA_UPLOAD_DB_NAME, 1);
req.onupgradeneeded = () => {
const db = req.result;
if (!db.objectStoreNames.contains(LOCAL_MEDIA_UPLOAD_STORE)) {
db.createObjectStore(LOCAL_MEDIA_UPLOAD_STORE);
}
};
req.onsuccess = () => resolve(req.result);
req.onerror = () => reject(req.error || new Error("Failed to open local media DB"));
});
}
async function putLocalMediaUpload(uploadId, value) {
const db = await openLocalMediaUploadDb();
await new Promise((resolve, reject) => {
const tx = db.transaction(LOCAL_MEDIA_UPLOAD_STORE, "readwrite");
const store = tx.objectStore(LOCAL_MEDIA_UPLOAD_STORE);
const req = store.put(value, uploadId);
req.onsuccess = () => resolve();
req.onerror = () => reject(req.error || new Error("Failed to store local upload"));
tx.oncomplete = () => db.close();
tx.onabort = () => db.close();
tx.onerror = () => db.close();
});
}
async function deleteLocalMediaUpload(uploadId) {
if (!uploadId) return;
const db = await openLocalMediaUploadDb();
await new Promise((resolve, reject) => {
const tx = db.transaction(LOCAL_MEDIA_UPLOAD_STORE, "readwrite");
const store = tx.objectStore(LOCAL_MEDIA_UPLOAD_STORE);
const req = store.delete(uploadId);
req.onsuccess = () => resolve();
req.onerror = () => reject(req.error || new Error("Failed to delete local upload"));
tx.oncomplete = () => db.close();
tx.onabort = () => db.close();
tx.onerror = () => db.close();
});
}
async function cleanupStaleLocalMediaUploads(maxAgeMs = LOCAL_MEDIA_UPLOAD_MAX_AGE_MS) {
const cutoff = Date.now() - maxAgeMs;
const db = await openLocalMediaUploadDb();
await new Promise((resolve, reject) => {
const tx = db.transaction(LOCAL_MEDIA_UPLOAD_STORE, "readwrite");
const store = tx.objectStore(LOCAL_MEDIA_UPLOAD_STORE);
const req = store.openCursor();
req.onsuccess = () => {
const cursor = req.result;
if (!cursor) {
resolve();
return;
}
const value = cursor.value || {};
if (!value.createdAt || value.createdAt < cutoff) {
cursor.delete();
}
cursor.continue();
};
req.onerror = () => reject(req.error || new Error("Failed to clean local uploads"));
tx.oncomplete = () => db.close();
tx.onabort = () => db.close();
tx.onerror = () => db.close();
});
}
async function savePopupState() {
await chrome.storage.session.set({
[POPUP_STATE_KEY]: {
input: selectedLocalUploadId ? "" : input.value,
output: output.value,
},
});
}
async function loadPopupState() {
const res = await chrome.storage.session.get(POPUP_STATE_KEY);
const state = res[POPUP_STATE_KEY];
if (!state) return;
if (state.input && !state.input.startsWith(LOCAL_FILE_INPUT_PREFIX)) {
input.value = state.input;
}
if (state.output) output.value = state.output;
}
function updateVisibility() {
useLocalApiToggle.style.display = usePublic.checked ? "flex" : "none";
}
async function saveSettings(patch) {
await chrome.runtime.sendMessage({
action: "saveSettings",
data: patch
});
}
async function clearSelectedLocalFile(resetInput = false, removeStoredUpload = true) {
const uploadId = selectedLocalUploadId;
selectedLocalUploadId = "";
selectedLocalFileName = "";
selectedLocalFileContentType = "";
selectedLocalFileMarker = "";
localFilePicker.value = "";
updateDropZone();
if (resetInput && input.value.startsWith(LOCAL_FILE_INPUT_PREFIX)) {
input.value = "";
}
if (removeStoredUpload && uploadId) {
try {
await deleteLocalMediaUpload(uploadId);
} catch (e) {
console.log("[popup] deleteLocalMediaUpload error:", e && e.message);
}
}
}
async function stageSelectedLocalUpload(uploadId, value, fileName, contentType, fileSize, statusLabel) {
if (selectedLocalUploadId) {
await clearSelectedLocalFile(false, true);
}
await putLocalMediaUpload(uploadId, value);
const sizeText = formatBytes(fileSize);
selectedLocalUploadId = uploadId;
selectedLocalFileName = fileName;
selectedLocalFileContentType = contentType || "";
selectedLocalFileMarker = selectedLocalFileLabel(fileName, sizeText);
input.value = selectedLocalFileMarker;
output.value = "";
status.textContent = statusLabel || `${fileName} selected`;
clearError();
updateDropZone(`Selected: ${fileName}${sizeText ? ` (${sizeText})` : ""}`);
await savePopupState();
}
async function setSelectedLocalFileHandle(handle) {
const readableHandle = await ensureReadableFileHandle(handle);
const file = await readableHandle.getFile();
if (!isSupportedLocalFile(file)) {
throw new Error("Only local image, video, and audio files are supported");
}
const uploadId = crypto.randomUUID();
const value = {
handle: readableHandle,
filename: file.name,
contentType: file.type || "",
size: file.size,
createdAt: Date.now(),
sourceType: "handle"
};
try {
await stageSelectedLocalUpload(
uploadId,
value,
file.name,
file.type || "",
file.size,
`${file.name} selected from filesystem`
);
return;
} catch (e) {
if (file.size > LOCAL_MEDIA_BLOB_STAGE_MAX_BYTES) {
throw new Error("Large local files require File System Access support or a pasted local path");
}
console.log("[popup] handle staging fallback:", e && e.message);
}
await setSelectedLocalFile(file);
}
async function setSelectedLocalFile(file) {
if (!isSupportedLocalFile(file)) {
throw new Error("Only local image, video, and audio files are supported");
}
if (file.size > LOCAL_MEDIA_BLOB_STAGE_MAX_BYTES) {
throw new Error("Large local files must be selected through File System Access or pasted as a local path");
}
const uploadId = crypto.randomUUID();
await stageSelectedLocalUpload(
uploadId,
{
blob: file,
filename: file.name,
contentType: file.type || "",
size: file.size,
createdAt: Date.now(),
sourceType: "blob"
},
file.name,
file.type || "",
file.size,
`${file.name} selected`
);
}
function applyJobLabel(job) {
if (!job || !job.sourceLabel) return;
if (job.sourceKind === "local-upload") {
input.value = selectedLocalFileLabel(job.sourceLabel);
return;
}
if (!input.value || input.value.startsWith(LOCAL_FILE_INPUT_PREFIX)) {
input.value = job.sourceLabel;
}
}
function pendingStatusText(job) {
switch (job.sourceKind) {
case "telegram":
return "Preparing Telegram stream. Large videos can take a few minutes...";
case "local-upload":
return job.status === "starting"
? "Uploading local file and preparing HLS stream..."
: "Preparing local media stream...";
case "local-path":
return job.status === "starting"
? "Preparing local media from filesystem path..."
: "Preparing local media stream...";
case "youtube":
case "soundcloud":
case "audio":
case "video":
case "image":
return "Waiting for server...";
default:
return "Waiting for server...";
}
}
async function copyResult(url) {
try {
await navigator.clipboard.writeText(url);
return true;
} catch {
try {
output.focus();
output.select();
document.execCommand("copy");
return true;
} catch {
return false;
}
}
}
async function applyQuickLinkState(job, autoCopy = true) {
if (!job || job.status === "idle") {
return false;
}
applyJobLabel(job);
if (job.status === "starting" || job.status === "pending") {
showSpinner(pendingStatusText(job));
return false;
}
hideSpinner();
if (job.status === "ready" && job.url) {
output.value = job.url;
if (autoCopy && !job.autoCopied) {
const copied = await copyResult(job.url);
if (copied) {
try {
await chrome.runtime.sendMessage({
action: "markQuickLinkJobCopied",
url: job.url
});
} catch (e) {
console.log("[popup] markQuickLinkJobCopied error:", e && e.message);
}
}
status.textContent = copied ? "Ready & copied" : "Ready";
} else {
status.textContent = "Ready";
}
await savePopupState();
return true;
}
if (job.status === "error") {
status.textContent = "Error: " + (job.error || "Build failed");
return true;
}
return false;
}
async function pollQuickLinkUntilSettled() {
if (isPollingQuickLink) return;
isPollingQuickLink = true;
try {
while (true) {
const job = await chrome.runtime.sendMessage({ action: "getQuickLinkJobStatus" });
if (!job || job.status === "idle") {
hideSpinner();
return;
}
const done = await applyQuickLinkState(job, true);
if (done) {
return;
}
await sleep(QUICK_LINK_POLL_MS);
}
} finally {
isPollingQuickLink = false;
}
}
async function resumeQuickLinkJobIfNeeded() {
const job = await chrome.runtime.sendMessage({ action: "getQuickLinkJobStatus" });
if (!job || job.status === "idle") {
return;
}
const done = await applyQuickLinkState(job, job.status === "ready" && !job.autoCopied);
if (!done) {
await pollQuickLinkUntilSettled();
}
}
async function loadSettingsAndMaybeAutofill() {
const cfg = await chrome.runtime.sendMessage({ action: "getSettings" });
usePublic.checked = !!cfg.usePublicUrl;
useLocalApi.checked = !!cfg.useLocalApiForProcessing;
localAddress.value = cfg.localAddress || "127.0.0.1";
localPort.value = cfg.localPort || "8080";
globalUrl.value = cfg.globalUrl || "";
streamSegmentDuration.value = String(normalizePositiveInt(cfg.streamSegmentDuration, 4));
updateVisibility();
clearError();
await loadPopupState();
const shouldAuto = usePublic.checked && (!cfg.globalUrl || !cfg.manualGlobal);
if (!shouldAuto) return;
showSpinner("Auto-detecting public URL...");
clearError();
try {
const r = await chrome.runtime.sendMessage({ action: "detectTunnel" });
if (r && r.url) {
globalUrl.value = r.url;
await chrome.runtime.sendMessage({
action: "saveSettings",
data: { globalUrl: r.url, manualGlobal: false }
});
status.textContent = "Public URL detected";
} else {
showError("Auto-detect failed");
status.textContent = "";
}
} catch {
showError("Auto-detect failed");
status.textContent = "";
} finally {
hideSpinner();
}
}
usePublic.addEventListener("change", async () => {
updateVisibility();
await saveSettings({ usePublicUrl: usePublic.checked });
if (usePublic.checked) {
loadSettingsAndMaybeAutofill().catch(() => {});
}
});
useLocalApi.addEventListener("change", () => saveSettings({ useLocalApiForProcessing: useLocalApi.checked }));
localAddress.addEventListener("change", () => saveSettings({ localAddress: localAddress.value.trim() }));
localPort.addEventListener("change", () => saveSettings({ localPort: localPort.value.trim() }));
function syncStreamingSettings(save = false) {
const duration = normalizePositiveInt(streamSegmentDuration.value, 4);
streamSegmentDuration.value = String(duration);
if (save) {
saveSettings({ streamSegmentDuration: duration });
}
}
streamSegmentDuration.addEventListener("change", () => syncStreamingSettings(true));
streamSegmentDuration.addEventListener("blur", () => syncStreamingSettings(true));
globalUrl.addEventListener("change", async () => {
const v = globalUrl.value.trim();
if (v) {
await saveSettings({ globalUrl: v, manualGlobal: true });
clearError();
} else {
await saveSettings({ globalUrl: "", manualGlobal: false });
}
});
refreshPublic.addEventListener("click", async () => {
clearError();
showSpinner("Refreshing public URL...");
try {
const r = await chrome.runtime.sendMessage({ action: "refreshPublicUrl" });
if (r && r.url) {
globalUrl.value = r.url;
await saveSettings({ globalUrl: r.url, manualGlobal: false });
status.textContent = "Refreshed";
} else {
showError("Failed to detect public URL (local API unreachable)");
status.textContent = "";
}
} catch {
showError("Failed to detect public URL");
status.textContent = "";
} finally {
hideSpinner();
}
});
clearAllCacheBtn.addEventListener("click", async () => {
if (!confirm("Clear all generated streams and temporary cached media files?")) {
return;
}
clearError();
showSpinner("Clearing all cache...");
try {
const result = await chrome.runtime.sendMessage({ action: "clearAllCache" });
if (!result || !result.ok) {
throw new Error(result?.error || "Failed to clear cache");
}
await clearSelectedLocalFile(true, false);
output.value = "";
await chrome.storage.session.remove(POPUP_STATE_KEY);
await savePopupState();
status.textContent = "All cache cleared";
} catch (e) {
status.textContent = "Error: " + e.message;
} finally {
hideSpinner();
}
});
pickFileBtn.addEventListener("click", async () => {
if (typeof window.showOpenFilePicker === "function") {
try {
const handles = await window.showOpenFilePicker({
multiple: false,
excludeAcceptAllOption: false,
types: [{
description: "Local media",
accept: {
"image/*": [".jpg", ".jpeg", ".png", ".webp", ".bmp", ".gif", ".tif", ".tiff"],
"video/*": [".mp4", ".m4v", ".mov", ".mkv", ".avi", ".webm", ".ts", ".mts", ".m2ts", ".flv"],
"audio/*": [".mp3", ".m4a", ".aac", ".flac", ".ogg", ".oga", ".opus", ".wav", ".wma"]
}
}]
});
const handle = handles && handles[0];
if (!handle) return;
await setSelectedLocalFileHandle(handle);
return;
} catch (e) {
if (e && e.name === "AbortError") {
return;
}
status.textContent = "Error: " + e.message;
return;
}
}
localFilePicker.click();
});
localFilePicker.addEventListener("change", async () => {
try {
const file = localFilePicker.files && localFilePicker.files[0];
if (!file) return;
await setSelectedLocalFile(file);
} catch (e) {
status.textContent = "Error: " + e.message;
} finally {
localFilePicker.value = "";
}
});
["dragenter", "dragover"].forEach(eventName => {
dropZone.addEventListener(eventName, (event) => {
event.preventDefault();
event.stopPropagation();
dropZone.classList.add("active");
});
});
["dragleave", "dragend"].forEach(eventName => {
dropZone.addEventListener(eventName, (event) => {
event.preventDefault();
event.stopPropagation();
dropZone.classList.remove("active");
});
});
dropZone.addEventListener("drop", async (event) => {
event.preventDefault();
event.stopPropagation();
dropZone.classList.remove("active");
try {
const item = Array.from(event.dataTransfer?.items || []).find(entry => entry && entry.kind === "file");
if (item && typeof item.getAsFileSystemHandle === "function") {
const handle = await item.getAsFileSystemHandle();
if (handle && handle.kind === "file") {
await setSelectedLocalFileHandle(handle);
return;
}
}
const file = event.dataTransfer?.files?.[0];
if (!file) return;
await setSelectedLocalFile(file);
} catch (e) {
status.textContent = "Error: " + e.message;
}
});
document.body.addEventListener("dragover", event => {
event.preventDefault();
});
document.body.addEventListener("drop", event => {
if (event.target === dropZone) return;
event.preventDefault();
});
input.addEventListener("input", async () => {
if (selectedLocalUploadId && input.value !== selectedLocalFileMarker) {
await clearSelectedLocalFile(false, true);
}
output.value = "";
await savePopupState();
});
getBtn.addEventListener("click", async () => {
const src = input.value.trim();
if (!src && !selectedLocalUploadId) return;
clearError();
showSpinner("Waiting for server...");
try {
let result;
if (selectedLocalUploadId) {
result = await chrome.runtime.sendMessage({
action: "startQuickLinkJob",
uploadId: selectedLocalUploadId,
fileName: selectedLocalFileName,
contentType: selectedLocalFileContentType,
sourceLabel: selectedLocalFileName
});
await clearSelectedLocalFile(false, false);
} else {
result = await chrome.runtime.sendMessage({
action: "startQuickLinkJob",
source: src,
sourceLabel: src
});
}
if (!result) {
throw new Error("Failed to start build");
}
const done = await applyQuickLinkState(result, true);
if (!done) {
await pollQuickLinkUntilSettled();
}
} catch (e) {
hideSpinner();
status.textContent = "Error: " + e.message;
}
});
updateDropZone();
(async () => {
await cleanupStaleLocalMediaUploads();
await loadSettingsAndMaybeAutofill();
await resumeQuickLinkJobIfNeeded();
})().catch((e) => {
hideSpinner();
status.textContent = "Error: " + (e && e.message ? e.message : String(e));
});
});