// ==UserScript== // @name Video Download Button // @namespace VDBMB // @author MegaByte // @description This script adds a download button on many video sites. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js // @run-at document-end // @noframes // @include http*://*streamcloud.eu/* // @include http*://*powerwatch.pw/* // @include http*://*vivo.sx/* // @include http*://*shared.sx/* // @include http*://*youtube.com/watch?v=* // @version 1.2 // @grant GM_addStyle // @downloadURL none // ==/UserScript== function main() { var site = window.location.href || document.URL; if(site.includes("streamcloud.eu")) streamcloud(); else if(site.includes("powerwatch.pw")) powerwatch(); else if(site.includes("vivo.sx")) vivo(); else if(site.includes("shared.sx")) shared(); else if(site.includes("youtube.com")) youtube(); } function streamcloud() { if($("#player_code").length === 0) return; var url = searchInScripts("file:\\s?\"https?:\\/\\/.+?\\.mp4\"", "http", ".mp4"); if(url !== null) $(".container-fluid ul.nav").prepend("
  • " + button(url) + "
  • "); } function powerwatch() { if($("#vplayer").length === 0) return; var url = searchInScripts("file:\\s?\"https?:\\/\\/.+?\\.mp4\"", "http", ".mp4"); if(url !== null) { $("h5.h4-fine").html(""+$("h5.h4-fine").html()+"" + button(url) + "") GM_addStyle("h5.h4-fine { display: flex; } h5.h4-fine .head { flex-grow: 1; } h5.h4-fine .down { flex-grow: 0; }"); } } function vivo() { var e = $(".stream-content"); if(e.length === 0) return; var url = e.attr("data-url"); if(typeof url === "undefined") return; $(".light-switch.btn").parent().prepend("
    " + button(url) + "
    "); GM_addStyle(".download.light-switch { margin-right: 15px; } .download.light-switch a { text-decoration: none; color: white; }"); } function shared() { var e = $(".stream-content"); if(e.length === 0) return; var url = e.attr("data-url"); if(typeof url === "undefined") return; $(".light-switch").parent().prepend("
    " + button(url) + "
    "); GM_addStyle(".addthis_toolbox { width: unset !important; } .download { position: relative; background-color: #FF6550; color: #FFF; float: right; font-size: 13px; font-weight: 700; height: 32px; line-height: 32px; margin: 0 0 0 10px; padding: 0 15px; width: auto; cursor: pointer; -webkit-transition: all .35s ease-in; -moz-transition: all .35s ease-in; -o-transition: all .35s ease-in; transition: all .35s ease-in; opacity: 1; z-index: 300; } .download a { text-decoration: none; color: white;}"); } function youtube() { $("script").each(function() { var cont = decodeURI($(this).html()); if(!cont.includes("\"adaptive_fmts\":")) return; cont = cont.replace(",", "\\u0026"); var data = cont.split("\\u0026"); var format = []; var vid = {}; for(var dat of data) { var tmp = dat.split("="); var name = tmp[0]; var val = tmp[1]; if("|type|quality_label|url|fps|".includes("|"+name+"|")) { if(name === "url" || name === "type") val = decodeURIComponent(val); if(name === "type") val = val.substring(0, val.indexOf(";")); if(name in vid) { if(("url" in vid) && ("type" in vid)) format.push(vid); vid = {}; } else vid[name] = val; } } for(var t of format) console.log(t); var links = ""; for(var t of format) links += "
  • " + t["type"] + "|" + t["quality_label"] + "
  • "; $("#watch8-secondary-actions").prepend(""); GM_addStyle(".download-link { text-decoration: none; color: inherit; } .download-link:hover { text-decoration: none; }"); }); } function searchInScripts(patt, start, end) { var url = null; $("body script").each(function() { var regex = new RegExp(patt); var out = regex.exec($(this).html()); if(typeof out !== "undefined" && out !== "" && out !== null) { if(typeof out !== "string") out = out[0]; var s = out.indexOf(start); var e = out.lastIndexOf(end); if( s!==-1 && e!==-1 ) url = out.substring(s, e); return false; } }); return url; } function button(url) { return "Download"; } main();