SaveTube

Download videos from video sharing web sites.

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

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