SaveTube

Download videos from video sharing web sites.

当前为 2014-09-07 提交的版本,查看 最新版本

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