Created
October 17, 2022 09:47
-
-
Save n0samu/9cf15d253103ec29cbcb39d3c57526c4 to your computer and use it in GitHub Desktop.
Revisions
-
n0samu created this gist
Oct 17, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ function saveFile(fileUrl, mimeType) { var fileName = fileUrl.split('/').pop(); fetch(fileUrl) .then(response => response.blob()) .then(blob => { var link = window.document.createElement("a"); link.href = window.URL.createObjectURL(blob, { type: mimeType }); link.download = fileName; document.body.appendChild(link); link.click(); document.body.removeChild(link); }); } function saveVideo(videoElement) { var playerParams = new URLSearchParams(videoElement.getAttribute('flashvars')); var videoURL = new URL(playerParams.get('streamName') + '.flv', document.baseURI); saveFile(videoURL.href, 'video/x-flv'); } var videoElements = document.querySelectorAll('embed, ruffle-embed'); videoElements.forEach(saveVideo);