Video downloader

function downloadVideo(url) { // create a new anchor element var a = document.createElement('a'); a.href = url; a.download = url.split('/').pop(); // set the filename to the last segment of the URL // simulate a click on the anchor element to trigger the download var event = new MouseEvent('click', { view: window, bubbles: true, cancelable: true }); a.dispatchEvent(event); }

Comments