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: enhance media detection and support for profile content types; improve cookie handling and deduplication logic

Tonho2405749f04b4
diff --git a/browser-extension/chrome/popup/popup.js b/browser-extension/chrome/popup/popup.js
index e1ead359..cac1f57e 100644
--- a/browser-extension/chrome/popup/popup.js
+++ b/browser-extension/chrome/popup/popup.js
@@ -61,7 +61,7 @@ function render() {
}
function renderKnownPlatform(container) {
- const { pageDetected, tabUrl, media } = currentData;
+ const { pageDetected, tabUrl } = currentData;
const domain = getDomainFromUrl(tabUrl);
const label = getDownloadLabel(pageDetected.contentType);
const meta = domain + (pageTitle ? " \u00b7 " + truncate(pageTitle, 35) : "");
@@ -69,8 +69,6 @@ function renderKnownPlatform(container) {
appendPrimaryButton(container, label, meta, (btn) => {
handleDownload(btn, tabUrl, pageDetected.platform);
});
-
- appendMediaControls(container, media);
}
function renderMediaDetected(container) {
@@ -139,7 +137,7 @@ function appendMediaControls(container, media) {
const hlsGroups = groupHlsManifests(media);
const groups = [...hlsGroups.values()].filter(g => g.master);
const nonHls = (media || []).filter(m => m.mediaType !== "hls");
- const directMedia = nonHls.filter(m => m.contentLength > 500 * 1024).slice(0, 10);
+ const directMedia = deduplicateMedia(nonHls.filter(m => m.contentLength > 500 * 1024)).slice(0, 10);
const totalItems = groups.length + directMedia.length;
if (groups.length >= 2) {
@@ -316,12 +314,13 @@ function sendToApp(url, platform, mediaEntry) {
if (mediaEntry?.contentType) msg.contentType = mediaEntry.contentType;
if (mediaEntry?.requestHeaders) {
- const keep = ["authorization", "x-csrf-token", "x-session-id", "cookie", "origin"];
+ const skip = ["host", "connection", "accept-encoding", "sec-ch-ua", "sec-ch-ua-mobile", "sec-ch-ua-platform", "sec-fetch-dest", "sec-fetch-mode", "sec-fetch-site", "upgrade-insecure-requests"];
const extracted = {};
for (const h of mediaEntry.requestHeaders) {
- if (keep.includes(h.name.toLowerCase())) {
- extracted[h.name] = h.value;
- }
+ const name = h.name.toLowerCase();
+ if (skip.includes(name)) continue;
+ if (name.startsWith("sec-")) continue;
+ extracted[h.name] = h.value;
}
if (Object.keys(extracted).length > 0) {
msg.headers = extracted;
@@ -375,8 +374,11 @@ function groupHlsManifests(media) {
const group = groups.get(key);
group.all.push(item);
- if (filename.includes("playlist")) group.master = item;
- else if (!group.master) group.master = item;
+ if (filename.includes("master") || filename.includes("playlist") || filename === "index.m3u8") {
+ group.master = item;
+ } else if (!group.master) {
+ group.master = item;
+ }
}
return groups;
@@ -421,12 +423,32 @@ function pickBestMedia(media) {
function getDownloadLabel(contentType) {
switch (contentType) {
- case "course": return "Send to OmniGet";
- case "playlist": return "Send playlist";
+ case "course": return "Send course to OmniGet";
+ case "playlist": return "Send playlist to OmniGet";
+ case "video": return "Send video to OmniGet";
+ case "reel": return "Send reel to OmniGet";
+ case "post": return "Send post to OmniGet";
+ case "short": return "Send short to OmniGet";
+ case "clip": return "Send clip to OmniGet";
+ case "image": return "Send image to OmniGet";
+ case "audio": return "Send audio to OmniGet";
+ case "profile": return "Send profile to OmniGet";
default: return "Send to OmniGet";
}
}
+function deduplicateMedia(media) {
+ const seen = new Map();
+ for (const m of media) {
+ const key = getDomainFromUrl(m.url) + "_" + m.mediaType;
+ const existing = seen.get(key);
+ if (!existing || m.contentLength > existing.contentLength) {
+ seen.set(key, m);
+ }
+ }
+ return [...seen.values()].sort((a, b) => b.contentLength - a.contentLength);
+}
+
function getDomainFromUrl(url) {
try { return new URL(url).hostname; } catch { return ""; }
}
diff --git a/browser-extension/chrome/src/background.js b/browser-extension/chrome/src/background.js
index 6c390c44..b7b85a5e 100644
--- a/browser-extension/chrome/src/background.js
+++ b/browser-extension/chrome/src/background.js
@@ -167,10 +167,26 @@ async function handleSendToApp(msg) {
if (platformCookies && platformCookies.length > 0) {
cookies = platformCookies;
} else {
+ const cookieMap = new Map();
+
const urlObj = new URL(url);
- const allCookies = await chrome.cookies.getAll({ domain: urlObj.hostname });
- if (allCookies.length > 0) {
- cookies = allCookies.map(c => ({
+ const cdnCookies = await chrome.cookies.getAll({ domain: urlObj.hostname });
+ for (const c of cdnCookies) {
+ cookieMap.set(`${c.domain}:${c.name}`, c);
+ }
+
+ if (msg.referer) {
+ try {
+ const refererObj = new URL(msg.referer);
+ const pageCookies = await chrome.cookies.getAll({ domain: refererObj.hostname });
+ for (const c of pageCookies) {
+ cookieMap.set(`${c.domain}:${c.name}`, c);
+ }
+ } catch {}
+ }
+
+ if (cookieMap.size > 0) {
+ cookies = [...cookieMap.values()].map(c => ({
domain: c.domain,
httpOnly: c.httpOnly,
path: c.path,
@@ -191,6 +207,21 @@ async function handleSendToApp(msg) {
if (msg.mediaType) message.mediaType = msg.mediaType;
if (msg.contentType) message.contentType = msg.contentType;
if (msg.headers) message.headers = msg.headers;
+ message.pageUrl = msg.referer || "";
+ message.userAgent = navigator.userAgent;
+
+ try {
+ await chrome.storage.local.set({
+ last_download_metadata: {
+ url,
+ referer: msg.referer || "",
+ headers: msg.headers || {},
+ cookies: cookies || [],
+ userAgent: navigator.userAgent,
+ timestamp: Date.now(),
+ },
+ }).catch(() => {});
+ } catch {}
try {
const response = await sendNativeMessage(message);
diff --git a/browser-extension/chrome/src/detect.js b/browser-extension/chrome/src/detect.js
index aebb0e22..29c6baf0 100644
--- a/browser-extension/chrome/src/detect.js
+++ b/browser-extension/chrome/src/detect.js
@@ -5,6 +5,7 @@ const MEDIA_CONTENT_TYPES = new Set([
"image",
"playlist",
"post",
+ "profile",
"reel",
"short",
"video",
diff --git a/browser-extension/chrome/src/media-sniffer.js b/browser-extension/chrome/src/media-sniffer.js
index b046bd18..f275f05d 100644
--- a/browser-extension/chrome/src/media-sniffer.js
+++ b/browser-extension/chrome/src/media-sniffer.js
@@ -218,6 +218,11 @@ export function registerSnifferListeners(onMediaDetected) {
const contentType = getContentType(details.responseHeaders);
const contentLength = getContentLength(details.responseHeaders);
+
+ if (isPlatformCdnFragment(url, contentType, contentLength)) {
+ pendingRequests.delete(details.requestId);
+ return;
+ }
const isOctetStream = contentType.toLowerCase().includes("application/octet-stream");
const isMedia = isMediaByContentType(contentType) || isMediaByExtension(url);
diff --git a/browser-extension/chrome/tests/detect.test.mjs b/browser-extension/chrome/tests/detect.test.mjs
index c7090028..73304af5 100644
--- a/browser-extension/chrome/tests/detect.test.mjs
+++ b/browser-extension/chrome/tests/detect.test.mjs
@@ -82,10 +82,10 @@ test("YouTube: old embed /v/ format", () => {
assertSupported("https://www.youtube.com/v/abc123", "youtube", "video");
});
-test("YouTube: channel page is unsupported", () => {
- assertUnsupported("https://www.youtube.com/@omniget", "youtube", "profile");
- assertUnsupported("https://www.youtube.com/channel/UCxyz", "youtube", "profile");
- assertUnsupported("https://www.youtube.com/c/omniget", "youtube", "profile");
+test("YouTube: channel page is supported as profile", () => {
+ assertSupported("https://www.youtube.com/@omniget", "youtube", "profile");
+ assertSupported("https://www.youtube.com/channel/UCxyz", "youtube", "profile");
+ assertSupported("https://www.youtube.com/c/omniget", "youtube", "profile");
});
test("YouTube: youtube-nocookie.com", () => {
@@ -106,8 +106,8 @@ test("Instagram: story", () => {
assertSupported("https://www.instagram.com/stories/user/12345/", "instagram", "image");
});
-test("Instagram: profile is unsupported", () => {
- assertUnsupported("https://www.instagram.com/username", "instagram", "profile");
+test("Instagram: profile is supported", () => {
+ assertSupported("https://www.instagram.com/username", "instagram", "profile");
});
test("Instagram: explore is unknown", () => {
@@ -124,8 +124,8 @@ test("TikTok: user video", () => {
assertSupported("https://www.tiktok.com/@user/video/1234567890", "tiktok", "video");
});
-test("TikTok: profile is unsupported", () => {
- assertUnsupported("https://www.tiktok.com/@user", "tiktok", "profile");
+test("TikTok: profile is supported", () => {
+ assertSupported("https://www.tiktok.com/@user", "tiktok", "profile");
});
test("TikTok: short link /t/<code>", () => {
@@ -166,8 +166,8 @@ test("Twitter: fixvx mirror", () => {
assertSupported("https://fixvx.com/user/status/123456", "twitter", "post");
});
-test("Twitter: profile is unsupported", () => {
- assertUnsupported("https://twitter.com/user", "twitter", "profile");
+test("Twitter: profile is supported", () => {
+ assertSupported("https://twitter.com/user", "twitter", "profile");
});
test("Twitter: search/explore/settings are unknown", () => {
@@ -203,8 +203,8 @@ test("Reddit: /video/ link", () => {
assertSupported("https://www.reddit.com/video/abc123", "reddit", "video");
});
-test("Reddit: subreddit browse is unsupported profile", () => {
- assertUnsupported("https://www.reddit.com/r/videos", "reddit", "profile");
+test("Reddit: subreddit browse is supported as profile", () => {
+ assertSupported("https://www.reddit.com/r/videos", "reddit", "profile");
});
test("Reddit: homepage is unknown", () => {
@@ -282,8 +282,8 @@ test("Bluesky: post", () => {
assertSupported("https://bsky.app/profile/user.bsky.social/post/abc123", "bluesky", "post");
});
-test("Bluesky: profile is unsupported", () => {
- assertUnsupported("https://bsky.app/profile/user.bsky.social", "bluesky", "profile");
+test("Bluesky: profile is supported", () => {
+ assertSupported("https://bsky.app/profile/user.bsky.social", "bluesky", "profile");
});
// ── Telegram ─────────────────────────────────────────────────────────────
@@ -292,8 +292,8 @@ test("Telegram: numbered post", () => {
assertSupported("https://t.me/channel/123", "telegram", "post");
});
-test("Telegram: channel profile is unsupported", () => {
- assertUnsupported("https://t.me/channel", "telegram", "profile");
+test("Telegram: channel profile is supported", () => {
+ assertSupported("https://t.me/channel", "telegram", "profile");
});
test("Telegram: joinchat/addstickers/login/share are unknown", () => {