SaveTube

Download videos from video sharing web sites.

当前为 2014-11-22 提交的版本,查看 最新版本

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