Skip to content

Instantly share code, notes, and snippets.

@tony-tripulca
Created October 22, 2023 05:04
Show Gist options
  • Save tony-tripulca/51bcfd86c273d9b48d4af7cf7fa3fbbd to your computer and use it in GitHub Desktop.
Save tony-tripulca/51bcfd86c273d9b48d4af7cf7fa3fbbd to your computer and use it in GitHub Desktop.
Get Media
javascript:(function () {
let video = document.querySelector("video.vjs-tech");
let title = document.title;
let timestamp = new Date().getTime();
let xhr = new XMLHttpRequest();
xhr.open("GET", video.src, true);
xhr.responseType = "blob";
xhr.onload = function () {
let urlCreator = window.URL || window.webkitURL;
let imageUrl = urlCreator.createObjectURL(this.response);
let tag = document.createElement("a");
tag.href = imageUrl;
tag.target = "_blank";
tag.download = `${timestamp} ${title}.mp4`;
document.body.appendChild(tag);
tag.click();
document.body.removeChild(tag);
};
xhr.onerror = (err) => {
alert("Failed to download picture");
};
xhr.send();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment