SaveTube

Download videos from video sharing web sites.

当前为 2015-11-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name SaveTube
  3. // @version 2015.11.24
  4. // @description Download videos from video sharing web sites.
  5. // @author sebaro
  6. // @namespace http://isebaro.com/savetube
  7. // @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
  8. // @icon http://s3.amazonaws.com/uso_ss/icon/130917/large.png
  9. // @include http://youtube.com*
  10. // @include http://www.youtube.com*
  11. // @include https://youtube.com*
  12. // @include https://www.youtube.com*
  13. // @include http://dailymotion.com*
  14. // @include http://www.dailymotion.com*
  15. // @include https://dailymotion.com*
  16. // @include https://www.dailymotion.com*
  17. // @include http://vimeo.com*
  18. // @include http://www.vimeo.com*
  19. // @include https://vimeo.com*
  20. // @include https://www.vimeo.com*
  21. // @include http://metacafe.com*
  22. // @include http://www.metacafe.com*
  23. // @include https://metacafe.com*
  24. // @include https://www.metacafe.com*
  25. // @include http://break.com*
  26. // @include http://www.break.com*
  27. // @include https://break.com*
  28. // @include https://www.break.com*
  29. // @include http://funnyordie.com*
  30. // @include http://www.funnyordie.com*
  31. // @include https://funnyordie.com*
  32. // @include https://www.funnyordie.com*
  33. // @include http://videojug.com*
  34. // @include http://www.videojug.com*
  35. // @include https://videojug.com*
  36. // @include https://www.videojug.com*
  37. // @include http://blip.tv*
  38. // @include http://www.blip.tv*
  39. // @include https://blip.tv*
  40. // @include https://www.blip.tv*
  41. // @include http://veoh.com*
  42. // @include http://www.veoh.com*
  43. // @include https://veoh.com*
  44. // @include https://www.veoh.com*
  45. // @include http://crackle.com*
  46. // @include http://www.crackle.com*
  47. // @include https://crackle.com*
  48. // @include https://www.crackle.com*
  49. // @include http://viki.com*
  50. // @include http://www.viki.com*
  51. // @include https://viki.com*
  52. // @include https://www.viki.com*
  53. // @include http://imdb.com*
  54. // @include http://www.imdb.com*
  55. // @include https://imdb.com*
  56. // @include https://www.imdb.com*
  57. // @include http://facebook.com*
  58. // @include http://www.facebook.com*
  59. // @include https://facebook.com*
  60. // @include https://www.facebook.com*
  61. // @include https://screen.yahoo.com*
  62. // @grant GM_xmlhttpRequest
  63. // @grant GM_setValue
  64. // @grant GM_getValue
  65. // ==/UserScript==
  66.  
  67.  
  68. /*
  69.  
  70. Copyright (C) 2010 - 2015 Sebastian Luncan
  71.  
  72. This program is free software: you can redistribute it and/or modify
  73. it under the terms of the GNU General Public License as published by
  74. the Free Software Foundation, either version 3 of the License, or
  75. (at your option) any later version.
  76.  
  77. This program is distributed in the hope that it will be useful,
  78. but WITHOUT ANY WARRANTY; without even the implied warranty of
  79. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  80. GNU General Public License for more details.
  81.  
  82. You should have received a copy of the GNU General Public License
  83. along with this program. If not, see <http://www.gnu.org/licenses/>.
  84.  
  85. Website: http://isebaro.com/savetube
  86. Contact: http://isebaro.com/contact
  87.  
  88. */
  89.  
  90.  
  91. (function() {
  92.  
  93.  
  94. // Don't run on frames or iframes
  95. if (window.top != window.self) return;
  96.  
  97.  
  98. // ==========Variables========== //
  99.  
  100. // Userscript
  101. var userscript = 'SaveTube';
  102.  
  103. // Page
  104. var page = {win: window, doc: document, body: document.body, url: window.location.href, site: window.location.hostname.match(/([^.]+)\.[^.]+$/)[1]};
  105.  
  106. // Saver
  107. var saver = {};
  108. var feature = {'definition': true, 'container': true, 'autoget': false};
  109. var option = {'definition': 'HD', 'container': 'MP4', 'autoget': false};
  110.  
  111. // Links
  112. var website = 'http://isebaro.com/savetube/?ln=en';
  113. var contact = 'http://isebaro.com/contact/?ln=en&sb=savetube';
  114.  
  115.  
  116. // ==========Functions========== //
  117.  
  118. function createMyElement (type, content, event, action, target) {
  119. var obj = page.doc.createElement(type);
  120. if (content) {
  121. if (type == 'div') obj.innerHTML = content;
  122. else if (type == 'option') {
  123. obj.value = content;
  124. obj.innerHTML = content;
  125. }
  126. }
  127. if (event == 'change') {
  128. if (target == 'video') {
  129. obj.addEventListener ('change', function () {
  130. saver['videoSave'] = this.value;
  131. if (feature['autoget']) {
  132. if (option['autoget']) getMyVideo();
  133. }
  134. else {
  135. modifyMyElement (saver['buttonGet'] , 'div', 'Get', false);
  136. }
  137. }, false);
  138. }
  139. }
  140. else if (event == 'click') {
  141. obj.addEventListener ('click', function () {
  142. if (action == 'close') {
  143. removeMyElement(page.body, target);
  144. }
  145. else if (action == 'logo') {
  146. page.win.location.href = website;
  147. }
  148. else if (action == 'get') {
  149. getMyVideo();
  150. }
  151. else if (action == 'autoget') {
  152. option['autoget'] = (option['autoget']) ? false : true;
  153. if (option['autoget']) {
  154. styleMyElement (saver['buttonGet'], {display: 'none'});
  155. styleMyElement (saver['buttonAutoget'], {color: '#008080', textShadow: '0px 1px 1px #CCCCCC'});
  156. getMyVideo();
  157. }
  158. else {
  159. styleMyElement (saver['buttonGet'], {display: 'inline'});
  160. styleMyElement (saver['buttonAutoget'], {color: '#CCCCCC', textShadow: '0px 0px 0px'});
  161. }
  162. setMyOptions ('autoget', option['autoget']);
  163. }
  164. else if (action == 'definition') {
  165. for (var itemDef = 0; itemDef < option['definitions'].length; itemDef++) {
  166. if (option['definitions'][itemDef].match(/[A-Z]/g).join('') == option['definition']) {
  167. var nextDef = (itemDef + 1 < option['definitions'].length) ? itemDef + 1 : 0;
  168. option['definition'] = option['definitions'][nextDef].match(/[A-Z]/g).join('');
  169. break;
  170. }
  171. }
  172. modifyMyElement (saver['buttonDefinition'], 'div', option['definition'], false);
  173. setMyOptions ('definition', option['definition']);
  174. modifyMyElement (saver['buttonGet'] , 'div', 'Get', false);
  175. selectMyVideo ();
  176. if (option['autoget']) getMyVideo();
  177. }
  178. else if (action == 'container') {
  179. for (var itemCont = 0; itemCont < option['containers'].length; itemCont++) {
  180. if (option['containers'][itemCont] == option['container']) {
  181. var nextCont = (itemCont + 1 < option['containers'].length) ? itemCont + 1 : 0;
  182. option['container'] = option['containers'][nextCont];
  183. break;
  184. }
  185. }
  186. modifyMyElement (saver['buttonContainer'], 'div', option['container'], false);
  187. setMyOptions ('container', option['container']);
  188. modifyMyElement (saver['buttonGet'] , 'div', 'Get', false);
  189. selectMyVideo ();
  190. if (option['autoget']) getMyVideo();
  191. }
  192. }, false);
  193. }
  194. return obj;
  195. }
  196.  
  197. function getMyElement (obj, type, from, value, child, content) {
  198. var getObj, chObj, coObj;
  199. var pObj = (!obj) ? page.doc : obj;
  200. if (type == 'body') getObj = pObj.body;
  201. else {
  202. if (from == 'id') getObj = pObj.getElementById(value);
  203. else if (from == 'class') getObj = pObj.getElementsByClassName(value);
  204. else if (from == 'tag') getObj = pObj.getElementsByTagName(type);
  205. else if (from == 'ns') getObj = pObj.getElementsByTagNameNS(value, type);
  206. }
  207. chObj = (child >= 0) ? getObj[child] : getObj;
  208. if (content && chObj) {
  209. if (type == 'html' || type == 'body' || type == 'div' || type == 'option') coObj = chObj.innerHTML;
  210. else if (type == 'object') coObj = chObj.data;
  211. else coObj = chObj.textContent;
  212. return coObj;
  213. }
  214. else {
  215. return chObj;
  216. }
  217. }
  218.  
  219. function modifyMyElement (obj, type, content, clear) {
  220. if (content) {
  221. if (type == 'div') obj.innerHTML = content;
  222. else if (type == 'option') {
  223. obj.value = content;
  224. obj.innerHTML = content;
  225. }
  226. }
  227. if (clear) {
  228. if (obj.hasChildNodes()) {
  229. while (obj.childNodes.length >= 1) {
  230. obj.removeChild(obj.firstChild);
  231. }
  232. }
  233. }
  234. }
  235.  
  236. function styleMyElement (obj, styles) {
  237. for (var property in styles) {
  238. if (styles.hasOwnProperty(property)) obj.style[property] = styles[property];
  239. }
  240. }
  241.  
  242. function appendMyElement (parent, child) {
  243. parent.appendChild(child);
  244. }
  245.  
  246. function removeMyElement (parent, child) {
  247. parent.removeChild(child);
  248. }
  249.  
  250. function replaceMyElement (parent, orphan, child) {
  251. parent.replaceChild(orphan, child);
  252. }
  253.  
  254. function createMySaver () {
  255. /* Get My Options */
  256. getMyOptions ();
  257.  
  258. /* Saver Settings */
  259. saver['panelHeight'] = 18;
  260. saver['panelPadding'] = 2;
  261.  
  262. /* The Panel */
  263. var panelWidth = saver['saverWidth'] - saver['panelPadding'] * 2;
  264. saver['saverPanel'] = createMyElement ('div', '', '', '', '');
  265. styleMyElement (saver['saverPanel'], {position: 'relative', width: panelWidth + 'px', height: saver['panelHeight'] + 'px', display: 'block', padding: saver['panelPadding'] + 'px', backgroundColor: '#F4F4F4', fontSize: '12px', textAlign: 'center'});
  266. appendMyElement (saver['saverSocket'], saver['saverPanel']);
  267.  
  268. /* Warnings */
  269. if (saver['warnMess']) {
  270. if (saver['warnContent']) showMyMessage (saver['warnMess'], saver['warnContent']);
  271. else showMyMessage (saver['warnMess']);
  272. return;
  273. }
  274.  
  275. /* Panel Items */
  276. var panelItemBorder = 1;
  277. var panelItemHeight = saver['panelHeight'] - panelItemBorder * 2;
  278.  
  279. /* Panel Logo */
  280. saver['panelLogo'] = createMyElement ('div', userscript + ': ', 'click', 'logo', '');
  281. saver['panelLogo'].title = '{SaveTube: click to visit the script web page}';
  282. styleMyElement (saver['panelLogo'], {height: panelItemHeight + 'px', padding: '0px', display: 'inline', color: '#336699', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
  283. appendMyElement (saver['saverPanel'], saver['panelLogo']);
  284.  
  285. /* Panel Video Menu */
  286. saver['videoMenu'] = createMyElement ('select', '', 'change', '', 'video');
  287. saver['videoMenu'].title = '{Videos: select the video format for download}';
  288. styleMyElement (saver['videoMenu'], {width: '200px', height: panelItemHeight + 'px', border: '1px solid transparent', padding: '0px', display: 'inline', backgroundColor: 'inherit', color: '#336699', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', verticalAlign: 'baseline', cursor: 'pointer'});
  289. appendMyElement (saver['saverPanel'], saver['videoMenu'] );
  290. for (var videoCode in saver['videoList']) {
  291. saver['videoItem'] = createMyElement ('option', videoCode, '', '', '');
  292. styleMyElement (saver['videoItem'], {padding: '0px', display: 'block', color: '#336699', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
  293. if (videoCode.indexOf('Video') != -1 || videoCode.indexOf('Audio') != -1) styleMyElement (saver['videoItem'], {color: '#8F6B32'});
  294. appendMyElement (saver['videoMenu'], saver['videoItem']);
  295. }
  296.  
  297. /* Panel Get Button */
  298. saver['buttonGet'] = createMyElement ('div', 'Get', 'click', 'get', '');
  299. saver['buttonGet'].title = '{Get: click to download the selected video format}';
  300. styleMyElement (saver['buttonGet'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#C000C0', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
  301. if (option['autoget']) styleMyElement (saver['buttonGet'], {display: 'none'});
  302. appendMyElement (saver['saverPanel'], saver['buttonGet']);
  303.  
  304. /* Panel Autoget Button */
  305. if (feature['autoget']) {
  306. saver['buttonAutoget'] = createMyElement ('div', 'Autoget', 'click', 'autoget', '');
  307. saver['buttonAutoget'].title = '{Get: click to enable/disable auto download on page load}';
  308. styleMyElement (saver['buttonAutoget'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#CCCCCC', fontSize: '12px', cursor: 'pointer'});
  309. if (option['autoget']) styleMyElement (saver['buttonAutoget'], {color: '#008080', textShadow: '0px 1px 1px #CCCCCC'});
  310. appendMyElement (saver['saverPanel'], saver['buttonAutoget']);
  311. }
  312.  
  313. /* Panel Definition Button */
  314. if (feature['definition']) {
  315. saver['buttonDefinition'] = createMyElement ('div', option['definition'], 'click', 'definition', '');
  316. saver['buttonDefinition'].title = '{Definition: click to change the preferred video definition}';
  317. styleMyElement (saver['buttonDefinition'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#008000', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
  318. appendMyElement (saver['saverPanel'], saver['buttonDefinition']);
  319. }
  320.  
  321. /* Panel Container Button */
  322. if (feature['container']) {
  323. saver['buttonContainer'] = createMyElement ('div', option['container'], 'click', 'container', '');
  324. saver['buttonContainer'].title = '{Container: click to change the preferred video container}';
  325. styleMyElement (saver['buttonContainer'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#008000', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
  326. appendMyElement (saver['saverPanel'], saver['buttonContainer']);
  327. }
  328.  
  329. /* Select The Video */
  330. if (feature['definition'] || feature['container']) selectMyVideo ();
  331.  
  332. /* Get The Video On Autoget */
  333. if (option['autoget']) getMyVideo();
  334. }
  335.  
  336. function selectMyVideo () {
  337. var vdoCont = (option['container'] != 'Any') ? [option['container']] : option['containers'];
  338. var vdoDef = option['definitions'];
  339. var vdoList = {};
  340. for (var vC = 0; vC < vdoCont.length; vC++) {
  341. if (vdoCont[vC] != 'Any') {
  342. for (var vD = 0; vD < vdoDef.length; vD++) {
  343. var format = vdoDef[vD] + ' ' + vdoCont[vC];
  344. if (!vdoList[vdoDef[vD]]) {
  345. for (var vL in saver['videoList']) {
  346. if (vL == format) {
  347. vdoList[vdoDef[vD]] = vL;
  348. break;
  349. }
  350. }
  351. }
  352. }
  353. }
  354. }
  355. if (option['definition'] == 'UHD') {
  356. if (vdoList['Ultra High Definition']) saver['videoSave'] = vdoList['Ultra High Definition'];
  357. else if (vdoList['Full High Definition']) saver['videoSave'] = vdoList['Full High Definition'];
  358. else if (vdoList['High Definition']) saver['videoSave'] = vdoList['High Definition'];
  359. else if (vdoList['Standard Definition']) saver['videoSave'] = vdoList['Standard Definition'];
  360. else if (vdoList['Low Definition']) saver['videoSave'] = vdoList['Low Definition'];
  361. else if (vdoList['Very Low Definition']) saver['videoSave'] = vdoList['Very Low Definition'];
  362. }
  363. else if (option['definition'] == 'FHD') {
  364. if (vdoList['Full High Definition']) saver['videoSave'] = vdoList['Full High Definition'];
  365. else if (vdoList['High Definition']) saver['videoSave'] = vdoList['High Definition'];
  366. else if (vdoList['Standard Definition']) saver['videoSave'] = vdoList['Standard Definition'];
  367. else if (vdoList['Low Definition']) saver['videoSave'] = vdoList['Low Definition'];
  368. else if (vdoList['Very Low Definition']) saver['videoSave'] = vdoList['Very Low Definition'];
  369. }
  370. else if (option['definition'] == 'HD') {
  371. if (vdoList['High Definition']) saver['videoSave'] = vdoList['High Definition'];
  372. else if (vdoList['Standard Definition']) saver['videoSave'] = vdoList['Standard Definition'];
  373. else if (vdoList['Low Definition']) saver['videoSave'] = vdoList['Low Definition'];
  374. else if (vdoList['Very Low Definition']) saver['videoSave'] = vdoList['Very Low Definition'];
  375. }
  376. else if (option['definition'] == 'SD') {
  377. if (vdoList['Standard Definition']) saver['videoSave'] = vdoList['Standard Definition'];
  378. else if (vdoList['Low Definition']) saver['videoSave'] = vdoList['Low Definition'];
  379. else if (vdoList['Very Low Definition']) saver['videoSave'] = vdoList['Very Low Definition'];
  380. }
  381. else if (option['definition'] == 'LD') {
  382. if (vdoList['Low Definition']) saver['videoSave'] = vdoList['Low Definition'];
  383. else if (vdoList['Very Low Definition']) saver['videoSave'] = vdoList['Very Low Definition'];
  384. }
  385. else if (option['definition'] == 'VLD') {
  386. if (vdoList['Very Low Definition']) saver['videoSave'] = vdoList['Very Low Definition'];
  387. else if (vdoList['Low Definition']) saver['videoSave'] = vdoList['Low Definition'];
  388. }
  389. saver['videoMenu'].value = saver['videoSave'];
  390. }
  391.  
  392. function getMyVideo () {
  393. var vdoURL = saver['videoList'][saver['videoSave']];
  394. if (saver['videoTitle']) {
  395. var vdoD = ' (' + saver['videoSave'] + ')';
  396. vdoD = vdoD.replace(/Ultra High Definition/, 'UHD');
  397. vdoD = vdoD.replace(/Full High Definition/, 'FHD');
  398. vdoD = vdoD.replace(/High Definition/, 'HD');
  399. vdoD = vdoD.replace(/Standard Definition/, 'SD');
  400. vdoD = vdoD.replace(/Very Low Definition/, 'VLD');
  401. vdoD = vdoD.replace(/Low Definition/, 'LD');
  402. vdoD = vdoD.replace(/\sFLV|\sMP4|\sWebM|\s3GP/g, '');
  403. vdoURL = vdoURL + '&title=' + saver['videoTitle'] + vdoD;
  404. }
  405. if (feature['autoget'] && !saver['videoSave'].match(/(Video|Audio)/)) page.win.location.href = vdoURL;
  406. else {
  407. var vdoLink = 'Get <a href="' + vdoURL + '" style="color:#00892C">Link</a>';
  408. modifyMyElement (saver['buttonGet'] , 'div', vdoLink, false);
  409. }
  410. }
  411.  
  412. function cleanMyContent (content, unesc) {
  413. var myNewContent = content;
  414. if (unesc) myNewContent = unescape (myNewContent);
  415. myNewContent = myNewContent.replace (/\\u0025/g,'%');
  416. myNewContent = myNewContent.replace (/\\u0026/g,'&');
  417. myNewContent = myNewContent.replace (/\\/g,'');
  418. myNewContent = myNewContent.replace (/\n/g,'');
  419. return myNewContent;
  420. }
  421.  
  422. function getMyContent (url, pattern, clean) {
  423. var myPageContent, myVideosParse, myVideosContent;
  424. var isIE = (navigator.appName.indexOf('Internet Explorer') != -1) ? true : false;
  425. var getMethod = (url != page.url || isIE) ? 'XHR' : 'DOM';
  426. if (getMethod == 'DOM') {
  427. myPageContent = getMyElement ('', 'html', 'tag', '', 0, true);
  428. if (!myPageContent) myPageContent = getMyElement ('', 'body', '', '', -1, true);
  429. if (clean) myPageContent = cleanMyContent (myPageContent, true);
  430. myVideosParse = myPageContent.match (pattern);
  431. myVideosContent = (myVideosParse) ? myVideosParse[1] : null;
  432. if (myVideosContent) return myVideosContent;
  433. else getMethod = 'XHR';
  434. }
  435. if (getMethod == 'XHR') {
  436. var xmlHTTP = new XMLHttpRequest();
  437. xmlHTTP.open('GET', url, false);
  438. xmlHTTP.send();
  439. if (pattern == 'XML') {
  440. myVideosContent = xmlHTTP.responseXML;
  441. }
  442. else if (pattern == 'TEXT') {
  443. myVideosContent = xmlHTTP.responseText;
  444. }
  445. else {
  446. myPageContent = xmlHTTP.responseText;
  447. if (clean) myPageContent = cleanMyContent (myPageContent, true);
  448. myVideosParse = myPageContent.match (pattern);
  449. myVideosContent = (myVideosParse) ? myVideosParse[1] : null;
  450. }
  451. return myVideosContent;
  452. }
  453. }
  454.  
  455. function setMyOptions (key, value) {
  456. key = page.site + '_' + userscript.toLowerCase() + '_' + key;
  457. if (typeof GM_setValue === 'function') {
  458. GM_setValue(key, value);
  459. if (typeof GM_getValue === 'function' && GM_getValue(key) == value) return;
  460. }
  461. try {
  462. localStorage.setItem(key, value);
  463. if (localStorage.getItem(key) == value) return;
  464. else throw false;
  465. }
  466. catch(e) {
  467. var date = new Date();
  468. date.setTime(date.getTime() + (356*24*60*60*1000));
  469. var expires = '; expires=' + date.toGMTString();
  470. page.doc.cookie = key + '=' + value + expires + '; path=/';
  471. }
  472. }
  473.  
  474. function getMyOptions () {
  475. for (var opt in option) {
  476. if (option.hasOwnProperty(opt)) {
  477. var key = page.site + '_' + userscript.toLowerCase() + '_' + opt;
  478. if (typeof GM_getValue === 'function') {
  479. if (GM_getValue(key)) {
  480. option[opt] = GM_getValue(key);
  481. continue;
  482. }
  483. }
  484. try {
  485. if (localStorage.getItem(key)) {
  486. option[opt] = localStorage.getItem(key);
  487. continue;
  488. }
  489. else throw false;
  490. }
  491. catch (e) {
  492. var cookies = page.doc.cookie.split(';');
  493. for (var i=0; i < cookies.length; i++) {
  494. var cookie = cookies[i];
  495. while (cookie.charAt(0) == ' ') cookie = cookie.substring(1, cookie.length);
  496. option[opt] = (cookie.indexOf(key) == 0) ? cookie.substring(key.length + 1, cookie.length) : option[opt];
  497. }
  498. }
  499. }
  500. }
  501. option['autoget'] = (option['autoget'] === true || option['autoget'] == 'true') ? true : false;
  502. }
  503.  
  504. function showMyMessage (cause, content) {
  505. var myScriptLogo = createMyElement ('div', userscript, '', '', '');
  506. styleMyElement (myScriptLogo, {margin: '0px auto', padding: '10px', color: '#666666', fontSize: '24px', textAlign: 'center', textShadow: '#FFFFFF -1px -1px 2px'});
  507. var myScriptMess = createMyElement ('div', '', '', '', '');
  508. styleMyElement (myScriptMess, {border: '1px solid #F4F4F4', margin: '5px auto 5px auto', padding: '10px', backgroundColor: '#FFFFFF', color: '#AD0000', textAlign: 'center'});
  509. if (cause == '!player') {
  510. var myScriptAlert = createMyElement ('div', '', '', '', '');
  511. styleMyElement (myScriptAlert, {position: 'absolute', top: '30%', left: '35%', border: '1px solid #F4F4F4', borderRadius: '3px', padding: '10px', backgroundColor: '#FFFFFF', fontSize: '14px', textAlign: 'center', zIndex: '99999'});
  512. appendMyElement (myScriptAlert, myScriptLogo);
  513. var myNoPlayerMess = 'Couldn\'t get the player element. Please report it <a href="' + contact + '" style="color:#00892C">here</a>.';
  514. modifyMyElement (myScriptMess, 'div', myNoPlayerMess, false);
  515. appendMyElement (myScriptAlert, myScriptMess);
  516. var myScriptAlertButton = createMyElement ('div', 'OK', 'click', 'close', myScriptAlert);
  517. styleMyElement (myScriptAlertButton, {width: '100px', border: '3px solid #EEEEEE', borderRadius: '5px', margin: '0px auto', backgroundColor: '#EEEEEE', color: '#666666', fontSize: '18px', textAlign: 'center', textShadow: '#FFFFFF -1px -1px 2px', cursor: 'pointer'});
  518. appendMyElement (myScriptAlert, myScriptAlertButton);
  519. appendMyElement (page.body, myScriptAlert);
  520. }
  521. else {
  522. styleMyElement (saver['saverPanel'], {color: '#AD0000'});
  523. if (cause == '!content') {
  524. var myNoContentMess = '<b>SaveTube:</b> Couldn\'t get the videos content. Please report it <a href="' + contact + '" style="color:#00892C">here</a>.';
  525. modifyMyElement (saver['saverPanel'], 'div', myNoContentMess, false);
  526. }
  527. else if (cause == '!videos') {
  528. var myNoVideosMess = '<b>SaveTube:</b> Couldn\'t get any video. Please report it <a href="' + contact + '" style="color:#00892C">here</a>.';
  529. modifyMyElement (saver['saverPanel'], 'div', myNoVideosMess, false);
  530. }
  531. else if (cause == '!support') {
  532. var myNoSupportMess = '<b>SaveTube:</b> This video uses the RTMP protocol which is not supported.';
  533. modifyMyElement (saver['saverPanel'], 'div', myNoSupportMess, false);
  534. }
  535. else if (cause == 'embed') {
  536. var myEmbedMess = '<b>SaveTube:</b> This is an embedded video. You can get it <a href="' + content + '" style="color:#00892C">here</a>.';
  537. modifyMyElement (saver['saverPanel'], 'div', myEmbedMess, false);
  538. }
  539. }
  540. }
  541.  
  542.  
  543. // ==========Websites========== //
  544.  
  545. // Force page reload on href change
  546. page.win.setInterval(function() {
  547. nurl = page.win.location.href;
  548. if (page.url != nurl) {
  549. // YouTube
  550. if (nurl.indexOf('youtube.com') != -1) {
  551. if (nurl.indexOf('youtube.com/watch') != -1) page.win.location.href = nurl;
  552. }
  553. // Facebook
  554. else if (nurl.indexOf('facebook.com') != -1) {
  555. if (nurl.match('facebook.com/(video.php|.*/videos/)')) {
  556. page.win.location.href = nurl.replace('&theater', '');
  557. }
  558. }
  559. // Others
  560. else {
  561. page.win.location.href = nurl;
  562. }
  563. }
  564. }, 500);
  565.  
  566. // =====YouTube===== //
  567.  
  568. if (page.url.indexOf('youtube.com/watch') != -1) {
  569.  
  570. /* Video Availability */
  571. var ytVideoUnavailable = getMyElement ('', 'div', 'id', 'player-unavailable', -1, false);
  572. if (ytVideoUnavailable) {
  573. if (ytVideoUnavailable.className.indexOf('hid') == -1) {
  574. var ytAgeGateContent = getMyElement ('', 'div', 'id', 'watch7-player-age-gate-content', -1, true);
  575. if (!ytAgeGateContent) return;
  576. else {
  577. if(ytAgeGateContent.indexOf('feature=private_video') != -1) return;
  578. }
  579. }
  580. }
  581.  
  582. /* Decrypt Signature */
  583. var ytScriptSrc;
  584. function ytDecryptSignature (s) {return null;}
  585. function ytDecryptFunction () {
  586. var ytSignFuncName, ytSignFuncBody, ytSwapFuncName, ytSwapFuncBody, ytFuncMatch;
  587. ytScriptSrc = ytScriptSrc.replace(/(\r\n|\n|\r)/gm, '');
  588. ytSignFuncName = ytScriptSrc.match(/"signature"\s*,\s*(.*?)\(/);
  589. ytSignFuncName = (ytSignFuncName) ? ytSignFuncName[1] : null;
  590. if (ytSignFuncName) {
  591. ytFuncMatch = ytSignFuncName.replace(/\$/, '\\$') + '\\s*=\\s*function\\s*' + '\\s*\\(\\w+\\)\\s*\\{(.*?)\\}';
  592. ytSignFuncBody = ytScriptSrc.match(ytFuncMatch);
  593. ytSignFuncBody = (ytSignFuncBody) ? ytSignFuncBody[1] : null;
  594. if (ytSignFuncBody) {
  595. ytSwapFuncName = ytSignFuncBody.match(/((\$|_|\w)+)\.(\$|_|\w)+\(\w,[0-9]+\)/);
  596. ytSwapFuncName = (ytSwapFuncName) ? ytSwapFuncName[1] : null;
  597. if (ytSwapFuncName) {
  598. ytFuncMatch = 'var\\s+' + ytSwapFuncName.replace(/\$/, '\\$') + '=\\s*\\{(.*?)\\};';
  599. ytSwapFuncBody = ytScriptSrc.match(ytFuncMatch);
  600. ytSwapFuncBody = (ytSwapFuncBody) ? ytSwapFuncBody[1] : null;
  601. }
  602. if (ytSwapFuncBody) ytSignFuncBody = 'var ' + ytSwapFuncName + '={' + ytSwapFuncBody + '};' + ytSignFuncBody;
  603. ytSignFuncBody = 'try {' + ytSignFuncBody + '} catch(e) {return null}';
  604. ytDecryptSignature = new Function('a', ytSignFuncBody);
  605. }
  606. }
  607. }
  608.  
  609. /* Get Player Window */
  610. var ytPlayerWindow = getMyElement ('', 'div', 'id', 'placeholder-player', -1, false);
  611. if (!ytPlayerWindow) {
  612. showMyMessage ('!player');
  613. }
  614. else {
  615. /* Get Video Title */
  616. var ytVideoTitle = getMyContent (page.url, 'meta\\s+itemprop="name"\\s+content="(.*?)"', false);
  617. if (!ytVideoTitle) ytVideoTitle = getMyContent (page.url, 'meta\\s+property="og:title"\\s+content="(.*?)"', false);
  618. if (!ytVideoTitle) ytVideoTitle = page.doc.title;
  619. if (ytVideoTitle) {
  620. ytVideoTitle = ytVideoTitle.replace(/&quot;/g, '\'').replace(/&#34;/g, '\'').replace(/"/g, '\'');
  621. ytVideoTitle = ytVideoTitle.replace(/&#39;/g, '\'').replace(/'/g, '\'');
  622. ytVideoTitle = ytVideoTitle.replace(/&amp;/g, 'and').replace(/&/g, 'and');
  623. ytVideoTitle = ytVideoTitle.replace(/\?/g, '').replace(/[#:\*]/g, '-').replace(/\//g, '-');
  624. ytVideoTitle = ytVideoTitle.replace(/^\s+|\s+$/, '').replace(/\.+$/g, '');
  625. ytVideoTitle = ytVideoTitle.replace(/^YouTube\s-\s/, '');
  626. }
  627.  
  628. /* Get Videos Content */
  629. var ytVideosContent, ytHLSContent;
  630. var ytVideosEncodedFmts, ytVideosAdaptiveFmts;
  631. ytVideosEncodedFmts = getMyContent(page.url, '"url_encoded_fmt_stream_map":\\s*"(.*?)"', false);
  632. ytVideosAdaptiveFmts = getMyContent(page.url, '"adaptive_fmts":\\s*"(.*?)"', false);
  633. if (ytVideosEncodedFmts) {
  634. ytVideosContent = ytVideosEncodedFmts;
  635. }
  636. else {
  637. if (!ytVideoID) {
  638. var ytVideoID = page.url.match (/(\?|&)v=(.*?)(&|$)/);
  639. ytVideoID = (ytVideoID) ? ytVideoID[2] : null;
  640. }
  641. if (ytVideoID) {
  642. var ytVideoSts = getMyContent(page.url.replace(/watch.*?v=/, 'embed/').replace(/&.*$/, ''), '"sts"\\s*:\\s*(\\d+)', false);
  643. var ytVideosInfoURL = page.win.location.protocol + '//' + page.win.location.hostname + '/get_video_info?video_id=' + ytVideoID + '&eurl=https://youtube.googleapis.com/v/' + ytVideoID + '&sts=' + ytVideoSts;
  644. var ytVideosInfo = getMyContent(ytVideosInfoURL, 'TEXT', false);
  645. if (ytVideosInfo) {
  646. ytVideosEncodedFmts = ytVideosInfo.match(/url_encoded_fmt_stream_map=(.*?)&/);
  647. ytVideosEncodedFmts = (ytVideosEncodedFmts) ? ytVideosEncodedFmts[1] : null;
  648. if (ytVideosEncodedFmts) {
  649. ytVideosEncodedFmts = cleanMyContent(ytVideosEncodedFmts, true);
  650. ytVideosContent = ytVideosEncodedFmts;
  651. }
  652. if (!ytVideosAdaptiveFmts) {
  653. ytVideosAdaptiveFmts = ytVideosInfo.match(/adaptive_fmts=(.*?)&/);
  654. ytVideosAdaptiveFmts = (ytVideosAdaptiveFmts) ? ytVideosAdaptiveFmts[1] : null;
  655. if (ytVideosAdaptiveFmts) ytVideosAdaptiveFmts = cleanMyContent(ytVideosAdaptiveFmts, true);
  656. }
  657. }
  658. }
  659. }
  660. if (ytVideosAdaptiveFmts) {
  661. if (ytVideosContent) ytVideosContent += ',' + ytVideosAdaptiveFmts;
  662. else ytVideosContent = ytVideosAdaptiveFmts;
  663. }
  664.  
  665. /* Get HLS Content */
  666. if (!ytVideosContent) {
  667. var ytHLSVideos, ytHLSContent;
  668. ytHLSVideos = getMyContent(page.url, '"hlsvp":\\s*"(.*?)"', false);
  669. if (ytHLSVideos) ytHLSVideos = cleanMyContent(ytHLSVideos, false);
  670. }
  671.  
  672. /* Fix Sidebar */
  673. //var ytSidebarWindow = getMyElement ('', 'div', 'id', 'watch7-sidebar', -1, false);
  674. //if (ytSidebarWindow) styleMyElement(ytSidebarWindow, {marginTop: '-412px'});
  675.  
  676. /* Create Saver */
  677. var ytDefaultVideo = 'Low Definition MP4';
  678. function ytSaver () {
  679. saver = {'saverSocket': ytPlayerWindow, 'videoList': ytVideoList, 'videoSave': ytDefaultVideo, 'videoTitle': ytVideoTitle, 'saverWidth': 640};
  680. option['definitions'] = ['Ultra High Definition', 'Full High Definition', 'High Definition', 'Standard Definition', 'Low Definition', 'Very Low Definition'];
  681. option['containers'] = ['MP4', 'WebM', 'FLV', '3GP', 'Any'];
  682. }
  683.  
  684. /* Parse Videos */
  685. function ytVideos() {
  686. var ytVideoFormats = {
  687. '5': 'Very Low Definition FLV',
  688. '17': 'Very Low Definition 3GP',
  689. '18': 'Low Definition MP4',
  690. '22': 'High Definition MP4',
  691. '34': 'Low Definition FLV',
  692. '35': 'Standard Definition FLV',
  693. '36': 'Low Definition 3GP',
  694. '37': 'Full High Definition MP4',
  695. '38': 'Ultra High Definition MP4',
  696. '43': 'Low Definition WebM',
  697. '44': 'Standard Definition WebM',
  698. '45': 'High Definition WebM',
  699. '46': 'Full High Definition WebM',
  700. '82': 'Low Definition 3D MP4',
  701. '83': 'Standard Definition 3D MP4',
  702. '84': 'High Definition 3D MP4',
  703. '85': 'Full High Definition 3D MP4',
  704. '100': 'Low Definition 3D WebM',
  705. '101': 'Standard Definition 3D WebM',
  706. '102': 'High Definition 3D WebM',
  707. '135': 'Standard Definition Video MP4',
  708. '136': 'High Definition Video MP4',
  709. '137': 'Full High Definition Video MP4',
  710. '138': 'Ultra High Definition Video MP4',
  711. '139': 'Low Bitrate Audio MP4',
  712. '140': 'Medium Bitrate Audio MP4',
  713. '141': 'High Bitrate Audio MP4',
  714. '171': 'Medium Bitrate Audio WebM',
  715. '172': 'High Bitrate Audio WebM',
  716. '244': 'Standard Definition Video WebM',
  717. '247': 'High Definition Video WebM',
  718. '248': 'Full High Definition Video WebM',
  719. '249': 'Low Bitrate Audio Opus',
  720. '250': 'Medium Bitrate Audio Opus',
  721. '251': 'High Bitrate Audio Opus',
  722. '266': 'Ultra High Definition Video MP4',
  723. '272': 'Ultra High Definition Video WebM',
  724. '298': 'High Definition Video MP4',
  725. '299': 'Full High Definition Video MP4',
  726. '302': 'High Definition Video WebM',
  727. '303': 'Full High Definition Video WebM',
  728. '313': 'Ultra High Definition Video WebM'
  729. };
  730. var ytVideoFound = false;
  731. var ytVideos = ytVideosContent.split(',');
  732. var ytVideoParse, ytVideoCodeParse, ytVideoCode, myVideoCode, ytVideo;
  733. for (var i = 0; i < ytVideos.length; i++) {
  734. if (!ytVideos[i].match(/^url/)) {
  735. ytVideoParse = ytVideos[i].match(/(.*)(url=.*$)/);
  736. if (ytVideoParse) ytVideos[i] = ytVideoParse[2] + '&' + ytVideoParse[1];
  737. }
  738. ytVideoCodeParse = ytVideos[i].match (/itag=(\d{1,3})/);
  739. ytVideoCode = (ytVideoCodeParse) ? ytVideoCodeParse[1] : null;
  740. if (ytVideoCode) {
  741. myVideoCode = ytVideoFormats[ytVideoCode];
  742. if (myVideoCode) {
  743. ytVideo = cleanMyContent(ytVideos[i], true);
  744. ytVideo = ytVideo.replace (/url=/, '').replace(/&$/, '');
  745. if (ytVideo.match(/itag=/) && ytVideo.match(/itag=/g).length > 1) {
  746. if (ytVideo.match(/itag=\d{1,3}&/)) ytVideo = ytVideo.replace(/itag=\d{1,3}&/, '');
  747. else if (ytVideo.match(/&itag=\d{1,3}/)) ytVideo = ytVideo.replace(/&itag=\d{1,3}/, '');
  748. }
  749. if (ytVideo.match(/clen=/) && ytVideo.match(/clen=/g).length > 1) {
  750. if (ytVideo.match(/clen=\d+&/)) ytVideo = ytVideo.replace(/clen=\d+&/, '');
  751. else if (ytVideo.match(/&clen=\d+/)) ytVideo = ytVideo.replace(/&clen=\d+/, '');
  752. }
  753. if (ytVideo.match(/lmt=/) && ytVideo.match(/lmt=/g).length > 1) {
  754. if (ytVideo.match(/lmt=\d+&/)) ytVideo = ytVideo.replace(/lmt=\d+&/, '');
  755. else if (ytVideo.match(/&lmt=\d+/)) ytVideo = ytVideo.replace(/&lmt=\d+/, '');
  756. }
  757. if (ytVideo.match(/type=(video|audio).*?&/)) ytVideo = ytVideo.replace(/type=(video|audio).*?&/, '');
  758. else ytVideo = ytVideo.replace(/&type=(video|audio).*$/, '');
  759. if (ytVideo.match(/&sig=/)) ytVideo = ytVideo.replace (/&sig=/, '&signature=');
  760. else if (ytVideo.match(/&s=/)) {
  761. var ytSig = ytVideo.match(/&s=(.*?)(&|$)/);
  762. if (ytSig) {
  763. var s = ytSig[1];
  764. s = ytDecryptSignature(s);
  765. if (s) ytVideo = ytVideo.replace(/&s=.*?(&|$)/, '&signature=' + s + '$1');
  766. else ytVideo = '';
  767. }
  768. else ytVideo = '';
  769. }
  770. ytVideo = cleanMyContent (ytVideo, true);
  771. if (ytVideo.indexOf('ratebypass') == -1) ytVideo += '&ratebypass=yes';
  772. if (ytVideo && ytVideo.indexOf('http') == 0) {
  773. if (!ytVideoFound) ytVideoFound = true;
  774. ytVideoList[myVideoCode] = ytVideo;
  775. }
  776. }
  777. }
  778. }
  779.  
  780. if (ytVideoFound) {
  781. /* Create Saver */
  782. feature['autoget'] = true;
  783. ytSaver();
  784. createMySaver();
  785. }
  786. else {
  787. saver = {'saverSocket': ytPlayerWindow, 'saverWidth': 640};
  788. if (ytVideosContent.indexOf('conn=rtmp') != -1) saver['warnMess'] = '!support';
  789. else saver['warnMess'] = '!videos';
  790. createMySaver();
  791. }
  792. }
  793.  
  794. /* Parse HLS */
  795. function ytHLS() {
  796. var ytHLSFormats = {
  797. '92': 'Very Low Definition MP4',
  798. '93': 'Low Definition MP4',
  799. '94': 'Standard Definition MP4',
  800. '95': 'High Definition MP4',
  801. '96': 'Full High Definition MP4'
  802. };
  803. ytVideoList["Any Definition MP4"] = ytHLSVideos;
  804. if (ytHLSContent) {
  805. var ytHLSVideo, ytVideoCodeParse, ytVideoCode, myVideoCode;
  806. var ytHLSMatcher = new RegExp('(http.*?m3u8)', 'g');
  807. ytHLSVideos = ytHLSContent.match(ytHLSMatcher);
  808. if (ytHLSVideos) {
  809. for (var i = 0; i < ytHLSVideos.length; i++) {
  810. ytHLSVideo = ytHLSVideos[i];
  811. ytVideoCodeParse = ytHLSVideo.match(/\/itag\/(\d{1,3})\//);
  812. ytVideoCode = (ytVideoCodeParse) ? ytVideoCodeParse[1] : null;
  813. if (ytVideoCode) {
  814. myVideoCode = ytHLSFormats[ytVideoCode];
  815. if (myVideoCode && ytHLSVideo) {
  816. ytVideoList[myVideoCode] = ytHLSVideo;
  817. }
  818. }
  819. }
  820. }
  821. }
  822.  
  823. /* Create Saver */
  824. ytVideoTitle = null;
  825. ytDefaultVideo = 'Any Definition MP4';
  826. ytSaver();
  827. createMySaver();
  828. }
  829.  
  830. /* Get Videos */
  831. var ytVideoList = {};
  832. if (ytVideosContent) {
  833. if (ytVideosContent.match(/&s=/) || ytVideosContent.match(/,s=/) || ytVideosContent.match(/u0026s=/)) {
  834. var ytScriptURL = getMyContent(page.url, '"js":\\s*"(.*?)"', true);
  835. if (!ytScriptURL) ytScriptURL = getMyContent(page.url.replace(/watch.*?v=/, 'embed/').replace(/&.*$/, ''), '"js":\\s*"(.*?)"', true);
  836. if (ytScriptURL) {
  837. ytScriptURL = page.win.location.protocol + ytScriptURL;
  838. try {
  839. ytScriptSrc = getMyContent(ytScriptURL, 'TEXT', false);
  840. if (ytScriptSrc) ytDecryptFunction();
  841. ytVideos();
  842. }
  843. catch (e) {
  844. try {
  845. GM_xmlhttpRequest({
  846. method: 'GET',
  847. url: ytScriptURL,
  848. onload: function(response) {
  849. if (response.readyState === 4 && response.status === 200) {
  850. ytScriptSrc = response.responseText;
  851. }
  852. if (ytScriptSrc) ytDecryptFunction();
  853. ytVideos();
  854. }
  855. });
  856. }
  857. catch (e) {
  858. ytVideos();
  859. }
  860. }
  861. }
  862. else {
  863. ytVideos();
  864. }
  865. }
  866. else {
  867. ytVideos();
  868. }
  869. }
  870. else {
  871. if (ytHLSVideos) {
  872. try {
  873. ytHLSContent = getMyContent(ytHLSVideos, 'TEXT', false);
  874. ytHLS();
  875. }
  876. catch (e) {
  877. try {
  878. GM_xmlhttpRequest({
  879. method: 'GET',
  880. url: ytHLSVideos,
  881. onload: function(response) {
  882. if (response.readyState === 4 && response.status === 200) {
  883. ytHLSContent = response.responseText;
  884. }
  885. ytHLS();
  886. }
  887. });
  888. }
  889. catch (e) {
  890. ytHLS();
  891. }
  892. }
  893. }
  894. else {
  895. saver = {'saverSocket': ytPlayerWindow, 'saverWidth': 640, 'warnMess': '!content'};
  896. createMySaver ();
  897. }
  898. }
  899. }
  900.  
  901. }
  902.  
  903. // =====DailyMotion===== //
  904.  
  905. else if (page.url.indexOf('dailymotion.com/video') != -1 || page.url.indexOf('dailymotion.com/playlist') != -1) {
  906.  
  907. /* Redirect Playlist To Video */
  908. if (page.url.indexOf('dailymotion.com/playlist') != -1 && page.url.indexOf('#video=') != -1) {
  909. page.win.location.href = page.url.replace(/playlist.*#/, '').replace("=", "/");
  910. }
  911.  
  912. /* Get Player Window */
  913. var dmPlayerWindow = getMyElement ('', 'div', 'class', 'js-player-box', 0, false);
  914. if (!dmPlayerWindow) dmPlayerWindow = getMyElement ('', 'div', 'id', 'player_container', -1, false);
  915. if (!dmPlayerWindow) {
  916. showMyMessage ('!player');
  917. }
  918. else {
  919. /* Get Videos Content */
  920. var dmEmbed;
  921. if (page.url.indexOf('dailymotion.com/video') != -1) dmEmbed = page.url.replace(/\/video\//, "/embed/video/");
  922. else dmEmbed = page.url.replace(/playlist.*=/, "embed/video/");
  923. dmVideosContent = getMyContent (dmEmbed, '"qualities":\\{(.*?)\\]\\},', false);
  924.  
  925. /* Get Videos */
  926. if (dmVideosContent) {
  927. var dmVideoFormats = {'240': 'Very Low Definition MP4', '380': 'Low Definition MP4', '480': 'Standard Definition MP4',
  928. '720': 'High Definition MP4', '1080': 'Full High Definition MP4'};
  929. var dmVideoList = {};
  930. var dmVideoFound = false;
  931. var dmVideoParser, dmVideoParse, myVideoCode, dmVideo;
  932. for (var dmVideoCode in dmVideoFormats) {
  933. dmVideoParser = '"' + dmVideoCode + '".*?"url":"(.*?)"';
  934. dmVideoParse = dmVideosContent.match (dmVideoParser);
  935. dmVideo = (dmVideoParse) ? dmVideoParse[1] : null;
  936. if (dmVideo) {
  937. if (!dmVideoFound) dmVideoFound = true;
  938. dmVideo = cleanMyContent(dmVideo, true);
  939. myVideoCode = dmVideoFormats[dmVideoCode];
  940. if (!dmVideoList[myVideoCode]) dmVideoList[myVideoCode] = dmVideo;
  941. }
  942. }
  943.  
  944. if (dmVideoFound) {
  945. /* Create Saver */
  946. var dmDefaultVideo = 'Low Definition MP4';
  947. saver = {'saverSocket': dmPlayerWindow, 'videoList': dmVideoList, 'videoSave': dmDefaultVideo, 'saverWidth': 800};
  948. feature['container'] = false;
  949. option['definitions'] = ['Full High Definition', 'High Definition', 'Standard Definition', 'Low Definition', 'Very Low Definition'];
  950. option['containers'] = ['MP4'];
  951. createMySaver ();
  952. }
  953. else {
  954. saver = {'saverSocket': dmPlayerWindow, 'saverWidth': 800, 'warnMess': '!videos'};
  955. createMySaver ();
  956. }
  957. }
  958. else {
  959. saver = {'saverSocket': dmPlayerWindow, 'saverWidth': 800, 'warnMess': '!content'};
  960. createMySaver ();
  961. }
  962. }
  963.  
  964. }
  965.  
  966. // =====Vimeo===== //
  967.  
  968. else if (page.url.match(/vimeo.com\/\d+/) || page.url.match(/vimeo.com\/channels\/[^\/]*($|\/page|\/\d+)/) || page.url.match(/vimeo.com\/originals\/[^\/]*\/\d+/) || page.url.match(/vimeo.com\/album\/\d+\/video\/\d+/)) {
  969.  
  970. /* Multi Video Page */
  971. if (getMyElement('', 'div', 'class', 'player_container', -1, false).length > 1) return;
  972.  
  973. /* Saver Width */
  974. var viSaverWidth = 960;
  975. if (page.url.indexOf('/channels/') != -1 && page.url.indexOf('/channels/staffpicks') == -1) {
  976. viSaverWidth = 630;
  977. }
  978.  
  979. /* Get Player Window */
  980. var viPlayerWindow = getMyElement ('', 'div', 'class', 'player_container', 0, false) || null;
  981. if (!viPlayerWindow) {
  982. showMyMessage ('!player');
  983. }
  984. else {
  985. /* Restyle Player Window */
  986. styleMyElement (viPlayerWindow, {margin: '0px 0px 20px 0px'});
  987.  
  988. /* Get Content Source */
  989. var viVideoSource = getMyContent (page.url, 'data-config-url="(.*?)"', false).replace(/&amp;/g, '&');
  990.  
  991. /* Get Videos Content */
  992. var viVideosContent;
  993. if (viVideoSource) {
  994. viVideosContent = getMyContent(viVideoSource, '"progressive":\\[(.*?)\\]', false);
  995. }
  996.  
  997. /* Get Videos */
  998. if (viVideosContent) {
  999. var viVideoFormats = {'720p': 'High Definition MP4', '360p': 'Low Definition MP4', '270p': 'Very Low Definition MP4'};
  1000. var viVideoList = {};
  1001. var viVideoFound = false;
  1002. var viVideo, myVideoCode;
  1003. var viVideos = viVideosContent.split('},');
  1004. for (var i = 0; i < viVideos.length; i++) {
  1005. for (var viVideoCode in viVideoFormats) {
  1006. if (viVideos[i].indexOf('"quality":"' + viVideoCode + '"') != -1) {
  1007. viVideo = viVideos[i].match(/"url":"(.*?)"/);
  1008. viVideo = (viVideo) ? viVideo[1] : null;
  1009. if (viVideo) {
  1010. if (!viVideoFound) viVideoFound = true;
  1011. myVideoCode = viVideoFormats[viVideoCode];
  1012. viVideoList[myVideoCode] = viVideo;
  1013. }
  1014. }
  1015. }
  1016. }
  1017.  
  1018. if (viVideoFound) {
  1019. /* Create Saver */
  1020. var viDefaultVideo = 'Low Definition MP4';
  1021. saver = {'saverSocket': viPlayerWindow, 'videoList': viVideoList, 'videoSave': viDefaultVideo, 'saverWidth': viSaverWidth};
  1022. feature['container'] = false;
  1023. option['definitions'] = ['High Definition', 'Low Definition', 'Very Low Definition'];
  1024. option['containers'] = ['MP4'];
  1025. createMySaver ();
  1026. }
  1027. else {
  1028. saver = {'saverSocket': viPlayerWindow, 'saverWidth': viSaverWidth, 'warnMess': '!videos'};
  1029. createMySaver ();
  1030. }
  1031. }
  1032. else {
  1033. saver = {'saverSocket': viPlayerWindow, 'saverWidth': viSaverWidth, 'warnMess': '!content'};
  1034. createMySaver ();
  1035. }
  1036. }
  1037.  
  1038. }
  1039.  
  1040. // =====MetaCafe===== //
  1041.  
  1042. else if (page.url.indexOf('metacafe.com/watch') != -1) {
  1043.  
  1044. /* Get Player Window */
  1045. var mcPlayerWindow = getMyElement ('', 'div', 'id', 'FlashWrap', -1, false);
  1046. if (!mcPlayerWindow) mcPlayerWindow = getMyElement ('', 'div', 'id', 'ItemContainer', -1, false);
  1047. if (!mcPlayerWindow) {
  1048. showMyMessage ('!player');
  1049. }
  1050. else {
  1051. /* Check Video Availability */
  1052. if (mcPlayerWindow.innerHTML.indexOf('This Video cannot be played on this device.') != -1) return;
  1053.  
  1054. /* Restyle Player Window */
  1055. styleMyElement (mcPlayerWindow, {margin: '0px 0px 30px 0px'});
  1056.  
  1057. /* Get Videos Content */
  1058. var mcVideosContent, mcVideo;
  1059. var mcFlashVideo = getMyElement (mcPlayerWindow, 'embed', 'tag', '', 0, false) || getMyElement (mcPlayerWindow, 'object', 'tag', '', 0, false);
  1060. if (mcFlashVideo) {
  1061. mcVideosContent = getMyContent (page.url, '"mediaData":"(.*?)"', false);
  1062. if (!mcVideosContent) {
  1063. anyClipId = page.url.match(/\/an-(.*?)\//);
  1064. if (anyClipId && anyClipId[1]) {
  1065. mcVideo = 'http://vid2.anyclip.com/' + anyClipId[1];
  1066. }
  1067. }
  1068. }
  1069. else mcVideo = getMyContent (page.url, 'video\\s+src="(.*?)"', false);
  1070. /* New */
  1071. if (!mcVideosContent && !mcVideo) {
  1072. mcVideo = getMyContent (page.url, 'videoURL=(.*?)&', true);
  1073. }
  1074.  
  1075. /* Get Videos */
  1076. if (mcVideosContent || mcVideo) {
  1077. var mcVideoList = {};
  1078. var mcVideoFound = false;
  1079. if (mcVideosContent) {
  1080. mcVideosContent = cleanMyContent(mcVideosContent, true);
  1081. var mcVideoFormats = {'highDefinitionMP4': 'High Definition MP4', 'MP4': 'Low Definition MP4', 'flv': 'Low Definition FLV'};
  1082. var mcVideoParser, mcVideoParse, myVideoCode, mcVideoPath, mcVideoKey, mcVideo;
  1083. for (var mcVideoCode in mcVideoFormats) {
  1084. mcVideoParser = '"' + mcVideoCode + '":\\{.*?"mediaURL":"(.*?)","access":\\[\\{"key":"(.*?)","value":"(.*?)"\\}\\]\\}';
  1085. mcVideoParse = mcVideosContent.match (mcVideoParser);
  1086. mcVideoPath = (mcVideoParse) ? mcVideoParse[1] : null;
  1087. mcVideoKeyName = (mcVideoParse) ? mcVideoParse[2] : null;
  1088. mcVideoKeyValue = (mcVideoParse) ? mcVideoParse[3] : null;
  1089. if (mcVideoPath && mcVideoKeyName && mcVideoKeyValue) {
  1090. if (!mcVideoFound) mcVideoFound = true;
  1091. myVideoCode = mcVideoFormats[mcVideoCode];
  1092. mcVideo = mcVideoPath + '?' + mcVideoKeyName + '=' + mcVideoKeyValue;
  1093. mcVideoList[myVideoCode] = mcVideo;
  1094. }
  1095. }
  1096. }
  1097. else {
  1098. mcVideoList['Low Definition MP4'] = mcVideo;
  1099. mcVideoFound = true;
  1100. feature['definition'] = false;
  1101. feature['container'] = false;
  1102. }
  1103.  
  1104. if (mcVideoFound) {
  1105. /* Create Saver */
  1106. var mcDefaultVideo = (mcVideoList['Low Definition MP4']) ? 'Low Definition MP4' : 'Low Definition FLV';
  1107. saver = {'saverSocket': mcPlayerWindow, 'videoList': mcVideoList, 'videoSave': mcDefaultVideo, 'saverWidth': 640};
  1108. option['definitions'] = ['High Definition', 'Low Definition'];
  1109. option['containers'] = ['MP4', 'FLV', 'Any'];
  1110. createMySaver ();
  1111. }
  1112. else {
  1113. saver = {'saverSocket': mcPlayerWindow, 'saverWidth': 640, 'warnMess': '!videos'};
  1114. createMySaver ();
  1115. }
  1116. }
  1117. else {
  1118. saver = {'saverSocket': mcPlayerWindow, 'saverWidth': 640};
  1119. var ytVideoId = page.url.match (/\/yt-(.*?)\//);
  1120. if (ytVideoId && ytVideoId[1]) {
  1121. var ytVideoLink = 'http://youtube.com/watch?v=' + ytVideoId[1];
  1122. saver['warnMess'] = 'embed';
  1123. saver['warnContent'] = ytVideoLink;
  1124. }
  1125. else saver['warnMess'] = '!videos';
  1126. createMySaver ();
  1127. }
  1128. }
  1129.  
  1130. }
  1131.  
  1132. // =====Break===== //
  1133.  
  1134. else if (page.url.indexOf('break.com/video') != -1 || page.url.indexOf('break.com/movies') != -1) {
  1135.  
  1136. /* Get Player Window */
  1137. var brPlayerWindow = getMyElement ('', 'div', 'id', 'video-player', -1, false);
  1138. if (!brPlayerWindow) {
  1139. showMyMessage ('!player');
  1140. }
  1141. else {
  1142. /* Saver Width */
  1143. var brWindowWidth = page.win.innerWidth || page.doc.documentElement.clientWidth;
  1144. var brSaverWidth;
  1145. if (page.url.indexOf('break.com/movies') != -1) {
  1146. if (brWindowWidth >= 1400) brSaverWidth = 1152;
  1147. else brSaverWidth = 912;
  1148. }
  1149. else {
  1150. if (brWindowWidth >= 1400) brSaverWidth = 832;
  1151. else brSaverWidth = 592;
  1152. }
  1153.  
  1154. /* Get Video ID */
  1155. var brVideoID = page.url.match(/-(\d+)($|\?)/);
  1156. brVideoID = (brVideoID) ? brVideoID[1] : null;
  1157.  
  1158. /* Get Videos Content */
  1159. var brSource = page.win.location.protocol + '//' + page.win.location.hostname + '/embed/' + brVideoID;
  1160. var brVideosContent = getMyContent (brSource, 'TEXT', false);
  1161.  
  1162. /* Get Videos */
  1163. if (brVideosContent) {
  1164. var brVideoList = {};
  1165. var brVideoFormats = {};
  1166. var brVideoFound = false;
  1167. var brVideoFormats = {'320_kbps.mp4': 'Very Low Definition MP4', '496_kbps.mp4': 'Low Definition MP4', '864_kbps.mp4': 'Standard Definition MP4', '2240_kbps.mp4': 'High Definition MP4', '3264_kbps.mp4': 'Full High Definition MP4'};
  1168. var brVideoPath, brVideoToken, brVideoThumb, brVideo, myVideoCode;
  1169. brVideoPath = brVideosContent.match (/"videoUri":\s"(.*?)496_kbps/);
  1170. brVideoPath = (brVideoPath) ? brVideoPath[1] : null;
  1171. brVideoToken = brVideosContent.match (/"AuthToken":\s"(.*?)"/);
  1172. brVideoToken = (brVideoToken) ? brVideoToken[1] : null;
  1173. if (brVideoPath && brVideoToken) {
  1174. for (var brVideoCode in brVideoFormats) {
  1175. if (brVideosContent.match(brVideoPath + brVideoCode)) {
  1176. if (!brVideoFound) brVideoFound = true;
  1177. myVideoCode = brVideoFormats[brVideoCode];
  1178. brVideo = brVideoPath + brVideoCode + '?' + brVideoToken;
  1179. brVideoList[myVideoCode] = brVideo;
  1180. }
  1181. }
  1182. }
  1183.  
  1184. if (brVideoFound) {
  1185. /* Create Saver */
  1186. var brDefaultVideo = 'Low Definition MP4';
  1187. saver = {'saverSocket': brPlayerWindow, 'videoList': brVideoList, 'videoSave': brDefaultVideo, 'saverWidth': brSaverWidth};
  1188. option['definitions'] = ['Very Low Definition', 'Low Definition', 'Standard Definition', 'High Definition', 'Full High Definition'];
  1189. option['containers'] = ['MP4', 'FLV', 'Any'];
  1190. createMySaver ();
  1191. }
  1192. else {
  1193. saver = {'saverSocket': brPlayerWindow, 'saverWidth': brSaverWidth};
  1194. var ytVideoId = brVideosContent.match (/"youtubeId":\s"(.*?)"/);
  1195. if (ytVideoId && ytVideoId[1]) {
  1196. var ytVideoLink = 'http://youtube.com/watch?v=' + ytVideoId[1];
  1197. saver['warnMess'] = 'embed';
  1198. saver['warnContent'] = ytVideoLink;
  1199. }
  1200. else saver['warnMess'] = '!videos';
  1201. createMySaver ();
  1202. }
  1203. }
  1204. else {
  1205. saver = {'saverSocket': brPlayerWindow, 'saverWidth': brSaverWidth, 'warnMess': '!content'};
  1206. createMySaver ();
  1207. }
  1208. }
  1209.  
  1210. }
  1211.  
  1212. // =====FunnyOrDie===== //
  1213.  
  1214. else if (page.url.indexOf('funnyordie.com/videos') != -1) {
  1215.  
  1216. /* Get Player Window */
  1217. var fodPlayerWindow = getMyElement ('', 'div', 'class', 'video-content', 0, false);
  1218. if (!fodPlayerWindow) {
  1219. showMyMessage ('!player');
  1220. }
  1221. else {
  1222. /* My Saver Socket */
  1223. var fodSaverSocket = createMyElement ('div', '', '', '', '');
  1224. styleMyElement (fodSaverSocket, {width: '100%', height: '24px', textAlign: 'center', padding: '0px 100px 0px 100px', backgroundColor: '#F4F4F4'});
  1225. appendMyElement (fodPlayerWindow, fodSaverSocket);
  1226.  
  1227. /* Get Videos Content */
  1228. var fodVideosContent = getMyContent (page.url, '<video([\\s\\S]*?)video>', false);
  1229.  
  1230. /* Get Videos */
  1231. if (fodVideosContent) {
  1232. var fodVideoFormats = {'v2500.mp4': 'High Definition MP4', 'v1800.mp4': 'Standard Definition MP4', 'v600.mp4': 'Low Definition MP4', 'v600.webm': 'Low Definition WebM', 'v110.mp4': 'Very Low Definition MP4'};
  1233. var fodVideoList = {};
  1234. var fodVideoFound = false;
  1235. var fodVideoPath, fodVideoCodes, fodVideo, myVideoCode;
  1236. fodVideoPath = fodVideosContent.match(/src="(.*?)v\d+.*?\.mp4"/);
  1237. fodVideoPath = (fodVideoPath) ? fodVideoPath[1] : null;
  1238. fodVideoCodes = fodVideosContent.match (/v,(.*?),\./);
  1239. fodVideoCodes = (fodVideoCodes) ? fodVideoCodes[1] : '';
  1240. if (fodVideoPath) {
  1241. if (fodVideoCodes) {
  1242. for (var fodVideoCode in fodVideoFormats) {
  1243. if (fodVideoCodes.indexOf(fodVideoCode.replace(/v/, '').replace(/\..*/, '')) != -1) {
  1244. if (!fodVideoFound) fodVideoFound = true;
  1245. fodVideo = fodVideoPath + fodVideoCode;
  1246. myVideoCode = fodVideoFormats[fodVideoCode];
  1247. fodVideoList[myVideoCode] = fodVideo;
  1248. }
  1249. }
  1250. }
  1251. else {
  1252. for (var fodVideoCode in fodVideoFormats) {
  1253. fodVideo = fodVideoPath + fodVideoCode;
  1254. if (fodVideosContent.match(fodVideo)) {
  1255. if (!fodVideoFound) fodVideoFound = true;
  1256. myVideoCode = fodVideoFormats[fodVideoCode];
  1257. fodVideoList[myVideoCode] = fodVideo;
  1258. }
  1259. }
  1260. }
  1261. }
  1262.  
  1263. if (fodVideoFound) {
  1264. /* Create Saver */
  1265. fodDefaultVideo = 'Low Definition MP4';
  1266. saver = {'saverSocket': fodSaverSocket, 'videoList': fodVideoList, 'videoSave': fodDefaultVideo, 'saverWidth': 570};
  1267. feature['container'] = false;
  1268. option['definitions'] = ['High Definition', 'Standard Definition', 'Low Definition', 'Very Low Definition'];
  1269. option['containers'] = ['MP4'];
  1270. createMySaver ();
  1271. }
  1272. else {
  1273. saver = {'saverSocket': fodPlayerWindow, 'saverWidth': 570, 'warnMess': '!videos'};
  1274. createMySaver ();
  1275. }
  1276. }
  1277. else {
  1278. saver = {'saverSocket': fodPlayerWindow, 'saverWidth': 570, 'warnMess': '!content'};
  1279. createMySaver ();
  1280. }
  1281. }
  1282.  
  1283. }
  1284.  
  1285. // =====Videojug===== //
  1286.  
  1287. else if (page.url.indexOf('videojug.com/') != -1) {
  1288.  
  1289. /* Get Player Window */
  1290. var vjPlayerWindow = getMyElement ('', 'div', 'id', 'player_shadow', -1, false);
  1291. var vjPlayerWidth;
  1292. if (page.url.indexOf("videojug.com/film") != -1) vjPlayerWidth = 640;
  1293. else if (page.url.indexOf("videojug.com/series") != -1) vjPlayerWidth = 768;
  1294. else return;
  1295. if (!vjPlayerWindow) {
  1296. showMyMessage ('!player');
  1297. }
  1298. else {
  1299. /* Get Videos Content */
  1300. var vjVideoID = getMyContent (page.url, 'data-videoid="(.*?)"', true);
  1301. var vjVideoTitle = getMyContent (page.url, 'data-filenameprefix="(.*?)"', true);
  1302.  
  1303. /* Get Videos */
  1304. if (vjVideoID && vjVideoTitle) {
  1305. var vjVideoID2 = vjVideoID.substring(0,2);
  1306. var vjVideoProtocol = page.win.location.protocol;
  1307. var vjVideoSource = vjVideoProtocol + '//' + page.win.location.hostname + '/views/film/playlist.aspx?id=' + vjVideoID;
  1308. var vjVideoShapes = getMyContent(vjVideoSource, '<Shapes>(.*?)<\/Shapes>', false);
  1309. var vjVideoFormats = {'VJ480PENG.mp4': 'Standard Definition MP4', 'VJ360PENG.mp4': 'Low Definition MP4', 'PHOENG.mp4': 'Very Low Definition MP4', 'FW8ENG.flv': 'Low Definition FLV', 'FS8ENG.flv': 'Very Low Definition FLV'};
  1310. var vjVideoList = {};
  1311. var vjVideoFound = false;
  1312. var vjVideoPart, myVideoCode, vjVideo, vjVideoCodePart, vjVideoPattern, vjVideoLocation;
  1313. if (vjVideoShapes) {
  1314. vjVideoPart = vjVideoID2 + '/' + vjVideoID + '/' + vjVideoTitle;
  1315. for (var vjVideoCode in vjVideoFormats) {
  1316. if (vjVideoCode.indexOf('VJ') != -1) vjVideoCodePart = vjVideoCode.substring(0, 6);
  1317. else vjVideoCodePart = vjVideoCode.substring(0, 3);
  1318. vjVideoPattern = 'Code="' + vjVideoCodePart + '"\\s+Locations="(.*?),';
  1319. vjVideoLocation = vjVideoShapes.match(vjVideoPattern);
  1320. vjVideoLocation = (vjVideoLocation) ? vjVideoProtocol + '//' + vjVideoLocation[1] : null;
  1321. if (vjVideoLocation) {
  1322. if (!vjVideoFound) vjVideoFound = true;
  1323. vjVideo = vjVideoLocation + '/' + vjVideoPart + '__' + vjVideoCode;
  1324. myVideoCode = vjVideoFormats[vjVideoCode];
  1325. vjVideoList[myVideoCode] = vjVideo;
  1326. }
  1327. }
  1328. }
  1329.  
  1330. if (vjVideoFound) {
  1331. /* Create Saver */
  1332. var vjDefaultVideo = 'Low Definition MP4';
  1333. saver = {'saverSocket': vjPlayerWindow, 'videoList': vjVideoList, 'videoSave': vjDefaultVideo, 'saverWidth': vjPlayerWidth};
  1334. option['definition'] = 'SD';
  1335. option['definitions'] = ['Standard Definition', 'Low Definition', 'Very Low Definition'];
  1336. option['containers'] = ['MP4', 'FLV', 'Any'];
  1337. createMySaver ();
  1338. }
  1339. else {
  1340. saver = {'saverSocket': vjPlayerWindow, 'saverWidth': vjPlayerWidth, 'warnMess': '!videos'};
  1341. createMySaver ();
  1342. }
  1343. }
  1344. else {
  1345. saver = {'saverSocket': vjPlayerWindow, 'saverWidth': vjPlayerWidth, 'warnMess': '!content'};
  1346. createMySaver ();
  1347. }
  1348. }
  1349. if (saver['saverPanel'] && vjPlayerWidth == 768) {
  1350. styleMyElement(saver['saverPanel'], {marginTop: '10px'});
  1351. }
  1352.  
  1353. }
  1354.  
  1355. // =====Blip===== //
  1356.  
  1357. else if (page.url.indexOf('blip.tv') != -1) {
  1358.  
  1359. /* Get Page Type */
  1360. var blipPageType = getMyContent (page.url, 'meta\\s+property="video:tag"\\s+content="(.*?)"', false);
  1361. if (!blipPageType || blipPageType.indexOf('episode') == -1) return;
  1362.  
  1363. /* Get Player Window */
  1364. var blipSaverWidth;
  1365. var blipPlayerWindow = getMyElement ('', 'div', 'class', 'Theater', 0, false) || getMyElement ('', 'div', 'id', 'ErrorWrap', -1, false);
  1366. if (!blipPlayerWindow) {
  1367. blipPlayerWindow = getMyElement ('', 'div', 'id', 'PlayerEmbed', -1, false);
  1368. blipSaverWidth = 596;
  1369. }
  1370. else {
  1371. blipSaverWidth = 960;
  1372. }
  1373. if (!blipPlayerWindow) {
  1374. showMyMessage ('!player');
  1375. }
  1376. else {
  1377. /* My Saver Socket */
  1378. var blipSaverSocket = createMyElement ('div', '', '', '', '');
  1379. styleMyElement (blipSaverSocket, {width: blipSaverWidth + 'px', textAlign: 'center', margin: '0px auto'});
  1380. appendMyElement (blipPlayerWindow, blipSaverSocket);
  1381.  
  1382. /* Get Videos Content */
  1383. var blipVideosContent = getMyContent(page.url + '?skin=json', '"additionalMedia":\\[(.*?)\\]', false);
  1384.  
  1385. /* Get Videos */
  1386. if (blipVideosContent) {
  1387. var blipVideoList = {};
  1388. var blipVideoFound = false;
  1389. var blipMimeTypes = {'video/x-m4v': 'M4V', 'video/quicktime': 'MOV', 'video/mp4': 'MP4', 'video/x-flv': 'FLV'};
  1390. var blipVideos = blipVideosContent.split(',{');
  1391. var blipVideoURL, blipVideoMime, blipVideoHeight, blipVideoRole, blipVideoDef, blipVideoCode;
  1392. var blipDefaultVideo = 'Low Definition MP4';
  1393. for (var blipV = 0; blipV < blipVideos.length; blipV++) {
  1394. blipVideoMime = blipVideos[blipV].match(/"primary_mime_type":"(.*?)"/);
  1395. blipVideoMime = (blipVideoMime) ? blipVideoMime[1] : null;
  1396. if (blipMimeTypes[blipVideoMime]) {
  1397. blipVideoURL = blipVideos[blipV].match(/"url":"(.*?)"/);
  1398. blipVideoURL = (blipVideoURL) ? blipVideoURL[1] : null;
  1399. blipVideoHeight = blipVideos[blipV].match(/"media_height":"(.*?)"/);
  1400. blipVideoHeight = (blipVideoHeight) ? blipVideoHeight[1] : null;
  1401. blipVideoRole = blipVideos[blipV].match(/"role":"(.*?)"/);
  1402. blipVideoRole = (blipVideoRole) ? blipVideoRole[1] : null;
  1403. if (blipVideoURL && blipVideoHeight && blipVideoRole) {
  1404. if (!blipVideoFound) blipVideoFound = true;
  1405. if (blipVideoHeight >= 200 && blipVideoHeight < 400) blipVideoDef = 'Low Definition';
  1406. else if (blipVideoHeight >= 400 && blipVideoHeight < 700) blipVideoDef = 'Standard Definition';
  1407. else if (blipVideoHeight >= 700) blipVideoDef = 'High Definition';
  1408. blipVideoCode = blipVideoDef + ' ' + blipMimeTypes[blipVideoMime];
  1409. blipVideoList[blipVideoCode] = blipVideoURL;
  1410. if (blipVideoRole == 'Source') blipDefaultVideo = blipVideoCode;
  1411. }
  1412. }
  1413. }
  1414.  
  1415. if (blipVideoFound) {
  1416. /* Create Saver */
  1417. saver = {'saverSocket': blipSaverSocket, 'videoList': blipVideoList, 'videoSave': blipDefaultVideo, 'saverWidth': blipSaverWidth};
  1418. option['definitions'] = ['High Definition', 'Standard Definition', 'Low Definition'];
  1419. option['containers'] = ['MP4', 'M4V', 'MOV', 'FLV', 'Any'];
  1420. createMySaver ();
  1421. }
  1422. else {
  1423. saver = {'saverSocket': blipPlayerWindow, 'saverWidth': blipSaverWidth, 'warnMess': '!videos'};
  1424. createMySaver ();
  1425. }
  1426. }
  1427. else {
  1428. saver = {'saverSocket': blipPlayerWindow, 'saverWidth': blipSaverWidth, 'warnMess': '!content'};
  1429. createMySaver ();
  1430. }
  1431. }
  1432.  
  1433. }
  1434.  
  1435. // =====Veoh===== //
  1436.  
  1437. else if (page.url.indexOf('veoh.com/watch') != -1) {
  1438.  
  1439. /* Get Video Availability */
  1440. if (getMyElement ('', 'div', 'class', 'veoh-video-player-error', 0, false)) return;
  1441.  
  1442. /* Get Player Window */
  1443. var vePlayerWindow = getMyElement ('', 'div', 'id', 'videoPlayerContainer', -1, false);
  1444. if (!vePlayerWindow) {
  1445. showMyMessage ('!player');
  1446. }
  1447. else {
  1448. /* Get Videos Content */
  1449. var veVideosContent = getMyContent (page.url, '__watch.videoDetailsJSON = \'\\{(.*?)\\}', false);
  1450. veVideosContent = cleanMyContent (veVideosContent, true);
  1451.  
  1452. /* Restyle Player Window */
  1453. styleMyElement (vePlayerWindow, {margin: '0px 0px 20px 0px'});
  1454.  
  1455. /* Get Videos */
  1456. if (veVideosContent) {
  1457. var veVideoFormats = {'fullPreviewHashLowPath': 'Very Low Definition MP4', 'fullPreviewHashHighPath': 'Low Definition MP4'};
  1458. var veVideoList = {};
  1459. var veVideoFound = false;
  1460. var veVideoParser, veVideoParse, veVideo, myVideoCode;
  1461. for (var veVideoCode in veVideoFormats) {
  1462. veVideoParser = veVideoCode + '":"(.*?)"';
  1463. veVideoParse = veVideosContent.match (veVideoParser);
  1464. veVideo = (veVideoParse) ? veVideoParse[1] : null;
  1465. if (veVideo) {
  1466. if (!veVideoFound) veVideoFound = true;
  1467. myVideoCode = veVideoFormats[veVideoCode];
  1468. veVideoList[myVideoCode] = veVideo;
  1469. }
  1470. }
  1471.  
  1472. if (veVideoFound) {
  1473. /* Create Saver */
  1474. var veDefaultVideo = 'Low Definition MP4';
  1475. saver = {'saverSocket': vePlayerWindow, 'videoList': veVideoList, 'videoSave': veDefaultVideo, 'saverWidth': 640};
  1476. feature['container'] = false;
  1477. feature['fullsize'] = false;
  1478. option['definition'] = 'LD';
  1479. option['definitions'] = ['Low Definition', 'Very Low Definition'];
  1480. option['containers'] = ['MP4'];
  1481. createMySaver ();
  1482. }
  1483. else {
  1484. saver = {'saverSocket': vePlayerWindow, 'saverWidth': 640};
  1485. var veVideoSource = getMyContent(page.url, '"videoContentSource":"(.*?)"', false);
  1486. if (veVideoSource == 'YouTube') var ytVideoId = getMyContent(page.url, '"videoId":"yapi-(.*?)"', false);
  1487. if (ytVideoId) {
  1488. var ytVideoLink = 'http://youtube.com/watch?v=' + ytVideoId;
  1489. saver['warnMess'] = 'embed';
  1490. saver['warnContent'] = ytVideoLink;
  1491. styleMyElement(vePlayerWindow, {margin: '0px 0px 20px 0px'});
  1492. }
  1493. else saver['warnMess'] = '!videos';
  1494. createMySaver ();
  1495. }
  1496. }
  1497. else {
  1498. saver = {'saverSocket': vePlayerWindow, 'saverWidth': 640, 'warnMess': '!content'};
  1499. createMySaver ();
  1500. }
  1501. }
  1502.  
  1503. }
  1504.  
  1505. // =====Crackle===== //
  1506.  
  1507. else if (page.url.indexOf('crackle.com/') != -1) {
  1508.  
  1509. /* Get Page Type */
  1510. var crPageType = getMyContent (page.url, 'meta\\s+property="og:type"\\s+content="(.*?)"', false);
  1511. if (!crPageType || crPageType.indexOf('video') == -1) return;
  1512.  
  1513. /* Get Player Window */
  1514. var crPlayerWindow = getMyElement ('', 'div', 'class', 'player-stage-area1', 0, false);
  1515. if (!crPlayerWindow) {
  1516. showMyMessage ('!player');
  1517. }
  1518. else {
  1519. /* Restyle */
  1520. if (!getMyElement(crPlayerWindow, 'div', 'class', 'clearall', 0, false)) {
  1521. var myClearFix = createMyElement ('div', '', '', '', '');
  1522. styleMyElement (myClearFix, {clear: 'both'});
  1523. appendMyElement (crPlayerWindow, myClearFix);
  1524. }
  1525. var crContent = getMyElement ('', 'div', 'id', 'content', -1, false);
  1526. styleMyElement (crContent, {marginTop: '30px'});
  1527. var crPlayerImage = getMyElement ('', 'div', 'class', 'image-stage-area', 0, false);
  1528. if (crPlayerImage) removeMyElement (crPlayerImage.parentNode, crPlayerImage);
  1529.  
  1530. /* Get Videos Content */
  1531. var crVideoPath = getMyContent (page.url, 'images-us-am.crackle.com\/(.*?_)tnl', false);
  1532. if (!crVideoPath) {
  1533. var crVideoID = getMyContent (page.url, 'mediaId:\\s*(.*?),', false);
  1534. if (crVideoID) {
  1535. var crVidWallCache = page.win.location.protocol + '//' + page.win.location.hostname + '/app/vidwallcache.aspx?flags=-1&fm=' + crVideoID + '&partner=20';
  1536. crVideoPath = getMyContent (crVidWallCache, '\\sp="(.*?)"', false);
  1537. }
  1538. }
  1539.  
  1540. /* Get Videos */
  1541. if (crVideoPath) {
  1542. var crVideoList = {};
  1543. var crVideoFormats = {'360p.mp4': 'Low Definition MP4', '480p.mp4': 'Standard Definition MP4'};
  1544. var crVideoThumb, crVideo, myVideoCode;
  1545. for (var crVideoCode in crVideoFormats) {
  1546. crVideo = 'http://media-us-am.crackle.com/' + crVideoPath + crVideoCode;
  1547. myVideoCode = crVideoFormats[crVideoCode];
  1548. crVideoList[myVideoCode] = crVideo;
  1549. }
  1550.  
  1551. /* Create Saver */
  1552. var crDefaultVideo = 'Low Definition MP4';
  1553. saver = {'saverSocket': crPlayerWindow, 'videoList': crVideoList, 'videoSave': crDefaultVideo, 'saverWidth': 970};
  1554. feature['container'] = false;
  1555. option['definition'] = 'SD';
  1556. option['definitions'] = ['Standard Definition', 'Low Definition'];
  1557. option['containers'] = ['MP4'];
  1558. createMySaver ();
  1559.  
  1560. /* Fix Thumbnails */
  1561. var crThumbs = getMyElement('', 'div', 'class', 'thumbnail', -1, false);
  1562. for (var crT = 0; crT < crThumbs.length; crT++) {
  1563. if (crThumbs[crT].innerHTML.indexOf('AddObjectToQueue') != -1) {
  1564. var crLink = crThumbs[crT].innerHTML.match(/,\s+\d+,\s+'(.*?)'/);
  1565. crLink = (crLink) ? crLink[1] : null;
  1566. var crImg = crThumbs[crT].innerHTML.match(/src="(.*?)"/);
  1567. crImg = (crImg) ? crImg[1] : null;
  1568. crThumbs[crT].innerHTML = '<img src="' + crImg + '" onclick="window.location.href=\'' + crLink + '\'" style="cursor:pointer">';
  1569. }
  1570. }
  1571. }
  1572. else {
  1573. saver = {'saverSocket': crPlayerWindow, 'saverWidth': 970, 'warnMess': '!videos'};
  1574. createMySaver ();
  1575. }
  1576.  
  1577. }
  1578.  
  1579. }
  1580.  
  1581. // =====Viki===== //
  1582.  
  1583. else if (page.url.indexOf('viki.com/videos') != -1) {
  1584.  
  1585. /* Get Player Window */
  1586. var vkSaverWindow = getMyElement ('', 'div', 'class', 'card-content', 0, false);
  1587. if (!vkSaverWindow) {
  1588. showMyMessage ('!player');
  1589. }
  1590. else {
  1591. /* Get Video ID */
  1592. var vkVideoID = page.url.match(/videos\/(.*?)v/);
  1593. vkVideoID = (vkVideoID) ? vkVideoID[1] : null;
  1594.  
  1595. /* Get Videos Content */
  1596. var vkVideosContent;
  1597. if (vkVideoID) vkVideosContent = getMyContent (page.win.location.protocol + '//' + page.win.location.host + '/player5_fragment/' + vkVideoID + 'v.json', 'TEXT', false);
  1598.  
  1599. /* Saver Width*/
  1600. var vkSaverWith = parseInt(vkSaverWindow.clientWidth) - 20;
  1601.  
  1602. /* Get Videos */
  1603. if (vkVideosContent) {
  1604. var vkVideoList = {};
  1605. var vkVideo = vkVideosContent.match(/"video_url":"(.*?)"/);
  1606. vkVideo = (vkVideo) ? vkVideo[1] : null;
  1607.  
  1608. /* Create Saver */
  1609. if (vkVideo) {
  1610. var vkDefaultVideo = 'Low Definition MP4';
  1611. vkVideoList[vkDefaultVideo] = vkVideo
  1612. saver = {'saverSocket': vkSaverWindow, 'videoList': vkVideoList, 'videoSave': vkDefaultVideo, 'saverWidth': vkSaverWith};
  1613. feature['definition'] = false;
  1614. feature['container'] = false;
  1615. option['definition'] = 'LD';
  1616. option['definitions'] = ['Low Definition'];
  1617. option['containers'] = ['MP4'];
  1618. createMySaver ();
  1619. }
  1620. else {
  1621. saver = {'saverSocket': vkPlayerWindow, 'saverWidth': vkSaverWith, 'warnMess': '!videos'};
  1622. createMySaver ();
  1623. }
  1624. }
  1625. else {
  1626. saver = {'saverSocket': vkPlayerWindow, 'saverWidth': vkSaverWith, 'warnMess': '!content'};
  1627. createMySaver ();
  1628. }
  1629. }
  1630.  
  1631. }
  1632.  
  1633. // =====IMDB===== //
  1634.  
  1635. else if (page.url.indexOf('imdb.com') != -1) {
  1636.  
  1637. /* Redirect To Video Page */
  1638. if (page.url.indexOf('imdb.com/video/') == -1) {
  1639. page.doc.addEventListener('click', function(e) {
  1640. var p = e.target.parentNode;
  1641. while (p) {
  1642. if (p.tagName === 'A' && p.href.indexOf('/video/imdb') != -1) {
  1643. page.win.location.href = p.href.replace(/imdb\/inline.*/, '');
  1644. }
  1645. p = p.parentNode;
  1646. }
  1647. }, false);
  1648. return;
  1649. }
  1650.  
  1651. /* Get Player Window */
  1652. var imdbPlayerWindow = getMyElement ('', 'div', 'id', 'player-article', -1, false);
  1653. if (!imdbPlayerWindow) {
  1654. showMyMessage ('!player');
  1655. }
  1656. else {
  1657. /* Get Videos Content */
  1658. var imdbVideoList = {};
  1659. var imdbVideoFormats = {'1': 'Low Definition MP4', '2': 'Standard Definition MP4', '3': 'High Definition MP4'};
  1660. var imdbDefaultVideo, imdbURL, imdbVideo, myVideoCode;
  1661. var imdbVideoFound = false;
  1662. var imdbVideoRTMP = false;
  1663. var imdbPageURL = page.url.replace(/\?.*$/, '').replace(/\/$/, '');
  1664. for (var imdbVideoCode in imdbVideoFormats) {
  1665. imdbURL = imdbPageURL + '/player?uff=' + imdbVideoCode;
  1666. imdbVideo = getMyContent (imdbURL, 'so.addVariable\\("file",\\s+"(.*?)"\\);', true);
  1667. if (imdbVideo) {
  1668. if (imdbVideo.indexOf('rtmp') != -1) {
  1669. if (!imdbVideoRTMP) imdbVideoRTMP = true;
  1670. }
  1671. else {
  1672. if (!imdbVideoFound) imdbVideoFound = true;
  1673. myVideoCode = imdbVideoFormats[imdbVideoCode];
  1674. imdbVideoList[myVideoCode] = imdbVideo;
  1675. if (!imdbDefaultVideo) imdbDefaultVideo = myVideoCode;
  1676. }
  1677. }
  1678. }
  1679.  
  1680. if (imdbVideoFound) {
  1681. /* Create Saver */
  1682. saver = {'saverSocket': imdbPlayerWindow, 'videoList': imdbVideoList, 'videoSave': imdbDefaultVideo, 'saverWidth': 1010};
  1683. feature['container'] = false;
  1684. option['definitions'] = ['High Definition', 'Standard Definition', 'Low Definition'];
  1685. option['containers'] = ['MP4'];
  1686. createMySaver ();
  1687. }
  1688. else {
  1689. if (imdbVideoRTMP) {
  1690. saver = {'saverSocket': imdbPlayerWindow, 'saverWidth': 1010, 'warnMess': '!support'};
  1691. createMySaver ();
  1692. }
  1693. else {
  1694. saver = {'saverSocket': imdbPlayerWindow, 'saverWidth': 1010, 'warnMess': '!videos'};
  1695. createMySaver ();
  1696. }
  1697. }
  1698. }
  1699.  
  1700. }
  1701.  
  1702. // =====Facebook===== //
  1703.  
  1704. else if (page.url.match('facebook.com/(video.php|.*/videos/)')) {
  1705.  
  1706. /* Get Player Window */
  1707. var fbPlayerWindow = getMyElement ('', 'div', 'class', 'stageButtons', 0, false);
  1708. if (!fbPlayerWindow) {
  1709. showMyMessage ('!player');
  1710. }
  1711. else {
  1712. /* Get Videos Content */
  1713. var fbVideosContent = getMyContent(page.url, '"params","(.*?)"', false);
  1714. var fbPattern = /\\u([\d\w]{4})/gi;
  1715. fbVideosContent = fbVideosContent.replace(fbPattern, function (match, group) {
  1716. return String.fromCharCode(parseInt(group, 16));
  1717. });
  1718. fbVideosContent = unescape(fbVideosContent);
  1719.  
  1720. /* Get Videos */
  1721. if (fbVideosContent) {
  1722. var fbVideoList = {};
  1723. var fbVideoFormats = {'sd_src': 'Low Definition MP4', 'hd_src': 'High Definition MP4'};
  1724. var fbVideoFound = false;
  1725. var fbVideoPattern, fbVideo, myVideoCode, fbVideoThumb, fbDefaultVideo;
  1726. for (var fbVideoCode in fbVideoFormats) {
  1727. fbVideoPattern = '"' + fbVideoCode + '":"(.*?)"';
  1728. fbVideo = fbVideosContent.match(fbVideoPattern);
  1729. fbVideo = (fbVideo) ? fbVideo[1] : null;
  1730. if (fbVideo) {
  1731. fbVideo = cleanMyContent(fbVideo, false);
  1732. if (!fbVideoFound) fbVideoFound = true;
  1733. myVideoCode = fbVideoFormats[fbVideoCode];
  1734. if (fbVideo.indexOf('.flv') != -1) myVideoCode = myVideoCode.replace('MP4', 'FLV');
  1735. fbVideoList[myVideoCode] = fbVideo;
  1736. if (!fbDefaultVideo) fbDefaultVideo = myVideoCode;
  1737. }
  1738. }
  1739.  
  1740. if (fbVideoFound) {
  1741. /* Create Saver */
  1742. saver = {'saverSocket': fbPlayerWindow, 'videoList': fbVideoList, 'videoSave': fbDefaultVideo, 'saverWidth': 760};
  1743. option['definitions'] = ['High Definition', 'Low Definition'];
  1744. option['containers'] = ['MP4', 'FLV', 'Any'];
  1745. createMySaver ();
  1746. }
  1747. else {
  1748. saver = {'saverSocket': fbPlayerWindow, 'saverWidth': 760, 'warnMess': '!videos'};
  1749. createMySaver ();
  1750. }
  1751. }
  1752. else {
  1753. saver = {'saverSocket': fbPlayerWindow, 'saverWidth': 760, 'warnMess': '!content'};
  1754. createMySaver ();
  1755. }
  1756. }
  1757.  
  1758. }
  1759.  
  1760. // =====YahooScreen===== //
  1761.  
  1762. else if (page.url.indexOf('screen.yahoo.com') != -1) {
  1763.  
  1764. /* Get Player Window */
  1765. var ysPlayerWindow = getMyElement ('', 'div', 'class', 'vp-wd', 0, false);
  1766. if (!ysPlayerWindow) {
  1767. showMyMessage ('!player');
  1768. }
  1769. else {
  1770. /* Restyle Player Window */
  1771. styleMyElement (ysPlayerWindow, {height: '100%'});
  1772.  
  1773. /* Get Videos Content */
  1774. var ysVideosContent;
  1775. var ysVideoID = getMyContent (page.url, '"first_videoid":"(.*?)"', false);
  1776. if (ysVideoID) ysVideosContent = getMyContent('https://video.media.yql.yahoo.com/v1/video/sapi/streams/' + ysVideoID + '?protocol=http&region=US', '"streams":\\[(.*?)\\]', false);
  1777.  
  1778. /* Get Videos */
  1779. if (ysVideosContent) {
  1780. var ysVideoList = {};
  1781. var ysVideoFormats = {'240': 'Very Low Definition', '360': 'Low Definition', '432': 'Low Definition', '540': 'Standard Definition', '720': 'High Definition', '1080': 'Full High Definition'};
  1782. var ysVideoFound;
  1783. var ysVideoParts = ysVideosContent.split('},');
  1784. var ysVideoPart, ysVideoPath, ysVideoHost, ysVideoHeight, myVideoCode;
  1785. for (var i = 0; i < ysVideoParts.length; i++) {
  1786. ysVideoPart = ysVideoParts[i];
  1787. ysVideoPath = ysVideoPart.match(/"path":"(.*?)"/);
  1788. ysVideoPath = (ysVideoPath) ? ysVideoPath[1] : null;
  1789. ysVideoHost = ysVideoPart.match(/"host":"(.*?)"/);
  1790. ysVideoHost = (ysVideoHost) ? ysVideoHost[1] : null;
  1791. ysVideoHeight = ysVideoPart.match(/"height":(\d+),/);
  1792. ysVideoHeight = (ysVideoHeight) ? ysVideoHeight[1] : null;
  1793. ysVideoType = ysVideoPart.match(/"mime_type":"(.*?)"/);
  1794. ysVideoType = (ysVideoType) ? ysVideoType[1] : null;
  1795. if (ysVideoPath && ysVideoHost && ysVideoHeight && ysVideoType) {
  1796. for (var ysVideoCode in ysVideoFormats) {
  1797. if (ysVideoCode == ysVideoHeight) {
  1798. if (!ysVideoFound) ysVideoFound = true;
  1799. myVideoCode = ysVideoFormats[ysVideoCode]
  1800. if (ysVideoType == 'video/mp4') myVideoCode += ' MP4';
  1801. else if (ysVideoType == 'video/webm') myVideoCode += ' WebM';
  1802. ysVideoList[myVideoCode] = ysVideoHost + ysVideoPath;
  1803. }
  1804. }
  1805. }
  1806. }
  1807.  
  1808. if (ysVideoFound) {
  1809. /* Create Saver */
  1810. var ysDefaultVideo = 'Low Definition MP4';
  1811. saver = {'saverSocket': ysPlayerWindow, 'videoList': ysVideoList, 'videoSave': ysDefaultVideo, 'saverWidth': 640};
  1812. option['definitions'] = ['Full High Definition', 'High Definition', 'Standard Definition', 'Low Definition', 'Very Low Definition'];
  1813. option['containers'] = ['MP4', 'WebM', 'Any'];
  1814. createMySaver ();
  1815. styleMyElement(saver['saverPanel'], {padding: '0px 0px 7px 0px'});
  1816. }
  1817. else {
  1818. saver = {'saverSocket': ysPlayerWindow, 'saverWidth': 640, 'warnMess': '!videos'};
  1819. createMySaver ();
  1820. }
  1821. }
  1822. else {
  1823. saver = {'saverSocket': ysPlayerWindow, 'saverWidth': 640, 'warnMess': '!content'};
  1824. createMySaver ();
  1825. }
  1826. }
  1827.  
  1828. }
  1829.  
  1830. })();