misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux
Rust bittorrent-clientdebriddownload-acceleratordownload-managerdownloadmanagereguifile-downloadergallery-dlidmidm-alternativeinternet-download-managerm3u8-downloadermagnetplaylist-downloaderreal-debridrusttorrent-clientvideo-downloaderyoutube-downloaderyt-dlp
Video button: kept over a hover-to-play preview the page stops (#503) (#524)
Ahmed Nefzaouiab7520f7e6bb
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 055ceffb..a3569909 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -11,6 +11,7 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see### Fixed+- The browser's **video button** over a hover-to-play preview (YouTube's thumbnails) no longer vanishes as the pointer goes to it: it stays where it was while the pointer is on it, a click downloads that video, and it fades once the pointer leaves ([#503](https://github.com/anefzaoui/misterdownloadmanager/issues/503)).- **Enter new address to download**: an address with a login in **Options → Sites Logins** shows that login under **Use authorization** (ticked, the user name and the password), the one the download uses; it was used but the box stayed empty. A login typed there still goes first ([#511](https://github.com/anefzaoui/misterdownloadmanager/issues/511)).- The window no longer waits for the disk to write MDM's log or to save the RSS feeds: while Windows held every write on the disk to make a snapshot of it (a restore point or a backup), the window could stop answering until the writes were let go. Both are now written beside the window, as the download list already was (part of [#513](https://github.com/anefzaoui/misterdownloadmanager/issues/513)).- Windows: video and gallery look-ups no longer fail with "[WinError 448] The path cannot be traversed because it contains an untrusted mount point" when a folder on PATH goes through a junction Windows won't let yt-dlp cross (one an app installed for itself, Codex's for example): yt-dlp, gallery-dl and the ffmpeg they start get that folder's real place instead, and no folder that can't be opened ([#508](https://github.com/anefzaoui/misterdownloadmanager/issues/508)).diff --git a/ROADMAP.md b/ROADMAP.mdindex eafbffc3..60c8040a 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -520,6 +520,8 @@ These ship in a later version, when they're ready.### Bugs being looked into+- 🔄 The video button vanishing over a hover-to-play preview (YouTube's thumbnails) before it+ can be clicked ([#503](https://github.com/anefzaoui/misterdownloadmanager/issues/503)): fix in review- 🔄 Add URL's **Use authorization** empty for an address with a login in Options → SitesLogins, though the download used it([#511](https://github.com/anefzaoui/misterdownloadmanager/issues/511)): fix in reviewdiff --git a/extension/video.js b/extension/video.jsindex dc35d72d..89d69030 100644--- a/extension/video.js+++ b/extension/video.js@@ -136,6 +136,15 @@let auto = { v: null, at: null, t: 0 }; // the spot found for this video, kept for a momentconst AUTO_MS = 400;let video = null; // the video it is over+ // A video gone from under its button (#503): a hover-to-play preview (YouTube's thumbnails)+ // stops as soon as the pointer leaves it for the button, since the page sees the pointer go.+ // The button stays where it was, for that video, while the pointer is on it (or its menu is+ // open), or for HOLD_MS while the pointer is still over where the video was, on its way to it;+ // a click downloads what the video was playing.+ let held = null; // { r: the video's last rectangle, at: the button's spot, d: what download sends, since }+ const HOLD_MS = 1500;+ let lastRect = null; // the video's rectangle when the button was last placed over it+ let entered = null; // what download would send, taken as the pointer reached the button: { v, d, t }let lastMove = 0;let pointer = { x: -1, y: -1 };let menuOpen = false;@@ -315,7 +324,7 @@ button:focus-visible { outline: 2px solid #2a78d6; outline-offset: -2px; }// `place` is where it sits in the room the video leaves around it: x and y from 0 to 1, one of// them 0 or 1 (on an edge).function rects() {- const r = video.getBoundingClientRect();+ const r = held ? held.r : (lastRect = video.getBoundingClientRect());const w = pill.offsetWidth || 150;const h = pill.offsetHeight || 32;return { r, w, h, roomX: Math.max(0, r.width - w - 2 * INSET), roomY: Math.max(0, r.height - h - 2 * INSET) };@@ -371,7 +380,9 @@ button:focus-visible { outline: 2px solid #2a78d6; outline-offset: -2px; }const { r, w, roomX, roomY } = rects();// A narrow video gets the icon only.pill.classList.toggle("compact", r.width < 360);- const at = dragging ? dragging.at : spot(r, w, pill.offsetHeight || 32, roomX, roomY);+ // Held for a video gone (#503): where it was, not a corner found anew over what the page+ // shows there now.+ const at = dragging ? dragging.at : held && !chosen ? held.at : spot(r, w, pill.offsetHeight || 32, roomX, roomY);const left = r.left + INSET + at.x * roomX;// In the part of the video on screen: one scrolled half out keeps its button in view.const h = pill.offsetHeight || 32;@@ -419,6 +430,7 @@ button:focus-visible { outline: 2px solid #2a78d6; outline-offset: -2px; }function show(v) {if (video !== v) {video = v;+ held = null;closeMenu();}if (!attach()) return hide(true);@@ -432,6 +444,7 @@ button:focus-visible { outline: 2px solid #2a78d6; outline-offset: -2px; }function hide(now) {if (!now && (menuOpen || dragging || keyboardOn())) return;if (now) {+ held = null;closeMenu();shadow.activeElement?.blur();}@@ -444,17 +457,50 @@ button:focus-visible { outline: 2px solid #2a78d6; outline-offset: -2px; }}, now || reduced ? 0 : 180);}+ // What the button sends for `v` (its rectangle `r`): see `download`.+ function describe(v, r) {+ return {+ drm: Boolean(v.mediaKeys),+ src: /^https?:/i.test(v.currentSrc || "") ? v.currentSrc : "",+ url: videoPage(v),+ // The middle of the video: where the background asks the page's own player what it plays.+ at: { x: r.left + r.width / 2, y: r.top + r.height / 2 },+ };+ }++ // The video just went from under the button (#503): what it was, kept. What was taken as the+ // pointer reached the button, when that was a moment ago; else the video as it is now.+ function hold() {+ const now = Date.now();+ const d = entered && entered.v === video && now - entered.t < 1000 ? entered.d : describe(video, lastRect);+ return { r: lastRect, at: chosen ? place : (auto.v === video && auto.at) || place, d, since: now };+ }+// While shown: follow the video (scrolling, layout) and fade when the pointer rests.function tick() {raf = 0;- if (!video || !video.isConnected || !eligible(video)) {- video = null;- return hide(true);+ if (!video) return hide(true);+ const onButton = root.matches(":hover");+ if (!video.isConnected || !eligible(video)) {+ if (!held && lastRect && !isDismissed(video)) held = hold();+ const r = held && held.r;+ const over =+ r && pointer.x >= r.left && pointer.x <= r.right && pointer.y >= r.top && pointer.y <= r.bottom;+ if (!held || !(onButton || menuOpen || dragging || keyboardOn() || (over && Date.now() - held.since < HOLD_MS))) {+ const was = held;+ held = null;+ video = null;+ // Left after it was held: it fades, as when the pointer leaves a video.+ return was ? hide() : hide(true);+ }+ position();+ raf = requestAnimationFrame(tick);+ return;}+ held = null;const r = video.getBoundingClientRect();const over =pointer.x >= r.left && pointer.x <= r.right && pointer.y >= r.top && pointer.y <= r.bottom;- const onButton = root.matches(":hover");if (!onButton && !menuOpen && !dragging && !keyboardOn() && (!over || Date.now() - lastMove > IDLE_MS)) {return hide();}@@ -502,17 +548,15 @@ button:focus-visible { outline: 2px solid #2a78d6; outline-offset: -2px; }busy = true;try {closeMenu();+ // Asked now, not kept: one <video> plays many videos at the same address (a feed's+ // previews). A video gone from under the button: what it played then (#503).+ const { drm, src, url, at } = held ? held.d : describe(video, video.getBoundingClientRect());// Encrypted (DRM): no tool can save it; say so rather than send it.- if (video.mediaKeys) return flash("err", t("video_drm"));- const src = /^https?:/i.test(video.currentSrc || "") ? video.currentSrc : "";+ if (drm) return flash("err", t("video_drm"));// A page that moved in place keeps its first page's og:title; its document title follows.const og = location.href === landedAt ? document.querySelector('meta[property="og:title"]')?.content : "";const title = (og || document.title || "").trim();- // The middle of the video: where the background asks the page's own player what it plays.- const box = video.getBoundingClientRect();- const at = { x: box.left + box.width / 2, y: box.top + box.height / 2 };- // Asked now, not kept: one <video> plays many videos at the same address (a feed's previews).- const r = await send({ type: "video", src, title, url: videoPage(video), at });+ const r = await send({ type: "video", src, title, url, at });if (r.gone) return;flash(r.ok ? "ok" : "err", t(r.ok ? "video_sent" : r.why === "options" ? "video_off" : r.why === "unnamed" ? "video_unnamed" : "video_failed"));} finally {@@ -561,6 +605,7 @@ button:focus-visible { outline: 2px solid #2a78d6; outline-offset: -2px; }if (act === "download") return download();closeMenu();if (act === "hide") {+ held = null;dismissed.add(video);if (video.currentSrc) dismissedSrc.add(video.currentSrc);video = null;@@ -577,6 +622,14 @@ button:focus-visible { outline: 2px solid #2a78d6; outline-offset: -2px; }more.addEventListener("click", () => (menuOpen ? closeMenu() : openMenu()));+ // The pointer reached the button: what the video plays now, kept in case the page stops it for+ // that (a hover-to-play preview, #503).+ root.addEventListener("pointerenter", () => {+ if (video && !held && video.isConnected && eligible(video)) {+ entered = { v: video, d: describe(video, video.getBoundingClientRect()), t: Date.now() };+ }+ });+// Keys: Escape closes the menu, arrows move through it.shadow.addEventListener("keydown", (e) => {if (e.key === "Escape" && menuOpen) {diff --git a/tools/extension/e2e.mjs b/tools/extension/e2e.mjsindex 450e321a..8cd0a030 100644--- a/tools/extension/e2e.mjs+++ b/tools/extension/e2e.mjs@@ -17,7 +17,8 @@// do with each new type, as Waterfox is: caught before its dialog, #208), cookie (cookies and referrer// forwarded), names (Content-Disposition), redirect, leadon (a page going to the file by script, #374), form (POST, 303), alt (Alt+click leaves it// to the browser), opened (a PDF or MP3 the browser would show or play), spot (the video button-// clear of the page's controls, #421), csp (the video button+// clear of the page's controls, #421), preview (the video button kept over a hover-to-play+// preview the page stopped as the pointer went to it, #503), csp (the video button// under a strict CSP), hls (the stream a player loaded), streams (HLS and DASH players handed over// by the button, the right-click menu and the media list, and read by yt-dlp; #155; also with no// .m3u8 or .mpd, served as text/plain or octet-stream, #171), sniffed (#171 without yt-dlp: such@@ -223,6 +224,8 @@ async function chromium(bin, profile, dl, page, ready) {"--ignore-certificate-errors",// Linux: no keyring prompt for the test profile....(WIN ? [] : ["--password-store=basic"]),+ // E2E_CHROMIUM_ARGS: more switches, space separated (screenshots: --lang=de, --force-dark-mode).+ ...(process.env.E2E_CHROMIUM_ARGS || "").split(" ").filter(Boolean),"about:blank",],{ env: process.env, stdio: ["ignore", "ignore", "ignore", "pipe", "pipe"], windowsHide: true },@@ -1671,6 +1674,51 @@ const CASES = {return `at ${Math.round(b.l - v.l)},${Math.round(b.t - v.t)}, clear of the page's control`;},+ // #503: a hover-to-play preview (YouTube's thumbnails) stops as soon as the pointer leaves the+ // video for the button, the page seeing the pointer go: hidden, or taken out of the page. The+ // button stays where it was while the pointer is on it, a click sends the video it was over,+ // and it fades once the pointer leaves.+ async preview(t) {+ // E2E_PREVIEW_SHOT: screenshots of the page with the preview stopped, for a PR's body.+ const shoot = async (name) => {+ if (process.env.E2E_PREVIEW_SHOT && t.session.screenshot) await t.session.screenshot(`${process.env.E2E_PREVIEW_SHOT}-${name}.png`);+ };+ const done = [];+ for (const stop of ["hidden", "removed"]) {+ await t.session.navigate(`${LAB}/page?video=${encodeURIComponent("/gen/1M/clip.mp4")}`);+ await t.session.evaluate(`(() => {+ const v = document.querySelector("#video");+ v.addEventListener("mouseleave", () => {+ if (${JSON.stringify(stop)} === "hidden") v.style.display = "none"; else v.remove();+ document.body.dataset.preview = "stopped";+ });+ return true;+ })()`);+ const v = await rect(t.session, "#video");+ const b = await hover(t.session, v);+ if (!b) throw new Error(`${stop}: no button over the video`);+ // Onto the button: the page stops its preview.+ await t.session.mouse(b.l + 14, (b.t + b.b) / 2);+ await until(`${stop}: the page's preview stopped`, 3000, () => t.session.evaluate(`document.body.dataset.preview === "stopped"`));+ await sleep(500);+ await shoot(stop);+ const kept = await rect(t.session, "mdm-video-button");+ if (!kept) throw new Error(`${stop}: the button went with the preview`);+ near(kept.l, b.l, `${stop}: kept, left edge`);+ near(kept.t, b.t, `${stop}: kept, top`);+ // Still there with the pointer resting on it, past the time the pointer is given to reach it.+ await sleep(2000);+ if (!(await rect(t.session, "mdm-video-button"))) throw new Error(`${stop}: the button went while the pointer rested on it`);+ const address = await clickButton(t.session, kept);+ if (address !== `${LAB}/gen/1M/clip.mp4`) throw new Error(`${stop}: the video window got ${address}`);+ // The pointer leaves: it fades, as over any video.+ await t.session.mouse(5, 5);+ await until(`${stop}: the button gone after the pointer left`, 3000, async () => !(await rect(t.session, "mdm-video-button")));+ done.push(`${stop}: kept, sent ${address.replace(LAB, "")}, gone after`);+ }+ return done.join("; ");+ },+// A player playing a stream (a blob: in the page): the button sends the manifest it loaded.async hls(t) {await t.session.navigate(`${LAB}/page?hls=1`);