SaveTube

Download videos from video sharing web sites.

当前为 2016-03-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name SaveTube
  3. // @version 2016.03.25
  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(/&sig=/)) ytVideo = ytVideo.replace (/&sig=/, '&signature=');
  750. else if (ytVideo.match(/&s=/)) {
  751. var ytSig = ytVideo.match(/&s=(.*?)(&|$)/);
  752. if (ytSig) {
  753. var s = ytSig[1];
  754. s = ytDecryptSignature(s);
  755. if (s) ytVideo = ytVideo.replace(/&s=.*?(&|$)/, '&signature=' + s + '$1');
  756. else ytVideo = '';
  757. }
  758. else ytVideo = '';
  759. }
  760. ytVideo = cleanMyContent (ytVideo, true);
  761. if (ytVideo.indexOf('ratebypass') == -1) ytVideo += '&ratebypass=yes';
  762. if (ytVideo && ytVideo.indexOf('http') == 0) {
  763. if (!ytVideoFound) ytVideoFound = true;
  764. ytVideoList[myVideoCode] = ytVideo;
  765. }
  766. }
  767. }
  768. }
  769.  
  770. if (ytVideoFound) {
  771. /* Create Saver */
  772. feature['autoget'] = true;
  773. ytSaver();
  774. createMySaver();
  775. }
  776. else {
  777. saver = {'saverSocket': ytPlayerWindow, 'saverWidth': 640};
  778. if (ytVideosContent.indexOf('conn=rtmp') != -1) saver['warnMess'] = '!support';
  779. else saver['warnMess'] = '!videos';
  780. createMySaver();
  781. }
  782. }
  783.  
  784. /* Parse HLS */
  785. function ytHLS() {
  786. var ytHLSFormats = {
  787. '92': 'Very Low Definition MP4',
  788. '93': 'Low Definition MP4',
  789. '94': 'Standard Definition MP4',
  790. '95': 'High Definition MP4',
  791. '96': 'Full High Definition MP4'
  792. };
  793. ytVideoList["Any Definition MP4"] = ytHLSVideos;
  794. if (ytHLSContent) {
  795. var ytHLSVideo, ytVideoCodeParse, ytVideoCode, myVideoCode;
  796. var ytHLSMatcher = new RegExp('(http.*?m3u8)', 'g');
  797. ytHLSVideos = ytHLSContent.match(ytHLSMatcher);
  798. if (ytHLSVideos) {
  799. for (var i = 0; i < ytHLSVideos.length; i++) {
  800. ytHLSVideo = ytHLSVideos[i];
  801. ytVideoCodeParse = ytHLSVideo.match(/\/itag\/(\d{1,3})\//);
  802. ytVideoCode = (ytVideoCodeParse) ? ytVideoCodeParse[1] : null;
  803. if (ytVideoCode) {
  804. myVideoCode = ytHLSFormats[ytVideoCode];
  805. if (myVideoCode && ytHLSVideo) {
  806. ytVideoList[myVideoCode] = ytHLSVideo;
  807. }
  808. }
  809. }
  810. }
  811. }
  812.  
  813. /* Create Saver */
  814. ytVideoTitle = null;
  815. ytDefaultVideo = 'Any Definition MP4';
  816. ytSaver();
  817. createMySaver();
  818. }
  819.  
  820. /* Get Videos */
  821. var ytVideoList = {};
  822. if (ytVideosContent) {
  823. if (ytVideosContent.match(/&s=/) || ytVideosContent.match(/,s=/) || ytVideosContent.match(/u0026s=/)) {
  824. var ytScriptURL = getMyContent(page.url, '"js":\\s*"(.*?)"', true);
  825. if (!ytScriptURL) ytScriptURL = getMyContent(page.url.replace(/watch.*?v=/, 'embed/').replace(/&.*$/, ''), '"js":\\s*"(.*?)"', true);
  826. if (ytScriptURL) {
  827. ytScriptURL = page.win.location.protocol + ytScriptURL;
  828. try {
  829. ytScriptSrc = getMyContent(ytScriptURL, 'TEXT', false);
  830. if (ytScriptSrc) ytDecryptFunction();
  831. ytVideos();
  832. }
  833. catch (e) {
  834. try {
  835. GM_xmlhttpRequest({
  836. method: 'GET',
  837. url: ytScriptURL,
  838. onload: function(response) {
  839. if (response.readyState === 4 && response.status === 200 && response.responseText) {
  840. ytScriptSrc = response.responseText;
  841. ytDecryptFunction();
  842. ytVideos();
  843. }
  844. else {
  845. saver = {
  846. 'saverSocket': ytPlayerWindow,
  847. 'saverWidth': 640,
  848. 'warnMess': 'other',
  849. 'warnContent': '<b>SaveTube:</b> Couldn\'t get the signature content. Please report it <a href="' + contact + '" style="color:#00892C">here</a>.'
  850. };
  851. createMySaver ();
  852. }
  853. },
  854. onerror: function() {
  855. saver = {
  856. 'saverSocket': ytPlayerWindow,
  857. 'saverWidth': 640,
  858. 'warnMess': 'other',
  859. 'warnContent': '<b>SaveTube:</b> Couldn\'t make the request. Make sure your browser user scripts extension supports cross-domain requests.'
  860. };
  861. createMySaver ();
  862. }
  863. });
  864. }
  865. catch (e) {
  866. saver = {
  867. 'saverSocket': ytPlayerWindow,
  868. 'saverWidth': 640,
  869. 'warnMess': 'other',
  870. 'warnContent': '<b>SaveTube:</b> Couldn\'t make the request. Make sure your browser user scripts extension supports cross-domain requests.'
  871. };
  872. createMySaver ();
  873. }
  874. }
  875. }
  876. else {
  877. saver = {
  878. 'saverSocket': ytPlayerWindow,
  879. 'saverWidth': 640,
  880. 'warnMess': 'other',
  881. 'warnContent': '<b>SaveTube:</b> Couldn\'t get the signature link. Please report it <a href="' + contact + '" style="color:#00892C">here</a>.'
  882. };
  883. createMySaver ();
  884. }
  885. }
  886. else {
  887. ytVideos();
  888. }
  889. }
  890. else {
  891. if (ytHLSVideos) {
  892. try {
  893. ytHLSContent = getMyContent(ytHLSVideos, 'TEXT', false);
  894. ytHLS();
  895. }
  896. catch (e) {
  897. try {
  898. GM_xmlhttpRequest({
  899. method: 'GET',
  900. url: ytHLSVideos,
  901. onload: function(response) {
  902. if (response.readyState === 4 && response.status === 200 && response.responseText) {
  903. ytHLSContent = response.responseText;
  904. }
  905. ytHLS();
  906. },
  907. onerror: function() {
  908. ytHLS();
  909. }
  910. });
  911. }
  912. catch (e) {
  913. ytHLS();
  914. }
  915. }
  916. }
  917. else {
  918. saver = {'saverSocket': ytPlayerWindow, 'saverWidth': 640, 'warnMess': '!content'};
  919. createMySaver ();
  920. }
  921. }
  922. }
  923.  
  924. }
  925.  
  926. // =====DailyMotion===== //
  927.  
  928. else if (page.url.indexOf('dailymotion.com/video') != -1 || page.url.indexOf('dailymotion.com/playlist') != -1) {
  929.  
  930. /* Redirect Playlist To Video */
  931. if (page.url.indexOf('dailymotion.com/playlist') != -1 && page.url.indexOf('#video=') != -1) {
  932. page.win.location.href = page.url.replace(/playlist.*#/, '').replace("=", "/");
  933. }
  934.  
  935. /* Get Player Window */
  936. var dmPlayerWindow = getMyElement ('', 'div', 'class', 'player-container', 0, false);
  937. if (!dmPlayerWindow) {
  938. showMyMessage ('!player');
  939. }
  940. else {
  941. /* Get Videos Content */
  942. var dmEmbed;
  943. if (page.url.indexOf('dailymotion.com/video') != -1) dmEmbed = page.url.replace(/\/video\//, "/embed/video/");
  944. else dmEmbed = page.url.replace(/playlist.*=/, "embed/video/");
  945. dmVideosContent = getMyContent (dmEmbed, '"qualities":\\{(.*?)\\]\\},', false);
  946.  
  947. /* Get Videos */
  948. if (dmVideosContent) {
  949. var dmVideoFormats = {'240': 'Very Low Definition MP4', '380': 'Low Definition MP4', '480': 'Standard Definition MP4',
  950. '720': 'High Definition MP4', '1080': 'Full High Definition MP4'};
  951. var dmVideoList = {};
  952. var dmVideoFound = false;
  953. var dmVideoParser, dmVideoParse, myVideoCode, dmVideo;
  954. for (var dmVideoCode in dmVideoFormats) {
  955. dmVideoParser = '"' + dmVideoCode + '".*?"url":"(.*?)"';
  956. dmVideoParse = dmVideosContent.match (dmVideoParser);
  957. dmVideo = (dmVideoParse) ? dmVideoParse[1] : null;
  958. if (dmVideo) {
  959. if (!dmVideoFound) dmVideoFound = true;
  960. dmVideo = cleanMyContent(dmVideo, true);
  961. myVideoCode = dmVideoFormats[dmVideoCode];
  962. if (!dmVideoList[myVideoCode]) dmVideoList[myVideoCode] = dmVideo;
  963. }
  964. }
  965.  
  966. if (dmVideoFound) {
  967. /* Create Saver */
  968. var dmDefaultVideo = 'Low Definition MP4';
  969. saver = {'saverSocket': dmPlayerWindow, 'videoList': dmVideoList, 'videoSave': dmDefaultVideo, 'saverWidth': 800};
  970. feature['container'] = false;
  971. option['definitions'] = ['Full High Definition', 'High Definition', 'Standard Definition', 'Low Definition', 'Very Low Definition'];
  972. option['containers'] = ['MP4'];
  973. createMySaver ();
  974. }
  975. else {
  976. saver = {'saverSocket': dmPlayerWindow, 'saverWidth': 800, 'warnMess': '!videos'};
  977. createMySaver ();
  978. }
  979. }
  980. else {
  981. saver = {'saverSocket': dmPlayerWindow, 'saverWidth': 800, 'warnMess': '!content'};
  982. createMySaver ();
  983. }
  984. }
  985.  
  986. }
  987.  
  988. // =====Vimeo===== //
  989.  
  990. 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+/)) {
  991.  
  992. /* Multi Video Page */
  993. if (getMyElement('', 'div', 'class', 'player_container', -1, false).length > 1) return;
  994.  
  995. /* Video Page Type */
  996. 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;
  997.  
  998. /* Saver Width */
  999. var viSaverWidth = 960;
  1000. if (page.url.indexOf('/channels/') != -1 && page.url.indexOf('/channels/staffpicks') == -1) {
  1001. viSaverWidth = 630;
  1002. }
  1003. if (viVideoPage) viSaverWidth = 700;
  1004.  
  1005. /* Get Player Window */
  1006. var viPlayerWindow;
  1007. if (viVideoPage) viPlayerWindow = getMyElement ('', 'div', 'class', 'clip_info-actions', 0, false);
  1008. else viPlayerWindow = getMyElement ('', 'div', 'class', 'player_container', 0, false);
  1009. if (!viPlayerWindow) {
  1010. showMyMessage ('!player');
  1011. }
  1012. else {
  1013. /* Restyle Player Window */
  1014. if (!viVideoPage) styleMyElement (viPlayerWindow, {margin: '0px 0px 20px 0px'});
  1015.  
  1016. /* Get Content Source */
  1017. var viVideoSource = getMyContent (page.url, '"config_url":"(.*?)"', false);
  1018. if (viVideoSource) viVideoSource = cleanMyContent(viVideoSource, false);
  1019. else viVideoSource = getMyContent (page.url, 'data-config-url="(.*?)"', false).replace(/&amp;/g, '&');
  1020.  
  1021. /* Get Videos Content */
  1022. var viVideosContent;
  1023. if (viVideoSource) {
  1024. viVideosContent = getMyContent(viVideoSource, '"progressive":\\[(.*?)\\]', false);
  1025. }
  1026.  
  1027. /* Get Videos */
  1028. if (viVideosContent) {
  1029. var viVideoFormats = {'1080p': 'Full High Definition MP4', '720p': 'High Definition MP4', '360p': 'Low Definition MP4', '270p': 'Very Low Definition MP4'};
  1030. var viVideoList = {};
  1031. var viVideoFound = false;
  1032. var viVideo, myVideoCode;
  1033. var viVideos = viVideosContent.split('},');
  1034. for (var i = 0; i < viVideos.length; i++) {
  1035. for (var viVideoCode in viVideoFormats) {
  1036. if (viVideos[i].indexOf('"quality":"' + viVideoCode + '"') != -1) {
  1037. viVideo = viVideos[i].match(/"url":"(.*?)"/);
  1038. viVideo = (viVideo) ? viVideo[1] : null;
  1039. if (viVideo) {
  1040. if (!viVideoFound) viVideoFound = true;
  1041. myVideoCode = viVideoFormats[viVideoCode];
  1042. viVideoList[myVideoCode] = viVideo;
  1043. }
  1044. }
  1045. }
  1046. }
  1047.  
  1048. if (viVideoFound) {
  1049. /* Create Saver */
  1050. var viDefaultVideo = 'Low Definition MP4';
  1051. saver = {'saverSocket': viPlayerWindow, 'videoList': viVideoList, 'videoSave': viDefaultVideo, 'saverWidth': viSaverWidth};
  1052. feature['container'] = false;
  1053. option['definitions'] = ['High Definition', 'Low Definition', 'Very Low Definition'];
  1054. option['containers'] = ['MP4'];
  1055. createMySaver ();
  1056. }
  1057. else {
  1058. saver = {'saverSocket': viPlayerWindow, 'saverWidth': viSaverWidth, 'warnMess': '!videos'};
  1059. createMySaver ();
  1060. }
  1061. }
  1062. else {
  1063. saver = {'saverSocket': viPlayerWindow, 'saverWidth': viSaverWidth, 'warnMess': '!content'};
  1064. createMySaver ();
  1065. }
  1066. }
  1067.  
  1068. }
  1069.  
  1070. // =====MetaCafe===== //
  1071.  
  1072. else if (page.url.indexOf('metacafe.com/watch') != -1) {
  1073.  
  1074. /* Get Player Window */
  1075. mcPlayerWindow = getMyElement ('', 'div', 'class', 'mc-video-player', 0, false);
  1076. if (!mcPlayerWindow) {
  1077. showMyMessage ('!player');
  1078. }
  1079. else {
  1080. /* Restyle Player Window */
  1081. styleMyElement (mcPlayerWindow, {margin: '0px 0px 10px 0px'});
  1082.  
  1083. /* Get Videos Content */
  1084. var mcVideosContent = getMyContent (page.url, 'flashvars\\s*=\\s*\\{(.*?)\\};', false);
  1085.  
  1086. /* Get Videos */
  1087. if (mcVideosContent) {
  1088. var mcVideoList = {};
  1089. var mcVideoFound = false;
  1090. var mcVideoFormats = {'video_alt_url2': 'High Definition MP4', 'video_alt_url': 'Low Definition MP4', 'video_url': 'Very Low Definition MP4'};
  1091. var mcVideoFormatz = {'video_alt_url2': '_720p', 'video_alt_url': '_360p', 'video_url': '_240p'};
  1092. var mcVideoHLS = mcVideosContent.match (/"src":"(.*?)"/);
  1093. mcVideoHLS = (mcVideoHLS) ? cleanMyContent(mcVideoHLS[1], false) : null;
  1094. if (mcVideoHLS) {
  1095. var mcVideoParser, mcVideoParse, myVideoCode, mcVideo;
  1096. for (var mcVideoCode in mcVideoFormats) {
  1097. mcVideoParser = '"' + mcVideoCode + '":"(.*?)"';
  1098. mcVideoParse = mcVideosContent.match (mcVideoParser);
  1099. mcVideo = (mcVideoParse) ? mcVideoParse[1] : null;
  1100. if (mcVideo) {
  1101. if (!mcVideoFound) mcVideoFound = true;
  1102. myVideoCode = mcVideoFormats[mcVideoCode];
  1103. mcVideoList[myVideoCode] = mcVideoHLS.replace('.m3u8', mcVideoFormatz[mcVideoCode] + '.m3u8');
  1104. }
  1105. }
  1106. }
  1107.  
  1108. if (mcVideoFound) {
  1109. /* Create Saver */
  1110. var mcDefaultVideo = 'Low Definition MP4';
  1111. saver = {'saverSocket': mcPlayerWindow, 'videoList': mcVideoList, 'videoSave': mcDefaultVideo, 'saverWidth': 640};
  1112. feature['container'] = false;
  1113. option['definitions'] = ['High Definition', 'Low Definition', 'Very Low Definition'];
  1114. option['containers'] = ['MP4'];
  1115. createMySaver ();
  1116. }
  1117. else {
  1118. saver = {'saverSocket': mcPlayerWindow, 'saverWidth': 640, 'warnMess': '!videos'};
  1119. createMySaver ();
  1120. }
  1121. }
  1122. else {
  1123. saver = {'saverSocket': mcPlayerWindow, 'saverWidth': 640};
  1124. var ytVideoId = page.url.match (/\/yt-(.*?)\//);
  1125. if (ytVideoId && ytVideoId[1]) {
  1126. var ytVideoLink = 'http://youtube.com/watch?v=' + ytVideoId[1];
  1127. saver['warnMess'] = 'embed';
  1128. saver['warnContent'] = ytVideoLink;
  1129. }
  1130. else saver['warnMess'] = '!videos';
  1131. createMySaver ();
  1132. }
  1133. }
  1134.  
  1135. }
  1136.  
  1137. // =====Break===== //
  1138.  
  1139. else if (page.url.indexOf('break.com/video') != -1 || page.url.indexOf('break.com/movies') != -1) {
  1140.  
  1141. /* Get Player Window */
  1142. var brPlayerWindow = getMyElement ('', 'div', 'id', 'video-player', -1, false);
  1143. if (!brPlayerWindow) {
  1144. showMyMessage ('!player');
  1145. }
  1146. else {
  1147. /* Saver Width */
  1148. var brWindowWidth = page.win.innerWidth || page.doc.documentElement.clientWidth;
  1149. var brSaverWidth;
  1150. if (page.url.indexOf('break.com/movies') != -1) {
  1151. if (brWindowWidth >= 1400) brSaverWidth = 1152;
  1152. else brSaverWidth = 912;
  1153. }
  1154. else {
  1155. if (brWindowWidth >= 1400) brSaverWidth = 832;
  1156. else brSaverWidth = 592;
  1157. }
  1158.  
  1159. /* Get Video ID */
  1160. var brVideoID = page.url.match(/-(\d+)($|\?)/);
  1161. brVideoID = (brVideoID) ? brVideoID[1] : null;
  1162.  
  1163. /* Get Videos Content */
  1164. var brSource = page.win.location.protocol + '//' + page.win.location.hostname + '/embed/' + brVideoID;
  1165. var brVideosContent = getMyContent (brSource, 'TEXT', false);
  1166.  
  1167. /* Get Videos */
  1168. if (brVideosContent) {
  1169. var brVideoList = {};
  1170. var brVideoFormats = {};
  1171. var brVideoFound = false;
  1172. 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'};
  1173. var brVideoPath, brVideoToken, brVideoThumb, brVideo, myVideoCode;
  1174. brVideoPath = brVideosContent.match (/"videoUri":\s"(.*?)496_kbps/);
  1175. brVideoPath = (brVideoPath) ? brVideoPath[1] : null;
  1176. brVideoToken = brVideosContent.match (/"AuthToken":\s"(.*?)"/);
  1177. brVideoToken = (brVideoToken) ? brVideoToken[1] : null;
  1178. if (brVideoPath && brVideoToken) {
  1179. for (var brVideoCode in brVideoFormats) {
  1180. if (brVideosContent.match(brVideoPath + brVideoCode)) {
  1181. if (!brVideoFound) brVideoFound = true;
  1182. myVideoCode = brVideoFormats[brVideoCode];
  1183. brVideo = brVideoPath + brVideoCode + '?' + brVideoToken;
  1184. brVideoList[myVideoCode] = brVideo;
  1185. }
  1186. }
  1187. }
  1188.  
  1189. if (brVideoFound) {
  1190. /* Create Saver */
  1191. var brDefaultVideo = 'Low Definition MP4';
  1192. saver = {'saverSocket': brPlayerWindow, 'videoList': brVideoList, 'videoSave': brDefaultVideo, 'saverWidth': brSaverWidth};
  1193. option['definitions'] = ['Very Low Definition', 'Low Definition', 'Standard Definition', 'High Definition', 'Full High Definition'];
  1194. option['containers'] = ['MP4', 'FLV', 'Any'];
  1195. createMySaver ();
  1196. }
  1197. else {
  1198. saver = {'saverSocket': brPlayerWindow, 'saverWidth': brSaverWidth};
  1199. var ytVideoId = brVideosContent.match (/"youtubeId":\s"(.*?)"/);
  1200. if (ytVideoId && ytVideoId[1]) {
  1201. var ytVideoLink = 'http://youtube.com/watch?v=' + ytVideoId[1];
  1202. saver['warnMess'] = 'embed';
  1203. saver['warnContent'] = ytVideoLink;
  1204. }
  1205. else saver['warnMess'] = '!videos';
  1206. createMySaver ();
  1207. }
  1208. }
  1209. else {
  1210. saver = {'saverSocket': brPlayerWindow, 'saverWidth': brSaverWidth, 'warnMess': '!content'};
  1211. createMySaver ();
  1212. }
  1213. }
  1214.  
  1215. }
  1216.  
  1217. // =====FunnyOrDie===== //
  1218.  
  1219. else if (page.url.indexOf('funnyordie.com/videos') != -1) {
  1220.  
  1221. /* Get Player Window */
  1222. var fodPlayerWindow = getMyElement ('', 'div', 'class', 'video-content', 0, false);
  1223. if (!fodPlayerWindow) {
  1224. showMyMessage ('!player');
  1225. }
  1226. else {
  1227. /* My Saver Socket */
  1228. var fodSaverSocket = createMyElement ('div', '', '', '', '');
  1229. styleMyElement (fodSaverSocket, {width: '100%', height: '24px', textAlign: 'center', padding: '0px 100px 0px 100px', backgroundColor: '#F4F4F4'});
  1230. appendMyElement (fodPlayerWindow, fodSaverSocket);
  1231.  
  1232. /* Get Videos Content */
  1233. var fodVideosContent = getMyContent (page.url, '<video([\\s\\S]*?)video>', false);
  1234.  
  1235. /* Get Videos */
  1236. if (fodVideosContent) {
  1237. 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'};
  1238. var fodVideoList = {};
  1239. var fodVideoFound = false;
  1240. var fodVideoPath, fodVideoCodes, fodVideo, myVideoCode;
  1241. fodVideoPath = fodVideosContent.match(/src="(.*?)v\d+.*?\.mp4"/);
  1242. fodVideoPath = (fodVideoPath) ? fodVideoPath[1] : null;
  1243. fodVideoCodes = fodVideosContent.match (/v([^\/]*?)\/master/);
  1244. fodVideoCodes = (fodVideoCodes) ? fodVideoCodes[1] : '';
  1245. if (fodVideoPath) {
  1246. if (fodVideoCodes) {
  1247. for (var fodVideoCode in fodVideoFormats) {
  1248. if (fodVideoCodes.indexOf(fodVideoCode.replace(/v/, '').replace(/\..*/, '')) != -1) {
  1249. if (!fodVideoFound) fodVideoFound = true;
  1250. fodVideo = fodVideoPath + fodVideoCode;
  1251. myVideoCode = fodVideoFormats[fodVideoCode];
  1252. fodVideoList[myVideoCode] = fodVideo;
  1253. }
  1254. }
  1255. }
  1256. else {
  1257. for (var fodVideoCode in fodVideoFormats) {
  1258. fodVideo = fodVideoPath + fodVideoCode;
  1259. if (fodVideosContent.match(fodVideo)) {
  1260. if (!fodVideoFound) fodVideoFound = true;
  1261. myVideoCode = fodVideoFormats[fodVideoCode];
  1262. fodVideoList[myVideoCode] = fodVideo;
  1263. }
  1264. }
  1265. }
  1266. }
  1267.  
  1268. if (fodVideoFound) {
  1269. /* Create Saver */
  1270. fodDefaultVideo = 'Low Definition MP4';
  1271. saver = {'saverSocket': fodSaverSocket, 'videoList': fodVideoList, 'videoSave': fodDefaultVideo, 'saverWidth': 570};
  1272. feature['container'] = false;
  1273. option['definitions'] = ['High Definition', 'Standard Definition', 'Low Definition', 'Very Low Definition'];
  1274. option['containers'] = ['MP4'];
  1275. createMySaver ();
  1276. }
  1277. else {
  1278. saver = {'saverSocket': fodPlayerWindow, 'saverWidth': 570, 'warnMess': '!videos'};
  1279. createMySaver ();
  1280. }
  1281. }
  1282. else {
  1283. saver = {'saverSocket': fodPlayerWindow, 'saverWidth': 570, 'warnMess': '!content'};
  1284. createMySaver ();
  1285. }
  1286. }
  1287.  
  1288. }
  1289.  
  1290. // =====Veoh===== //
  1291.  
  1292. else if (page.url.indexOf('veoh.com/watch') != -1) {
  1293.  
  1294. /* Get Video Availability */
  1295. if (getMyElement ('', 'div', 'class', 'veoh-video-player-error', 0, false)) return;
  1296.  
  1297. /* Get Player Window */
  1298. var vePlayerWindow = getMyElement ('', 'div', 'id', 'videoPlayerContainer', -1, false);
  1299. if (!vePlayerWindow) {
  1300. showMyMessage ('!player');
  1301. }
  1302. else {
  1303. /* Get Videos Content */
  1304. var veVideosContent = getMyContent (page.url, '__watch.videoDetailsJSON = \'\\{(.*?)\\}', false);
  1305. veVideosContent = cleanMyContent (veVideosContent, true);
  1306.  
  1307. /* Restyle Player Window */
  1308. styleMyElement (vePlayerWindow, {margin: '0px 0px 20px 0px'});
  1309.  
  1310. /* Get Videos */
  1311. if (veVideosContent) {
  1312. var veVideoFormats = {'fullPreviewHashLowPath': 'Very Low Definition MP4', 'fullPreviewHashHighPath': 'Low Definition MP4'};
  1313. var veVideoList = {};
  1314. var veVideoFound = false;
  1315. var veVideoParser, veVideoParse, veVideo, myVideoCode;
  1316. for (var veVideoCode in veVideoFormats) {
  1317. veVideoParser = veVideoCode + '":"(.*?)"';
  1318. veVideoParse = veVideosContent.match (veVideoParser);
  1319. veVideo = (veVideoParse) ? veVideoParse[1] : null;
  1320. if (veVideo) {
  1321. if (!veVideoFound) veVideoFound = true;
  1322. myVideoCode = veVideoFormats[veVideoCode];
  1323. veVideoList[myVideoCode] = veVideo;
  1324. }
  1325. }
  1326.  
  1327. if (veVideoFound) {
  1328. /* Create Saver */
  1329. var veDefaultVideo = 'Low Definition MP4';
  1330. saver = {'saverSocket': vePlayerWindow, 'videoList': veVideoList, 'videoSave': veDefaultVideo, 'saverWidth': 640};
  1331. feature['container'] = false;
  1332. feature['fullsize'] = false;
  1333. option['definition'] = 'LD';
  1334. option['definitions'] = ['Low Definition', 'Very Low Definition'];
  1335. option['containers'] = ['MP4'];
  1336. createMySaver ();
  1337. }
  1338. else {
  1339. saver = {'saverSocket': vePlayerWindow, 'saverWidth': 640};
  1340. var veVideoSource = getMyContent(page.url, '"videoContentSource":"(.*?)"', false);
  1341. if (veVideoSource == 'YouTube') var ytVideoId = getMyContent(page.url, '"videoId":"yapi-(.*?)"', false);
  1342. if (ytVideoId) {
  1343. var ytVideoLink = 'http://youtube.com/watch?v=' + ytVideoId;
  1344. saver['warnMess'] = 'embed';
  1345. saver['warnContent'] = ytVideoLink;
  1346. styleMyElement(vePlayerWindow, {margin: '0px 0px 20px 0px'});
  1347. }
  1348. else saver['warnMess'] = '!videos';
  1349. createMySaver ();
  1350. }
  1351. }
  1352. else {
  1353. saver = {'saverSocket': vePlayerWindow, 'saverWidth': 640, 'warnMess': '!content'};
  1354. createMySaver ();
  1355. }
  1356. }
  1357.  
  1358. }
  1359.  
  1360. // =====Viki===== //
  1361.  
  1362. else if (page.url.indexOf('viki.com/videos') != -1) {
  1363.  
  1364. /* Get Player Window */
  1365. var vkSaverWindow = getMyElement ('', 'div', 'class', 'card-content', 0, false);
  1366. if (!vkSaverWindow) {
  1367. showMyMessage ('!player');
  1368. }
  1369. else {
  1370. /* Get Video ID */
  1371. var vkVideoID = page.url.match(/videos\/(.*?)v/);
  1372. vkVideoID = (vkVideoID) ? vkVideoID[1] : null;
  1373.  
  1374. /* Get Videos Content */
  1375. var vkVideosContent;
  1376. if (vkVideoID) vkVideosContent = getMyContent (page.win.location.protocol + '//' + page.win.location.host + '/player5_fragment/' + vkVideoID + 'v.json', 'TEXT', false);
  1377.  
  1378. /* Saver Width*/
  1379. var vkSaverWith = parseInt(vkSaverWindow.clientWidth) - 20;
  1380.  
  1381. /* Get Videos */
  1382. if (vkVideosContent) {
  1383. var vkVideoList = {};
  1384. var vkVideo = vkVideosContent.match(/"video_url":"(.*?)"/);
  1385. vkVideo = (vkVideo) ? vkVideo[1] : null;
  1386.  
  1387. /* Create Saver */
  1388. if (vkVideo) {
  1389. var vkDefaultVideo = 'Low Definition MP4';
  1390. vkVideoList[vkDefaultVideo] = vkVideo
  1391. saver = {'saverSocket': vkSaverWindow, 'videoList': vkVideoList, 'videoSave': vkDefaultVideo, 'saverWidth': vkSaverWith};
  1392. feature['definition'] = false;
  1393. feature['container'] = false;
  1394. option['definition'] = 'LD';
  1395. option['definitions'] = ['Low Definition'];
  1396. option['containers'] = ['MP4'];
  1397. createMySaver ();
  1398. }
  1399. else {
  1400. saver = {'saverSocket': vkPlayerWindow, 'saverWidth': vkSaverWith, 'warnMess': '!videos'};
  1401. createMySaver ();
  1402. }
  1403. }
  1404. else {
  1405. saver = {'saverSocket': vkPlayerWindow, 'saverWidth': vkSaverWith, 'warnMess': '!content'};
  1406. createMySaver ();
  1407. }
  1408. }
  1409.  
  1410. }
  1411.  
  1412. // =====IMDB===== //
  1413.  
  1414. else if (page.url.indexOf('imdb.com') != -1) {
  1415.  
  1416. /* Redirect To Video Page */
  1417. if (page.url.indexOf('imdb.com/video/') == -1) {
  1418. page.doc.addEventListener('click', function(e) {
  1419. var p = e.target.parentNode;
  1420. while (p) {
  1421. if (p.tagName === 'A' && p.href.indexOf('/video/imdb') != -1) {
  1422. page.win.location.href = p.href.replace(/imdb\/inline.*/, '');
  1423. }
  1424. p = p.parentNode;
  1425. }
  1426. }, false);
  1427. return;
  1428. }
  1429.  
  1430. /* Get Player Window */
  1431. var imdbPlayerWindow = getMyElement ('', 'div', 'id', 'player-article', -1, false);
  1432. if (!imdbPlayerWindow) {
  1433. showMyMessage ('!player');
  1434. }
  1435. else {
  1436. /* Get Videos Content */
  1437. var imdbVideoList = {};
  1438. var imdbVideoFormats = {'1': 'Low Definition MP4', '2': 'Standard Definition MP4', '3': 'High Definition MP4'};
  1439. var imdbDefaultVideo, imdbURL, imdbVideo, myVideoCode;
  1440. var imdbVideoFound = false;
  1441. var imdbVideoRTMP = false;
  1442. var imdbPageURL = page.url.replace(/\?.*$/, '').replace(/\/$/, '');
  1443. for (var imdbVideoCode in imdbVideoFormats) {
  1444. imdbURL = imdbPageURL + '/player?uff=' + imdbVideoCode;
  1445. imdbVideo = getMyContent (imdbURL, 'so.addVariable\\("file",\\s+"(.*?)"\\);', true);
  1446. if (imdbVideo) {
  1447. if (imdbVideo.indexOf('rtmp') != -1) {
  1448. if (!imdbVideoRTMP) imdbVideoRTMP = true;
  1449. }
  1450. else {
  1451. if (!imdbVideoFound) imdbVideoFound = true;
  1452. myVideoCode = imdbVideoFormats[imdbVideoCode];
  1453. imdbVideoList[myVideoCode] = imdbVideo;
  1454. if (!imdbDefaultVideo) imdbDefaultVideo = myVideoCode;
  1455. }
  1456. }
  1457. }
  1458.  
  1459. if (imdbVideoFound) {
  1460. /* Create Saver */
  1461. saver = {'saverSocket': imdbPlayerWindow, 'videoList': imdbVideoList, 'videoSave': imdbDefaultVideo, 'saverWidth': 1010};
  1462. feature['container'] = false;
  1463. option['definitions'] = ['High Definition', 'Standard Definition', 'Low Definition'];
  1464. option['containers'] = ['MP4'];
  1465. createMySaver ();
  1466. }
  1467. else {
  1468. if (imdbVideoRTMP) {
  1469. saver = {'saverSocket': imdbPlayerWindow, 'saverWidth': 1010, 'warnMess': '!support'};
  1470. createMySaver ();
  1471. }
  1472. else {
  1473. saver = {'saverSocket': imdbPlayerWindow, 'saverWidth': 1010, 'warnMess': '!videos'};
  1474. createMySaver ();
  1475. }
  1476. }
  1477. }
  1478.  
  1479. }
  1480.  
  1481. // =====Facebook===== //
  1482.  
  1483. else if (page.url.match('facebook.com/(video.php|.*/videos/)')) {
  1484.  
  1485. /* Get Player Window */
  1486. var fbPlayerWindow = getMyElement ('', 'div', 'class', 'stageButtons', 0, false);
  1487. if (!fbPlayerWindow) {
  1488. showMyMessage ('!player');
  1489. }
  1490. else {
  1491. /* Get Videos Content */
  1492. var fbVideosContent = getMyContent(page.url, '"params","(.*?)"', false);
  1493. var fbPattern = /\\u([\d\w]{4})/gi;
  1494. fbVideosContent = fbVideosContent.replace(fbPattern, function (match, group) {
  1495. return String.fromCharCode(parseInt(group, 16));
  1496. });
  1497. fbVideosContent = unescape(fbVideosContent);
  1498.  
  1499. /* Get Videos */
  1500. if (fbVideosContent) {
  1501. var fbVideoList = {};
  1502. var fbVideoFormats = {'sd_src': 'Low Definition MP4', 'hd_src': 'High Definition MP4'};
  1503. var fbVideoFound = false;
  1504. var fbVideoPattern, fbVideo, myVideoCode, fbVideoThumb, fbDefaultVideo;
  1505. for (var fbVideoCode in fbVideoFormats) {
  1506. fbVideoPattern = '"' + fbVideoCode + '":"(.*?)"';
  1507. fbVideo = fbVideosContent.match(fbVideoPattern);
  1508. fbVideo = (fbVideo) ? fbVideo[1] : null;
  1509. if (fbVideo) {
  1510. fbVideo = cleanMyContent(fbVideo, false);
  1511. if (!fbVideoFound) fbVideoFound = true;
  1512. myVideoCode = fbVideoFormats[fbVideoCode];
  1513. if (fbVideo.indexOf('.flv') != -1) myVideoCode = myVideoCode.replace('MP4', 'FLV');
  1514. fbVideoList[myVideoCode] = fbVideo;
  1515. if (!fbDefaultVideo) fbDefaultVideo = myVideoCode;
  1516. }
  1517. }
  1518.  
  1519. if (fbVideoFound) {
  1520. /* Create Saver */
  1521. saver = {'saverSocket': fbPlayerWindow, 'videoList': fbVideoList, 'videoSave': fbDefaultVideo, 'saverWidth': 760};
  1522. option['definitions'] = ['High Definition', 'Low Definition'];
  1523. option['containers'] = ['MP4', 'FLV', 'Any'];
  1524. createMySaver ();
  1525. }
  1526. else {
  1527. saver = {'saverSocket': fbPlayerWindow, 'saverWidth': 760, 'warnMess': '!videos'};
  1528. createMySaver ();
  1529. }
  1530. }
  1531. else {
  1532. saver = {'saverSocket': fbPlayerWindow, 'saverWidth': 760, 'warnMess': '!content'};
  1533. createMySaver ();
  1534. }
  1535. }
  1536.  
  1537. }
  1538.  
  1539. })();