Skip to content

Instantly share code, notes, and snippets.

@n0samu
Created October 17, 2022 09:47
Show Gist options
  • Select an option

  • Save n0samu/9cf15d253103ec29cbcb39d3c57526c4 to your computer and use it in GitHub Desktop.

Select an option

Save n0samu/9cf15d253103ec29cbcb39d3c57526c4 to your computer and use it in GitHub Desktop.

Revisions

  1. n0samu created this gist Oct 17, 2022.
    22 changes: 22 additions & 0 deletions tangoandchaos-bookmarklet.js
    Original 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);