SaveTube

Download videos from video sharing web sites.

当前为 2016-04-16 提交的版本,查看 最新版本

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