SaveTube

Download videos from video sharing web sites.

当前为 2014-08-01 提交的版本,查看 最新版本

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