Created
October 22, 2023 05:04
-
-
Save tony-tripulca/51bcfd86c273d9b48d4af7cf7fa3fbbd to your computer and use it in GitHub Desktop.
Get Media
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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