Skip to content

The only downloader you need. 下载器的集大成者。

feat: 添加媒体下载覆盖层功能,支持在浏览器中下载媒体资源

XiaoYouChR52bac7da0cf9
diff --git a/browser_extension/app/public/catch-script/media-download-overlay.js b/browser_extension/app/public/catch-script/media-download-overlay.js
new file mode 100644
index 00000000..16730022
--- /dev/null
+++ b/browser_extension/app/public/catch-script/media-download-overlay.js
@@ -0,0 +1,224 @@
+(function installGhostDownloaderMediaButton() {
+ if (window.GhostDownloaderMediaButton?.installed) { return; }
+ if (!globalThis.chrome?.runtime?.sendMessage) { return; }
+
+ const host = document.createElement("div");
+ const root = host.attachShadow({ mode: "open" });
+ let resetTimer = 0;
+ let updateQueued = false;
+ let enabled = false;
+
+ host.id = "ghostDownloaderMediaDownload";
+ Object.assign(host.style, {
+ display: "none",
+ left: "0",
+ position: "fixed",
+ top: "0",
+ zIndex: "1000000000",
+ });
+
+ root.innerHTML = `
+ <style>
+ :host {
+ font: 13px/18px "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
+ }
+ button {
+ align-items: center;
+ background: rgba(255, 255, 255, 0.96);
+ border: 1px solid #d1d1d1;
+ border-radius: 4px;
+ box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18), 0 1px 4px rgba(0, 0, 0, 0.12);
+ color: #242424;
+ cursor: pointer;
+ display: inline-flex;
+ font: inherit;
+ font-weight: 600;
+ gap: 6px;
+ min-height: 32px;
+ padding: 6px 10px;
+ white-space: nowrap;
+ }
+ button:hover {
+ background: #f5f5f5;
+ }
+ button:active {
+ background: #e0e0e0;
+ }
+ button:disabled {
+ cursor: default;
+ opacity: 0.78;
+ }
+ .icon {
+ width: 16px;
+ height: 16px;
+ flex: none;
+ }
+ .status {
+ color: #0f6cbd;
+ }
+ .error {
+ color: #b10e1c;
+ }
+ </style>
+ <button type="button" title="发送当前媒体到 Ghost Downloader">
+ <svg class="icon" viewBox="0 0 20 20" aria-hidden="true">
+ <path fill="currentColor" d="M10 2.5a.75.75 0 0 1 .75.75v7.69l2.72-2.72a.75.75 0 1 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4a.75.75 0 0 1 1.06-1.06l2.72 2.72V3.25A.75.75 0 0 1 10 2.5Zm-5.25 11a.75.75 0 0 1 .75.75v1.25h9v-1.25a.75.75 0 0 1 1.5 0v2a.75.75 0 0 1-.75.75H4.75A.75.75 0 0 1 4 16.25v-2a.75.75 0 0 1 .75-.75Z"/>
+ </svg>
+ <span class="label">下载此媒体</span>
+ <span class="status"></span>
+ </button>
+ `;
+
+ const button = root.querySelector("button");
+ const label = root.querySelector(".label");
+ const status = root.querySelector(".status");
+
+ function mediaRect(media) {
+ const rect = media.getBoundingClientRect();
+ if (rect.width < 120 || rect.height < 80 || rect.bottom <= 0 || rect.right <= 0 || rect.top >= innerHeight || rect.left >= innerWidth) {
+ return null;
+ }
+ return rect;
+ }
+
+ function mediaScore(media, rect) {
+ const playing = !media.paused && !media.ended ? 1_000_000_000 : 0;
+ return playing + media.readyState * 1_000_000 + rect.width * rect.height;
+ }
+
+ function findActiveMedia() {
+ let selected = null;
+ for (const media of document.querySelectorAll("video")) {
+ const rect = mediaRect(media);
+ if (!rect) { continue; }
+ const score = mediaScore(media, rect);
+ if (!selected || score > selected.score) {
+ selected = { media, rect, score };
+ }
+ }
+ return selected;
+ }
+
+ function updatePosition() {
+ updateQueued = false;
+ if (!enabled) {
+ host.style.display = "none";
+ return;
+ }
+ const selected = findActiveMedia();
+ if (!selected) {
+ host.style.display = "none";
+ return;
+ }
+
+ host.style.display = "block";
+ const gap = 8;
+ const buttonWidth = host.offsetWidth || 112;
+ const buttonHeight = host.offsetHeight || 32;
+ let left = selected.rect.right + gap;
+ let top = selected.rect.top;
+
+ if (left + buttonWidth > innerWidth - gap) {
+ left = Math.min(innerWidth - buttonWidth - gap, Math.max(gap, selected.rect.right - buttonWidth));
+ top = selected.rect.top - buttonHeight - gap;
+ }
+ if (top < gap && selected.rect.left - buttonWidth - gap >= gap) {
+ left = selected.rect.left - buttonWidth - gap;
+ top = selected.rect.top;
+ }
+ if (top < gap) {
+ top = selected.rect.bottom + gap;
+ }
+
+ host.style.left = `${Math.max(gap, Math.min(left, innerWidth - buttonWidth - gap))}px`;
+ host.style.top = `${Math.max(gap, Math.min(top, innerHeight - buttonHeight - gap))}px`;
+ }
+
+ function enableOverlay() {
+ enabled = true;
+ if (document.documentElement && !host.isConnected) {
+ document.documentElement.appendChild(host);
+ }
+ scheduleUpdate();
+ }
+
+ function disableOverlay() {
+ enabled = false;
+ host.style.display = "none";
+ host.remove();
+ }
+
+ function scheduleUpdate() {
+ if (updateQueued) { return; }
+ updateQueued = true;
+ requestAnimationFrame(updatePosition);
+ }
+
+ function setStatus(text, failed = false) {
+ status.textContent = text;
+ status.className = failed ? "status error" : "status";
+ clearTimeout(resetTimer);
+ if (text && !failed) {
+ resetTimer = setTimeout(() => { status.textContent = ""; }, 1600);
+ }
+ }
+
+ async function downloadMedia() {
+ const media = findActiveMedia()?.media;
+ if (!media) {
+ setStatus("未检测到媒体", true);
+ return;
+ }
+
+ button.disabled = true;
+ label.textContent = "正在发送";
+ setStatus("");
+ try {
+ const result = await chrome.runtime.sendMessage({
+ type: "page_download_media",
+ url: media.currentSrc || media.src || "",
+ href: location.href,
+ filename: document.title,
+ });
+ setStatus(result?.ok ? "已发送" : result?.message || "发送失败", !result?.ok);
+ } catch (error) {
+ setStatus(error instanceof Error ? error.message : "发送失败", true);
+ } finally {
+ label.textContent = "下载此媒体";
+ button.disabled = false;
+ scheduleUpdate();
+ }
+ }
+
+ button.addEventListener("click", (event) => {
+ event.preventDefault();
+ event.stopPropagation();
+ void downloadMedia();
+ });
+
+ addEventListener("resize", scheduleUpdate, { passive: true });
+ addEventListener("scroll", scheduleUpdate, { passive: true });
+ document.addEventListener("play", scheduleUpdate, true);
+ document.addEventListener("pause", scheduleUpdate, true);
+ document.addEventListener("loadedmetadata", scheduleUpdate, true);
+ setInterval(scheduleUpdate, 1000);
+
+ chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
+ if (message?.type !== "media_download_overlay_set_enabled") { return; }
+ Boolean(message.enabled) ? enableOverlay() : disableOverlay();
+ sendResponse({ ok: true });
+ });
+
+ chrome.runtime.sendMessage({ type: "page_media_overlay_state" }, (result) => {
+ const lastError = chrome.runtime.lastError;
+ if (!lastError && result?.enabled === false) {
+ disableOverlay();
+ return;
+ }
+ enableOverlay();
+ });
+
+ window.GhostDownloaderMediaButton = {
+ installed: true,
+ };
+})();
diff --git a/browser_extension/app/public/manifest.json b/browser_extension/app/public/manifest.json
index 9cb8f268..32d95434 100644
--- a/browser_extension/app/public/manifest.json
+++ b/browser_extension/app/public/manifest.json
@@ -37,6 +37,12 @@
"js": ["cat-catch-content-script.js", "content-script.js"],
"run_at": "document_start",
"all_frames": true
+ },
+ {
+ "matches": ["http://*/*", "https://*/*"],
+ "js": ["catch-script/media-download-overlay.js"],
+ "run_at": "document_idle",
+ "all_frames": true
}
],
"web_accessible_resources": [
diff --git a/browser_extension/app/src/background.ts b/browser_extension/app/src/background.ts
index 4c766af4..f4c294b7 100644
--- a/browser_extension/app/src/background.ts
+++ b/browser_extension/app/src/background.ts
@@ -11,12 +11,15 @@ import { createMediaBridge } from "./background/media-bridge";
import { createResourceBridge } from "./background/resource-bridge";
import {
INTERCEPT_DOWNLOADS_KEY,
+ MEDIA_DOWNLOAD_OVERLAY_KEY,
} from "./background/constants";
import {
cancelDownload,
eraseDownloadFromHistory,
getTab,
localStorageGet,
+ openActionPopup,
+ queryTabs,
} from "./background/chrome-helpers";
import {
getOnSendHeadersExtraInfoSpec,
@@ -31,6 +34,48 @@ const featureBridge = createFeatureBridge();
const mediaBridge = createMediaBridge();
let interceptDownloads = true;
+let mediaDownloadOverlayEnabled = true;
+
+async function injectMediaDownloadOverlay(tabId: number) {
+ if (!mediaDownloadOverlayEnabled) {
+ return;
+ }
+ const tab = await getTab(tabId);
+ if (!tab?.url || !/^https?:/i.test(tab.url)) {
+ return;
+ }
+
+ try {
+ await chrome.scripting.executeScript({
+ files: ["catch-script/media-download-overlay.js"],
+ injectImmediately: false,
+ target: { tabId, allFrames: true },
+ });
+ } catch {
+ // Ignore pages that do not allow extension injection.
+ }
+}
+
+async function syncMediaDownloadOverlay(enabled: boolean) {
+ mediaDownloadOverlayEnabled = enabled;
+ await chrome.storage.local.set({ [MEDIA_DOWNLOAD_OVERLAY_KEY]: enabled });
+
+ const tabs = await queryTabs({});
+ for (const tab of tabs) {
+ if (!tab.id || !tab.url || !/^https?:/i.test(tab.url)) {
+ continue;
+ }
+ chrome.tabs.sendMessage(tab.id, {
+ type: "media_download_overlay_set_enabled",
+ enabled,
+ }, () => {
+ const lastError = chrome.runtime.lastError;
+ if (enabled && lastError && tab.id) {
+ void injectMediaDownloadOverlay(tab.id);
+ }
+ });
+ }
+}
function taskCounters(tasks: GenericTaskSummary[]) {
return {
@@ -60,6 +105,7 @@ async function buildPopupState(options: {
token: desktopState.token,
serverUrl: desktopState.serverUrl,
interceptDownloads,
+ mediaDownloadOverlayEnabled,
tasks: desktopState.tasks,
taskCounters: taskCounters(desktopState.tasks),
tabId: resolvedTabId,
@@ -73,16 +119,22 @@ async function buildPopupState(options: {
async function initialize() {
const localState = await localStorageGet<{
[INTERCEPT_DOWNLOADS_KEY]: boolean;
+ [MEDIA_DOWNLOAD_OVERLAY_KEY]: boolean;
}>({
[INTERCEPT_DOWNLOADS_KEY]: true,
+ [MEDIA_DOWNLOAD_OVERLAY_KEY]: true,
});
interceptDownloads = Boolean(localState[INTERCEPT_DOWNLOADS_KEY] ?? true);
+ mediaDownloadOverlayEnabled = Boolean(localState[MEDIA_DOWNLOAD_OVERLAY_KEY] ?? true);
await desktopBridge.loadPersistentState();
await resourceBridge.loadPersistentState();
await featureBridge.loadPersistentState();
- await resourceBridge.resolveActiveTabId();
+ const activeTabId = await resourceBridge.resolveActiveTabId();
+ if (activeTabId != null) {
+ void injectMediaDownloadOverlay(activeTabId);
+ }
if (desktopBridge.buildSnapshot().token) {
void desktopBridge.connect();
@@ -109,17 +161,25 @@ chrome.storage.onChanged.addListener((changes, areaName) => {
if (changes[INTERCEPT_DOWNLOADS_KEY]) {
interceptDownloads = Boolean(changes[INTERCEPT_DOWNLOADS_KEY].newValue ?? true);
}
+ if (changes[MEDIA_DOWNLOAD_OVERLAY_KEY]) {
+ mediaDownloadOverlayEnabled = Boolean(changes[MEDIA_DOWNLOAD_OVERLAY_KEY].newValue ?? true);
+ }
});
chrome.tabs.onActivated.addListener((activeInfo) => {
void resourceBridge.setLastActiveTab(activeInfo.tabId);
+ void injectMediaDownloadOverlay(activeInfo.tabId);
});
chrome.windows.onFocusChanged.addListener((windowId) => {
if (windowId === chrome.windows.WINDOW_ID_NONE) {
return;
}
- void resourceBridge.refreshActiveTabFromBrowser();
+ void resourceBridge.refreshActiveTabFromBrowser().then((tabId) => {
+ if (tabId != null) {
+ void injectMediaDownloadOverlay(tabId);
+ }
+ });
});
chrome.tabs.onRemoved.addListener((tabId) => {
@@ -250,6 +310,13 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
})());
}
+ if (message.type === "popup_set_media_download_overlay") {
+ return reply(sendResponse, (async () => {
+ await syncMediaDownloadOverlay(Boolean(message.enabled));
+ return buildPopupState({ currentView: message.view as PopupView | undefined });
+ })());
+ }
+
if (message.type === "popup_task_action") {
return reply(sendResponse, (async () => {
try {
@@ -280,6 +347,25 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
})());
}
+ if (message.type === "page_download_media") {
+ return reply(sendResponse, (async () => {
+ const result = await resourceBridge.downloadPageMedia(sender, {
+ url: String(message.url ?? ""),
+ href: String(message.href ?? ""),
+ filename: String(message.filename ?? ""),
+ });
+ if (result.ok) {
+ await openActionPopup();
+ }
+ return result;
+ })());
+ }
+
+ if (message.type === "page_media_overlay_state") {
+ sendResponse({ enabled: mediaDownloadOverlayEnabled });
+ return;
+ }
+
if (message.type === "popup_toggle_feature") {
return reply(sendResponse, (async () => {
const tabId = typeof message.tabId === "number" ? message.tabId : null;
diff --git a/browser_extension/app/src/background/constants.ts b/browser_extension/app/src/background/constants.ts
index d0c6f135..1c6a2dfa 100644
--- a/browser_extension/app/src/background/constants.ts
+++ b/browser_extension/app/src/background/constants.ts
@@ -11,6 +11,7 @@ export const MAIN_FRAME_ID = 0;
export const PAIR_TOKEN_KEY = "pairToken";
export const SERVER_URL_KEY = "desktopServerUrl";
export const INTERCEPT_DOWNLOADS_KEY = "interceptDownloads";
+export const MEDIA_DOWNLOAD_OVERLAY_KEY = "mediaDownloadOverlayEnabled";
export const FEATURE_TAB_STATE_KEY = "featureTabState";
export const BRIDGE_RESOURCE_CACHE_KEY = "bridgeResourceCacheByTab";
diff --git a/browser_extension/app/src/background/resource-bridge.ts b/browser_extension/app/src/background/resource-bridge.ts
index 7a50eae5..38ae50db 100644
--- a/browser_extension/app/src/background/resource-bridge.ts
+++ b/browser_extension/app/src/background/resource-bridge.ts
@@ -1,6 +1,8 @@
import type { CapturedResource, DesktopRequestResult, PopupStatePayload } from "../shared/types";
import {
+ canUseOnlineMerge,
canUseOnlineMergeSelection,
+ describeResource,
domainFromUrl,
fileExtension,
filenameFromUrl,
@@ -526,6 +528,26 @@ export function createResourceBridge(options: {
return sortResources(result);
}
+ function tabMediaResources(tabId: number): CapturedResource[] {
+ return sortResources(resourceCache.get(tabId)?.values() ?? [])
+ .filter((resource) => /^https?:/i.test(resource.url) && canUseOnlineMerge(resource));
+ }
+
+ function canSendOneClickResource(resource: CapturedResource): boolean {
+ const hint = describeResource(resource).parserHint;
+ return hint === "m3u8" || hint === "mpd" || resource.size > 0 || resource.supportsRange;
+ }
+
+ function recentAudioVideoPair(resources: CapturedResource[]): CapturedResource[] {
+ const recentResources = resources.filter((resource) => Date.now() - resource.capturedAt <= 120000);
+ const video = recentResources.find((resource) => describeResource(resource).category === "video");
+ const audio = recentResources.find((resource) => describeResource(resource).category === "audio");
+ if (!video || !audio || Math.abs(video.capturedAt - audio.capturedAt) > 30000) {
+ return [];
+ }
+ return canUseOnlineMergeSelection([video, audio]) ? [video, audio] : [];
+ }
+
function deriveMergeOutputTitle(resources: CapturedResource[]): string {
const pageTitle = String(resources[0]?.pageTitle || "").trim();
if (pageTitle) {
@@ -817,6 +839,42 @@ export function createResourceBridge(options: {
}
}
+ async function downloadPageMedia(sender: chrome.runtime.MessageSender, payload: BridgeResourcePayload): Promise<DesktopRequestResult> {
+ const tabId = await resolveBridgeResourceTabId(sender, payload.href);
+ if (!tabId) {
+ return { ok: false, message: "当前没有可操作的标签页" };
+ }
+
+ const exactResource = payload.url ? findResourceByUrl(payload.url) : null;
+ if (exactResource?.tabId === tabId && canSendOneClickResource(exactResource)) {
+ return sendResource(exactResource.id);
+ }
+
+ const candidates = tabMediaResources(tabId).filter(canSendOneClickResource);
+ const streamResource = candidates.find((resource) => {
+ const hint = describeResource(resource).parserHint;
+ return hint === "m3u8" || hint === "mpd";
+ });
+ if (streamResource) {
+ return sendResource(streamResource.id);
+ }
+
+ const pair = recentAudioVideoPair(candidates);
+ if (pair.length === 2) {
+ return mergeResources(pair.map((resource) => resource.id));
+ }
+
+ if (candidates.length === 1) {
+ return sendResource(candidates[0].id);
+ }
+
+ await openActionPopup();
+ return {
+ ok: false,
+ message: candidates.length > 1 ? "找到多个媒体资源,请在资源嗅探页选择" : "尚未捕获到可下载媒体资源",
+ };
+ }
+
async function mergeResources(resourceIds: string[]): Promise<DesktopRequestResult> {
const ids = [...new Set(resourceIds.map((value) => String(value || "")).filter(Boolean))];
const resources = ids
@@ -924,6 +982,7 @@ export function createResourceBridge(options: {
captureNetworkResource,
capturePageResource,
captureRequestResource,
+ downloadPageMedia,
handoffBrowserDownload,
handleNavigationCommitted,
handleRequestHeaders,
diff --git a/browser_extension/app/src/popup/App.tsx b/browser_extension/app/src/popup/App.tsx
index 15450537..7b6b0e72 100644
--- a/browser_extension/app/src/popup/App.tsx
+++ b/browser_extension/app/src/popup/App.tsx
@@ -44,9 +44,12 @@ export function App({
currentView={currentView}
connectionState={bridge.connectionState}
connectionMessage={bridge.connectionMessage}
+ mediaDownloadOverlayEnabled={bridge.mediaDownloadOverlayEnabled}
+ mediaDownloadOverlayBusy={bridge.isUpdatingMediaDownloadOverlay}
interceptEnabled={bridge.interceptDownloads}
interceptBusy={bridge.isUpdatingIntercept}
onViewChange={setCurrentView}
+ onMediaDownloadOverlayToggle={(enabled) => void bridge.setMediaDownloadOverlay(enabled)}
onInterceptToggle={(enabled) => void bridge.setInterceptDownloads(enabled)}
/>
diff --git a/browser_extension/app/src/popup/components/Header.tsx b/browser_extension/app/src/popup/components/Header.tsx
index e508347c..1485bfe3 100644
--- a/browser_extension/app/src/popup/components/Header.tsx
+++ b/browser_extension/app/src/popup/components/Header.tsx
@@ -36,6 +36,12 @@ const useStyles = makeStyles({
paddingLeft: "16px",
paddingRight: "16px",
},
+ switches: {
+ display: "flex",
+ alignItems: "center",
+ gap: "12px",
+ whiteSpace: "nowrap",
+ },
divider: {
width: "100%",
marginTop: "8px",
@@ -56,17 +62,23 @@ export function Header({
currentView,
connectionState,
connectionMessage,
+ mediaDownloadOverlayEnabled,
+ mediaDownloadOverlayBusy,
interceptEnabled,
interceptBusy,
onViewChange,
+ onMediaDownloadOverlayToggle,
onInterceptToggle,
}: {
currentView: PopupView;
connectionState: DesktopConnectionState;
connectionMessage: string;
+ mediaDownloadOverlayEnabled: boolean;
+ mediaDownloadOverlayBusy?: boolean;
interceptEnabled: boolean;
interceptBusy?: boolean;
onViewChange: (view: PopupView) => void;
+ onMediaDownloadOverlayToggle: (enabled: boolean) => void;
onInterceptToggle: (enabled: boolean) => void;
}) {
const styles = useStyles();
@@ -98,13 +110,22 @@ export function Header({
<div className={styles.bottomRow}>
<ConnectionStatusBadge state={connectionState} message={connectionMessage} />
- <Switch
- checked={interceptEnabled}
- disabled={interceptBusy}
- label="拦截下载"
- labelPosition="before"
- onChange={(_event, data: SwitchOnChangeData) => onInterceptToggle(Boolean(data.checked))}
- />
+ <div className={styles.switches}>
+ <Switch
+ checked={mediaDownloadOverlayEnabled}
+ disabled={mediaDownloadOverlayBusy}
+ label="下载此媒体"
+ labelPosition="before"
+ onChange={(_event, data: SwitchOnChangeData) => onMediaDownloadOverlayToggle(Boolean(data.checked))}
+ />
+ <Switch
+ checked={interceptEnabled}
+ disabled={interceptBusy}
+ label="拦截下载"
+ labelPosition="before"
+ onChange={(_event, data: SwitchOnChangeData) => onInterceptToggle(Boolean(data.checked))}
+ />
+ </div>
</div>
<Divider className={styles.divider} />
</header>
diff --git a/browser_extension/app/src/popup/hooks/usePopupBridge.ts b/browser_extension/app/src/popup/hooks/usePopupBridge.ts
index 4652fe66..5bb00fe7 100644
--- a/browser_extension/app/src/popup/hooks/usePopupBridge.ts
+++ b/browser_extension/app/src/popup/hooks/usePopupBridge.ts
@@ -65,6 +65,7 @@ function createEmptyPayload(): PopupStatePayload {
token: "",
serverUrl: "",
interceptDownloads: true,
+ mediaDownloadOverlayEnabled: true,
tasks: [],
taskCounters: { total: 0, active: 0, completed: 0 },
resourceState: "restoring",
@@ -160,6 +161,7 @@ export function usePopupBridge(activeView: PopupView) {
const [isSavingServerUrl, setIsSavingServerUrl] = useState(false);
const [isRefreshingConnection, setIsRefreshingConnection] = useState(false);
const [isUpdatingIntercept, setIsUpdatingIntercept] = useState(false);
+ const [isUpdatingMediaDownloadOverlay, setIsUpdatingMediaDownloadOverlay] = useState(false);
const [isUpdatingMedia, setIsUpdatingMedia] = useState(false);
const mountedRef = useRef(true);
@@ -356,6 +358,26 @@ export function usePopupBridge(activeView: PopupView) {
[applyPopupState, requestPopupState, setFlash],
);
+ const setMediaDownloadOverlay = useCallback(
+ async (enabled: boolean) => {
+ setIsUpdatingMediaDownloadOverlay(true);
+ try {
+ const next = await requestPopupState({
+ type: "popup_set_media_download_overlay",
+ enabled,
+ });
+ applyPopupState(next);
+ } catch (error) {
+ setFlash(getErrorMessage(error, "更新下载按钮失败"), "error");
+ } finally {
+ if (mountedRef.current) {
+ setIsUpdatingMediaDownloadOverlay(false);
+ }
+ }
+ },
+ [applyPopupState, requestPopupState, setFlash],
+ );
+
const performTaskAction = useCallback(
async (taskId: string, action: TaskAction) => {
updateBusyState(setBusyTaskIds, taskId, true);
@@ -551,11 +573,13 @@ export function usePopupBridge(activeView: PopupView) {
isSavingServerUrl,
isRefreshingConnection,
isUpdatingIntercept,
+ isUpdatingMediaDownloadOverlay,
isUpdatingMedia,
saveToken,
saveServerUrl,
refreshConnection,
setInterceptDownloads,
+ setMediaDownloadOverlay,
performTaskAction,
sendResource,
mergeResources,
diff --git a/browser_extension/app/src/shared/types.ts b/browser_extension/app/src/shared/types.ts
index 58d8c691..c06ab511 100644
--- a/browser_extension/app/src/shared/types.ts
+++ b/browser_extension/app/src/shared/types.ts
@@ -98,6 +98,7 @@ export interface PopupStatePayload {
token: string;
serverUrl: string;
interceptDownloads: boolean;
+ mediaDownloadOverlayEnabled: boolean;
tasks: GenericTaskSummary[];
taskCounters: TaskCounters;
resourceState: ResourceCollectionState;