Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat(medcel): add file import functionality for cookies JSON and update textarea placeholder

Tonho276eca23d176
diff --git a/src/routes/courses/medcel/+page.svelte b/src/routes/courses/medcel/+page.svelte
index 05bf9efd..6c290d2a 100644
--- a/src/routes/courses/medcel/+page.svelte
+++ b/src/routes/courses/medcel/+page.svelte
@@ -28,6 +28,18 @@
let loginMode = $state<"credentials" | "token">("credentials");
+ let fileInput: HTMLInputElement = $state() as HTMLInputElement;
+
+ function onFileSelected(e: Event) {
+ const input = e.target as HTMLInputElement;
+ const file = input.files?.[0];
+ if (!file) return;
+ const reader = new FileReader();
+ reader.onload = () => { token = reader.result as string; };
+ reader.readAsText(file);
+ input.value = "";
+ }
+
let courses: MedcelCourse[] = $state([]);
let loadingCourses = $state(false);
let coursesError = $state("");
@@ -380,15 +392,27 @@
{:else}
<div class="form">
<label class="field">
- <span class="field-label">Bearer Token</span>
+ <span class="field-label">Cookies JSON</span>
<textarea
class="input token-textarea"
- placeholder="Paste your Bearer token here..."
+ placeholder="Paste cookies JSON from browser extension or a raw token"
bind:value={token}
disabled={loading}
- rows="4"
+ rows="5"
></textarea>
</label>
+
+ <input
+ type="file"
+ accept=".json,.txt"
+ class="hidden-file-input"
+ bind:this={fileInput}
+ onchange={onFileSelected}
+ />
+ <button class="button" onclick={() => fileInput?.click()} disabled={loading}>
+ Import .json file
+ </button>
+
<label class="field">
<span class="field-label">X-API-Key</span>
<input
@@ -596,10 +620,15 @@
border-radius: 0 var(--border-radius) var(--border-radius) 0;
}
+ .hidden-file-input {
+ display: none;
+ }
+
.token-textarea {
resize: vertical;
min-height: 80px;
- font-size: 12px;
+ font-size: 11.5px;
+ font-family: var(--font-mono);
line-height: 1.5;
}