SaveTube+

Download videos from web sites.

  1. // ==UserScript==
  2. // @name SaveTube+
  3. // @version 2018.11.12
  4. // @description Download videos from web sites.
  5. // @author sebaro
  6. // @namespace http://sebaro.pro/savetube
  7. // @icon https://gitlab.com/sebaro/savetube/raw/master/savetube.png
  8. // @include *
  9. // @noframes
  10. // @grant none
  11. // @run-at document-end
  12. // ==/UserScript==
  13.  
  14.  
  15. /*
  16.  
  17. Copyright (C) 2014 - 2018 Sebastian Luncan
  18.  
  19. This program is free software: you can redistribute it and/or modify
  20. it under the terms of the GNU General Public License as published by
  21. the Free Software Foundation, either version 3 of the License, or
  22. (at your option) any later version.
  23.  
  24. This program is distributed in the hope that it will be useful,
  25. but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. GNU General Public License for more details.
  28.  
  29. You should have received a copy of the GNU General Public License
  30. along with this program. If not, see <http://www.gnu.org/licenses/>.
  31.  
  32. Website: http://sebaro.pro/savetube
  33. Contact: http://sebaro.pro/contact
  34.  
  35. */
  36.  
  37.  
  38. (function() {
  39.  
  40.  
  41. // ==========Variables========== //
  42.  
  43. // Userscript
  44. var userscript = 'SaveTube';
  45.  
  46. // Contact
  47. var contact = 'http://sebaro.pro/contact';
  48.  
  49.  
  50. // ==========Fixes========== //
  51.  
  52. // Don't run on frames or iframes
  53. if (window.top && window.top != window.self) return;
  54.  
  55.  
  56. // ==========Websites========== //
  57.  
  58. /* Page Source */
  59. var xmlHTTP = new XMLHttpRequest();
  60. xmlHTTP.open('GET', window.location.href, false);
  61. xmlHTTP.send();
  62. var source = xmlHTTP.responseText + document.getElementsByTagName('html')[0].innerHTML;
  63. if (!source) return;
  64.  
  65. /* Video Patterns */
  66. var patterns = [
  67. '=(http[^=\'"]*?\\.(mp4|flv|webm|m3u8).*?)&',
  68. 'file\s*:\s*"(http[^")]*?\\.(mp4|flv|webm|m3u8).*?)"',
  69. 'src="(http[^"]*?\\.(mp4|flv|webm|m3u8).*?)"',
  70. '"(http[^"]*?\\.(mp4|flv|webm|m3u8).*?)"',
  71. '\'(http[^\']*?\\.(mp4|flv|webm|m3u8).*?)\''
  72. ];
  73.  
  74. /* Video Matcher */
  75. var pattern, matches, matcher, video, type;
  76. var links = '';
  77. for (var i = 0; i < patterns.length; i++) {
  78. pattern = new RegExp(patterns[i], 'g');
  79. matches = source.match(pattern);
  80. if (matches) {
  81. for (var v = 0; v < matches.length; v++) {
  82. matcher = matches[v].match(patterns[i]);
  83. video = (matcher) ? matcher[1] : null;
  84. if (video) {
  85. video = video.replace(/\\/g, '');
  86. if (video.indexOf('%') != -1) video = unescape(video);
  87. if (video.indexOf('&amp;') != -1) video = video.replace(/&amp;/g, '&');
  88. if (video.indexOf('http') == 0 && !video.match(/(thumb|\.jpg|\.png|\.gif|\.htm|format=|\/\/[^\/]*?(mp4|flv|webm|m3u8))/)) {
  89. if (video.indexOf('.mp4') != -1) type = 'MP4';
  90. else if (video.indexOf('.flv') != -1) type = 'FLV';
  91. else if (video.indexOf('.webm') != -1) type = 'WebM';
  92. else if (video.indexOf('.m3u8') != -1) type = 'M3U8';
  93. else type = 'Video';
  94. if (links.indexOf(video) == -1) links += ' <a href="' + video + '" style="color:#2C72C7">' + type + '</a>';
  95. }
  96. }
  97. }
  98. }
  99. }
  100. if (links) {
  101. var panel = document.createElement('div');
  102. panel.style.position = 'fixed';
  103. panel.style.bottom = '0px';
  104. panel.style.right = '25px';
  105. panel.style.zIndex = '2000000000';
  106. panel.style.color = '#336699';
  107. panel.style.backgroundColor = '#FFFFFF';
  108. panel.style.padding = '5px 5px 10px 5px';
  109. panel.style.fontSize = '12px';
  110. panel.style.fontWeight = 'bold';
  111. panel.style.borderLeft = '3px solid #EEEEEE';
  112. panel.style.borderRight = '3px solid #EEEEEE';
  113. panel.style.borderTop = '3px solid #EEEEEE';
  114. panel.style.borderRadius = '5px 5px 0px 0px';
  115. panel.innerHTML = '<a href="' + contact + '" style="color:#336699; font-weight:bold; text-decoration:none">' + userscript + '</a>: ' + links;
  116. var button = document.createElement('div');
  117. button.innerHTML = '<';
  118. button.style.height = '12px';
  119. button.style.border = '1px solid #CCCCCC';
  120. button.style.borderRadius = '3px';
  121. button.style.padding = '0px 5px';
  122. button.style.display = 'inline';
  123. button.style.color = '#CCCCCC';
  124. button.style.fontSize = '12px';
  125. button.style.textShadow = '0px 1px 1px #CCCCCC';
  126. button.style.cursor = 'pointer';
  127. button.style.marginLeft = '10px';
  128. button.addEventListener('click', function() {
  129. if (panel.style.right == '25px') {
  130. panel.style.left = '25px';
  131. panel.style.right = 'auto';
  132. button.innerHTML = '>';
  133. }
  134. else {
  135. panel.style.left = 'auto';
  136. panel.style.right = '25px';
  137. button.innerHTML = '<';
  138. }
  139. }, false);
  140. panel.appendChild(button);
  141. document.body.appendChild(panel);
  142. }
  143.  
  144. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址