Vimeo Embedded Download Helper

find vimeo download links and display it on the embedded player

当前为 2016-06-29 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Vimeo Embedded Download Helper
// @namespace    http://tampermonkey.net/
// @version      0.1.4
// @description  find vimeo download links and display it on the embedded player
// @author       LordKBX
// @icon https://vimeo.com/favicon.ico
// @include http://*.*/*
// @include https://*.*/*
// @grant unsafeWindow
// @grant GM_addStyle
// @grant GM_getResourceText
// @grant GM_openInTab
// @grant GM_info
// @grant GM_getMetadata
// @grant GM_getMetadata
// @connect *
// @run-at document-start
// @encoding utf-8
// @license https://creativecommons.org/licenses/by-sa/4.0/
// @homepage https://greasyfork.org/fr/scripts/21002-vimeo-embedded-download-helper
// @contactURL mailto:[email protected]
// @supportURL mailto:[email protected]
// ==/UserScript==
var updateInterval = null;
var timeInterval = 800;
var nbscripts = 0;
var nbscriptsCharges = 0;

(function() {
    'use strict';
    setTimeout(verify, 2000);
})();

function verify(){
    var items = null;
    var i = 0;
    var j = 0;
    var ht = '';
    if(window.location.href.search("://player.vimeo.com/video/") != -1){
        ht = window.location.href.substring(0,window.location.href.search("://"));
        items = window.document.getElementsByTagName('script');
        if(items !== null){
            for(i = 0; i< items.length; i++){
                if(items[i].innerHTML !== ''){
                    div = document.createElement('div');
                    div.setAttribute("style","background:#ffffff;color:#000;position:fixed;top:0px;left:0px;right:0px;height:20px;z-index:999;");
                    htm = 'Video Download Links : ';
                    window.console.log(items[i].innerHTML);
                    tab = items[i].innerHTML.split('"progressive":');
                    tab2 = items[i].innerHTML.split('"text_tracks":');
                    if(tab[1] !== undefined){
                        lines = tab[1].split("]")[0]+"]";
                        lines = JSON.parse(lines);
                        for(j=0; j<lines.length; j++){
                            htm = htm + '&nbsp;<a href="'+lines[j].url+'" download="'+document.getElementsByTagName('title')[0].innerHTML+'.mp4">' + lines[j].quality + '</a>&nbsp;';
                            window.console.log(lines[j].quality + " -> " + lines[j].url);
                        }
                    if(tab2[1] !== undefined){
                        lines2 = tab2[1].split("]")[0]+"]";
                        lines2 = JSON.parse(lines2);
                        for(j=0; j<lines2.length; j++){
                            htm = htm + '&nbsp;<a href="'+lines2[j].url+'" download="'+document.getElementsByTagName('title')[0].innerHTML+'.vtt">sub(' + lines2[j].lang + ')</a>&nbsp;';
                            window.console.log('sub(' + lines2[j].lang + ')' + " -> " + lines2[j].url);
                        }
                    }
                    div.innerHTML = htm;
                    window.document.getElementsByTagName('body')[0].appendChild(div);
                    }
                    //window.console.log(items[i].innerHTML);
                }
            }
        }
    }
    else{
        /*
        items = document.querySelectorAll('iframe');
        if(items !== null){
            for(i = 0; i< items.length; i++){
                var url = (items[i].src !== undefined)?items[i].src:null;
                if(url !== null){
                    if(url.search("://") != -1){
                        ht = url.substring(0,url.search("://"));
                        if(url.search(ht+"://player.vimeo.com") != -1){
                            window.open(url, "_blank");
                        }
                    }
                }
            }
        }
        */
    }
}