Vimeo Download

Adds a download button to the Vimeo video player. This is a rewrite of "Vimeo Embed Download" originally created by aleixdev (https://greasyfork.org/en/scripts/376551).

目前為 2023-04-03 提交的版本,檢視 最新版本

// ==UserScript==
// @name        Vimeo Download
// @namespace   http://tampermonkey.net/
// @version     2.0
// @description Adds a download button to the Vimeo video player. This is a rewrite of "Vimeo Embed Download" originally created by aleixdev (https://greasyfork.org/en/scripts/376551).
// @author      You
// @match       https://vimeo.com/*
// @icon        https://www.google.com/s2/favicons?sz=64&domain=vimeo.com
// @grant       GM_download
// ==/UserScript==
(async function() {
    'use strict';
    if (document.title === 'VimeUhOh') return;
    const clips = vimeo.clips;
    const videoId = Object.keys(clips).at();
    if (!videoId) {
        throw new Error('[Vimeo Download] Error retrieving video meta data:', vimeo);
    }
    const { request, video } = clips[videoId];
    const streams = request.files.progressive.sort((a, b) => b.width - a.width);
    console.log(streams);
    const { url, quality } = streams[0];
    const button = Object.assign(document.createElement('button'), {
        innerHTML: 'Download',
        title: 'Download ' + quality,
        style: 'display: inline-block; font-size: 1.75em; margin: -0.25em 0 0 0.3em; color: rgb(68,187,255)',
        onclick: function() {
            console.log(url, quality);
            GM_download(url, video.title.replace(/[<>:"\/\\|?*]/g, '') + '.mp4');
        }
    })
    const interval = setInterval(function() {
        if (!document.querySelector('.vp-controls')) return;
        clearInterval(interval)
        document.querySelector('.vp-controls').appendChild(button);
    }, 100);
})();