Skip to content

Instantly share code, notes, and snippets.

@salif
Created June 5, 2024 17:44
Show Gist options
  • Save salif/7ba750c69d47a8a5a4434cfa0e47f45c to your computer and use it in GitHub Desktop.
Save salif/7ba750c69d47a8a5a4434cfa0e47f45c to your computer and use it in GitHub Desktop.
bookmarklet to open video in new tab/downloading
javascript:(function (w) {var vs = Array.from(w.document.body.querySelectorAll("video"));if (vs.length === 0) {w.document.querySelectorAll("iframe").forEach(vif => {vif.contentDocument?.body.querySelectorAll("video").forEach(vi => {vs.push(vi);});});};if (vs.length === 0) {w.alert("no videos!");} else {var v = vs.length === 1 ? vs[0]?.currentSrc : vs[w.Number.parseInt(w.prompt(vs.map((vv, ind) => ind + ": " + vv.currentSrc).join("\n"), "0"), 10)]?.currentSrc;if (v?.length > 0) { w.open(v, "_blank"); } else { w.alert("video src is empty!"); }};})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment