Video Download Button

This script adds a download button on many video sites.

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

  1. // ==UserScript==
  2. // @name Video Download Button
  3. // @namespace VDBMB
  4. // @author MegaByte
  5. // @description This script adds a download button on many video sites.
  6. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  7. // @run-at document-end
  8. // @noframes
  9. // @include http*://*streamcloud.eu/*
  10. // @include http*://*powerwatch.pw/*
  11. // @include http*://*vivo.sx/*
  12. // @include http*://*shared.sx/*
  13. // @version 1.0
  14. // @grant GM_addStyle
  15. // ==/UserScript==
  16.  
  17.  
  18. var site = window.location.href || document.URL;
  19.  
  20. if(site.includes("streamcloud.eu")) streamcloud();
  21. else if(site.includes("powerwatch.pw")) powerwatch();
  22. else if(site.includes("vivo.sx")) vivo();
  23. else if(site.includes("shared.sx")) shared();
  24.  
  25. function streamcloud() {
  26. if($("#player_code").length === 0) return;
  27. var url = searchInScripts("file:\\s?\"https?:\\/\\/.+?\\.mp4\"", "http", ".mp4");
  28. if(url !== null)
  29. $(".container-fluid ul.nav").prepend("<li>" + button(url) + "</li>");
  30. }
  31.  
  32. function powerwatch() {
  33. if($("#vplayer").length === 0) return;
  34. var url = searchInScripts("file:\\s?\"https?:\\/\\/.+?\\.mp4\"", "http", ".mp4");
  35. if(url !== null) {
  36. $("h5.h4-fine").html("<span class='head'>"+$("h5.h4-fine").html()+"</span><span class='down'>" + button(url) + "</span>")
  37. GM_addStyle("h5.h4-fine { display: flex; } h5.h4-fine .head { flex-grow: 1; } h5.h4-fine .down { flex-grow: 0; }");
  38. }
  39. }
  40.  
  41. function vivo() {
  42. var e = $(".stream-content");
  43. if(e.length === 0) return;
  44. var url = e.attr("data-url");
  45. if(typeof url === "undefined") return;
  46. $(".light-switch.btn").parent().prepend("<div class='light-switch btn btn-info download'>" + button(url) + "</div>");
  47. GM_addStyle(".download.light-switch { margin-right: 15px; } .download.light-switch a { text-decoration: none; color: white; }");
  48. }
  49.  
  50. function shared() {
  51. var e = $(".stream-content");
  52. if(e.length === 0) return;
  53. var url = e.attr("data-url");
  54. if(typeof url === "undefined") return;
  55. $(".light-switch").parent().prepend("<div class='download'>" + button(url) + "</div>");
  56. 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;}");
  57. }
  58.  
  59. function searchInScripts(patt, start, end) {
  60. var url = null;
  61. $("body script").each(function() {
  62. var regex = new RegExp(patt);
  63. var out = regex.exec($(this).html());
  64. if(typeof out !== "undefined" && out !== "" && out !== null) {
  65. if(typeof out !== "string") out = out[0];
  66. var s = out.indexOf(start);
  67. var e = out.lastIndexOf(end);
  68. if( s!==-1 && e!==-1 ) url = out.substring(s, e);
  69. return false;
  70. }
  71. });
  72. return url;
  73. }
  74.  
  75. function button(url) {
  76. return "<a href='" + url + "' download target='_blank'>Download</a>";
  77. }