ViewTube_GM

Watch videos from video sharing websites without Flash Player.

当前为 2016-02-29 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name ViewTube_GM
  3. // @version 2016.02.28
  4. // @description Watch videos from video sharing websites without Flash Player.
  5. // @author trupf
  6. // @namespace https://userscripts.org/users/trupf
  7. // @icon http://s3.amazonaws.com/uso_ss/icon/87011/large.png
  8. // @_require https://raw.github.com/Dash-Industry-Forum/dash.js/v1.1.2/dash.all.js
  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://gaming.youtube.com*
  14. // @include https://gaming.youtube.com*
  15. // @include http://dailymotion.com*
  16. // @include http://www.dailymotion.com*
  17. // @include https://dailymotion.com*
  18. // @include https://www.dailymotion.com*
  19. // @include http://vimeo.com*
  20. // @include http://www.vimeo.com*
  21. // @include https://vimeo.com*
  22. // @include https://www.vimeo.com*
  23. // @include http://metacafe.com*
  24. // @include http://www.metacafe.com*
  25. // @include https://metacafe.com*
  26. // @include https://www.metacafe.com*
  27. // @include http://break.com*
  28. // @include http://www.break.com*
  29. // @include https://break.com*
  30. // @include https://www.break.com*
  31. // @include http://funnyordie.com*
  32. // @include http://www.funnyordie.com*
  33. // @include https://funnyordie.com*
  34. // @include https://www.funnyordie.com*
  35. // @include http://videojug.com*
  36. // @include http://www.videojug.com*
  37. // @include https://videojug.com*
  38. // @include https://www.videojug.com*
  39. // @include http://blip.tv*
  40. // @include http://www.blip.tv*
  41. // @include https://blip.tv*
  42. // @include https://www.blip.tv*
  43. // @include http://veoh.com*
  44. // @include http://www.veoh.com*
  45. // @include https://veoh.com*
  46. // @include https://www.veoh.com*
  47. // @include http://www.imdb.org/*
  48. // @include http://www.imdb.com/video*
  49. // @include https://www.imdb.com/video*
  50. // @include http://crackle.com*
  51. // @include http://www.crackle.com*
  52. // @include https://crackle.com*
  53. // @include https://www.crackle.com*
  54. // @include http://viki.com*
  55. // @include http://www.viki.com*
  56. // @include https://viki.com*
  57. // @include https://www.viki.com*
  58. // @include http://vevo.com*
  59. // @include http://www.vevo.com*
  60. // @include https://vevo.com*
  61. // @include https://www.vevo.com*
  62. // @include http://facebook.com*
  63. // @include http://www.facebook.com*
  64. // @include https://facebook.com*
  65. // @include https://www.facebook.com*
  66. // @include https://screen.yahoo.com*
  67. // @license GPLv3
  68. // @grant GM_xmlhttpRequest
  69. // @grant GM_setValue
  70. // @grant GM_getValue
  71. // @grant GM_log
  72. // @grant unsafeWindow
  73. // @run-at document-end
  74.  
  75. // ==/UserScript==
  76.  
  77.  
  78. /*
  79. Copyright (C) 2010 - 2014 Tobias Rupf
  80.  
  81. This program is free software: you can redistribute it and/or modify
  82. it under the terms of the GNU General Public License as published by
  83. the Free Software Foundation, either version 3 of the License, or
  84. (at your option) any later version.
  85.  
  86. This program is distributed in the hope that it will be useful,
  87. but WITHOUT ANY WARRANTY; without even the implied warranty of
  88. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  89. GNU General Public License for more details.
  90.  
  91. You should have received a copy of the GNU General Public License
  92. along with this program. If not, see <http://www.gnu.org/licenses/>.
  93. This Program is mainly based on the work of Sebastian Luncan
  94. (Website: http://isebaro.com/viewtube)
  95. Youtube Signature decryption and mutation observers by Gantt.
  96. (see http://userscripts.org/scripts/show/25105)
  97. */
  98.  
  99. (function() {
  100. // ==========Variables========== //
  101.  
  102. // Userscript
  103. var userscript = 'ViewTube_GM';
  104.  
  105. // Page
  106. var page = {win: window, doc: document, body: document.body, url: window.location.href};
  107. var videoDiv,videoLink;
  108. var dashplayer;
  109.  
  110. // Player
  111. //var player = {};
  112. var myPlayerWindow, HeadWindow, OrgHeadWindowIndex, OrgPlayerIndex;
  113. var feature = {'autoplay': true, 'definition': true, 'container': true, 'dash': false, 'direct': false, 'widesize': true, 'fullsize': true};
  114. var plugins = ['HTML5'];
  115. if ((navigator.appVersion.indexOf('Chrome/') == -1) || (parseInt(navigator.appVersion.substr(navigator.appVersion.indexOf('Chrome/')+7,2)) < 35)
  116. || ((navigator.platform.indexOf('Win') != -1) && (parseInt(navigator.appVersion.substr(navigator.appVersion.indexOf('Chrome/')+7,2)) < 45))) {
  117. plugins = ['Auto'].concat(plugins);
  118. plugins = plugins.concat(['MPEG', 'MP4', 'FLV', 'VLC']);
  119. if (navigator.platform.indexOf('Win') != -1) plugins = plugins.concat(['WMP', 'WMP2', 'QT']);
  120. else if (navigator.platform.indexOf('Mac') != -1) plugins = plugins.concat(['QT']);
  121. else plugins = plugins.concat(['Totem', 'Xine']);
  122. }
  123. var option = {'plugin': plugins[0], 'autoplay': false, 'autoget': false, 'definition': 'HD', 'container': 'MP4', 'widesize': false, 'fullsize': false};
  124. var mimetypes = {
  125. 'MPEG': 'video/mpeg',
  126. 'MP4': 'video/mp4',
  127. 'WebM': 'video/webm',
  128. 'FLV': 'video/x-flv',
  129. 'MOV': 'video/quicktime',
  130. 'M4V': 'video/x-m4v',
  131. 'AVI': 'video/x-msvideo',
  132. '3GP': 'video/3gpp',
  133. 'WMP': 'application/x-ms-wmp',
  134. 'WMP2': 'application/x-mplayer2',
  135. 'QT': 'video/quicktime',
  136. 'VLC': 'application/x-vlc-plugin',
  137. 'Totem': 'application/x-totem-plugin',
  138. 'Xine': 'application/x-xine-plugin'
  139. };
  140.  
  141. // Links
  142. var website = 'https://greasyfork.org/de/scripts/1203-viewtube-gm';
  143. var contact = 'https://greasyfork.org/de/scripts/1203-viewtube-gm/feedback';
  144.  
  145. // ==========Fixes========== //
  146.  
  147. // Don't run on frames or iframes
  148. //if ((page.url.indexOf('imdb.com/') == -1) && (window.top != window.self)) return;
  149.  
  150. // ==========Functions========== //
  151.  
  152. function createVideoElement (type, content, player) {
  153. function createPlayerElement (type, content, player) {
  154. player['contentVideo'] = createMyElement (type, content,'','','',player);
  155. player['contentVideo'].width = player['contentWidth'];
  156. player['contentVideo'].height = player['contentHeight'];
  157. styleMyElement (player['contentVideo'], {position: 'relative', width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px'});
  158. modifyMyElement (player['playerContent'], 'div', '', true);
  159. appendMyElement (player['playerContent'], player['contentVideo']);
  160. if (type == 'video' && content == 'DASH') {
  161. }
  162. }
  163. setTimeout(function() { createPlayerElement(type, content, player); }, 0);
  164. }
  165.  
  166. function createMyElement (type, content, event, action, target, player) {
  167. var obj = page.doc.createElement(type);
  168. if (content) {
  169. if (type == 'div') obj.innerHTML = content;
  170. else if (type == 'img') obj.src = content;
  171. else if (type == 'option') {
  172. obj.value = content;
  173. obj.innerHTML = content;
  174. }
  175. else if (type == 'video') {
  176. obj.controls = 'controls';
  177. obj.autoplay = 'autoplay';
  178. obj.volume = 0.5;
  179. obj.innerHTML = '<br><br>The video should be loading. If it doesn\'t load, make sure your browser supports HTML5\'s Video and this video codec. If you think it\'s a script issue, please report it <a href="' + contact + '" style="color:#00892C">here</a>.';
  180. if (content != 'DASH') obj.src = content;
  181. }
  182. else if (type == 'object') {
  183. obj.data = content;
  184. obj.id = 'videoplayer';
  185. obj.innerHTML = '<br><br>The video should be loading. If it doesn\'t load, make sure a video plugin is installed. If you think it\'s a script issue, please report it <a href="' + contact + '" style="color:#00892C">here</a>.<param name="scale" value="aspect"><param name="stretchtofit" value="true"><param name="autostart" value="true"><param name="autoplay" value="true">';
  186. }
  187. else if (type == 'embed') {
  188. if (option['plugin'] == 'VLC') obj.setAttribute('target', content);
  189. else obj.src = content;
  190. obj.id = 'videoplayer';
  191. obj.innerHTML = '<br><br>The video should be loading. If it doesn\'t load, make sure a video plugin is installed. If you think it\'s a script issue, please report it <a href="' + contact + '" style="color:#00892C">here</a>.<param name="scale" value="aspect"><param name="stretchtofit" value="true"><param name="autostart" value="true"><param name="autoplay" value="true">';
  192. }
  193. }
  194. if (type == 'video' || type == 'object' || type == 'embed') {
  195. if (option['plugin'] == 'Auto' || option['plugin'] == 'Alt' || option['plugin'] == 'HTML5') {
  196. if (content == 'DASH') obj.type = 'application/dash+xml';
  197. else obj.type = mimetypes[player['videoPlay'].replace(/.*\s/, '')];
  198. }
  199. else {
  200. obj.type = mimetypes[option['plugin']];
  201. }
  202. obj.id = 'vtVideo';
  203. }
  204. if (event == 'change') {
  205. if (target == 'video') {
  206. obj.addEventListener ('change', function (e) {
  207. if (e.target) player['videoPlay'] = e.target.value;
  208. else if (e.srcElement) player['videoPlay'] = e.srcElement.value;
  209. if (player['isGetting']) {
  210. modifyMyElement (player['buttonGet'] , 'div', 'Get', false);
  211. player['isGetting'] = false;
  212. }
  213. if (player['isPlaying']) playMyVideo(player, option['autoplay']);
  214. }.bind(player), false);
  215. }
  216. else if (target == 'plugin') {
  217. obj.addEventListener ('change', function (e) {
  218. if (e.target) option['plugin'] = e.target.value;
  219. else if (e.srcElement) option['plugin'] = e.srcElement.value;
  220. setMyOptions ('viewtube_plugin', option['plugin']);
  221. if (player['isPlaying']) playMyVideo(player, true);
  222. }.bind(player), false);
  223. }
  224. }
  225. else if (event == 'click') {
  226. obj.addEventListener ('click', function () {
  227. if (action == 'close') {
  228. removeMyElement(page.body, target);
  229. }
  230. else if (action == 'logo') {
  231. page.win.location.href = website;
  232. }
  233. else if (action == 'play') {
  234. playMyVideo(player, !player['isPlaying']);
  235. }
  236. else if (action == 'get') {
  237. getMyVideo(player);
  238. }
  239. else if (action == 'autoplay') {
  240. option['autoplay'] = (option['autoplay']) ? false : true;
  241. if (option['autoplay']) {
  242. // styleMyElement (player['buttonPlay'], {display: 'none'});
  243. styleMyElement (player['buttonAutoplay'], {color: '#008080', textShadow: '0px 1px 1px #CCCCCC'});
  244. if (!player['isPlaying']) playMyVideo(player, true);
  245. }
  246. else {
  247. // styleMyElement (player['buttonPlay'], {display: 'inline'});
  248. styleMyElement (player['buttonAutoplay'], {color: '#CCCCCC', textShadow: '0px 0px 0px'});
  249. playMyVideo(player, false);
  250. }
  251. setMyOptions ('viewtube_autoplay', option['autoplay']);
  252. }
  253. else if (action == 'definition') {
  254. for (var itemDef = 0; itemDef < option['definitions'].length; itemDef++) {
  255. if (option['definitions'][itemDef].match(/[A-Z]/g).join('') == option['definition']) {
  256. var nextDef = (itemDef + 1 < option['definitions'].length) ? itemDef + 1 : 0;
  257. option['definition'] = option['definitions'][nextDef].match(/[A-Z]/g).join('');
  258. break;
  259. }
  260. }
  261. modifyMyElement (player['buttonDefinition'], 'div', option['definition'], false);
  262. setMyOptions ('viewtube_definition', option['definition']);
  263. if (player['isGetting']) {
  264. modifyMyElement (player['buttonGet'] , 'div', 'Get', false);
  265. player['isGetting'] = false;
  266. }
  267. selectMyVideo (player);
  268. if (player['isPlaying']) playMyVideo(player, true);
  269. }
  270. else if (action == 'container') {
  271. for (var itemCont = 0; itemCont < option['containers'].length; itemCont++) {
  272. if (option['containers'][itemCont] == option['container']) {
  273. var nextCont = (itemCont + 1 < option['containers'].length) ? itemCont + 1 : 0;
  274. option['container'] = option['containers'][nextCont];
  275. break;
  276. }
  277. }
  278. modifyMyElement (player['buttonContainer'], 'div', option['container'], false);
  279. setMyOptions ('viewtube_container', option['container']);
  280. if (player['isGetting']) {
  281. modifyMyElement (player['buttonGet'] , 'div', 'Get', false);
  282. player['isGetting'] = false;
  283. }
  284. selectMyVideo (player);
  285. if (player['isPlaying']) playMyVideo(player, true);
  286. }
  287. else if (action == 'widesize') {
  288. option['widesize'] = (option['widesize']) ? false : true;
  289. setMyOptions ('viewtube_widesize', option['widesize']);
  290. resizeMyPlayer(player, 'widesize');
  291. }
  292. else if (action == 'fullsize') {
  293. option['fullsize'] = (option['fullsize']) ? false : true;
  294. resizeMyPlayer(player, 'fullsize');
  295. }
  296. }.bind(player), false);
  297. }
  298. return obj;
  299. }
  300.  
  301. function getMyElement (obj, type, from, value, child, content) {
  302. var getObj, chObj, coObj;
  303. var pObj = (!obj) ? page.doc : obj;
  304. if (type == 'body') getObj = pObj.body;
  305. else {
  306. if (from == 'id') getObj = pObj.getElementById(value);
  307. else if (from == 'class') getObj = pObj.getElementsByClassName(value);
  308. else if (from == 'tag') getObj = pObj.getElementsByTagName(type);
  309. else if (from == 'ns') getObj = pObj.getElementsByTagNameNS(value, type);
  310. }
  311. chObj = (child >= 0) ? getObj[child] : getObj;
  312. if (content && chObj) {
  313. if (type == 'html' || type == 'body' || type == 'div' || type == 'option') coObj = chObj.innerHTML;
  314. else if (type == 'object') coObj = chObj.data;
  315. else if (type == 'img' || type == 'video' || type == 'embed') coObj = chObj.src;
  316. else coObj = chObj.textContent;
  317. return coObj;
  318. }
  319. else {
  320. return chObj;
  321. }
  322. }
  323.  
  324. function modifyMyElement (obj, type, content, clear, hide) {
  325. if (content) {
  326. if (type == 'div') obj.innerHTML = content;
  327. else if (type == 'option') {
  328. obj.value = content;
  329. obj.innerHTML = content;
  330. }
  331. else if (type == 'object') obj.data = content;
  332. else if (type == 'img' || type == 'video' || type == 'embed') obj.src = content;
  333. }
  334. if (clear) {
  335. if (obj.hasChildNodes()) {
  336. while (obj.childNodes.length >= 1) {
  337. obj.removeChild(obj.firstChild);
  338. }
  339. }
  340. }
  341. if (hide) {
  342. for(var i = 0; i < obj.children.length; i++) {
  343. styleMyElement(obj.children[i], {display: 'none'});
  344. }
  345. }
  346. }
  347.  
  348. function cleanMyElement (element, hide) {
  349. var elEmbed, elVideo;
  350. if (hide) styleMyElement (element, {display: 'none'});
  351. elEmbed = getMyElement (element, 'embed', 'tag', '', 0, false) || getMyElement (element, 'object', 'tag', '', 0, false);
  352. if (elEmbed && elEmbed.parentNode) {
  353. removeMyElement (elEmbed.parentNode, elEmbed);
  354. if (!hide) return;
  355. }
  356. elVideo = getMyElement (element, 'video', 'tag', '', 0, false);
  357. if (elVideo && elVideo.src && elVideo.currentSrc) {
  358. modifyMyElement (elVideo, 'video', 'none', true);
  359. if (!hide && elVideo.parentNode) removeMyElement (elVideo.parentNode, elVideo);
  360. if (elVideo.parentNode) try {elVideo.pause()} catch(e) {};
  361. }
  362. var elWait = 50;
  363. var elRemove = page.win.setInterval (function () {
  364. if (!elVideo) {
  365. elVideo = getMyElement (element, 'video', 'tag', '', 0, false);
  366. if (!elVideo) {
  367. elEmbed = getMyElement (element, 'embed', 'tag', '', 0, false) || getMyElement (element, 'object', 'tag', '', 0, false);
  368. if (elEmbed && elEmbed.id != 'vtVideo' && elEmbed.parentNode) {
  369. removeMyElement (elEmbed.parentNode, elEmbed);
  370. page.win.clearInterval (elRemove);
  371. }
  372. }
  373. }
  374. if (elVideo && elVideo.id != 'vtVideo' && elVideo.currentSrc && elVideo.currentSrc.indexOf('none') == -1) {
  375. modifyMyElement (elVideo, 'video', 'none', true);
  376. if (elVideo.parentNode) try {elVideo.pause()} catch(e) {};
  377. if (!hide && elVideo.parentNode) removeMyElement (elVideo.parentNode, elVideo);
  378. }
  379. if (elWait > 0) elWait--;
  380. else page.win.clearInterval (elRemove);
  381. }, 500);
  382. }
  383.  
  384. function styleMyElement (obj, styles) {
  385. for (var property in styles) {
  386. if (styles.hasOwnProperty(property)) obj.style[property] = styles[property];
  387. }
  388. }
  389.  
  390. function appendMyElement (parent, child) {
  391. parent.appendChild(child);
  392. }
  393.  
  394. function removeMyElement (parent, child) {
  395. parent.removeChild(child);
  396. }
  397.  
  398. function replaceMyElement (parent, orphan, child) {
  399. parent.replaceChild(orphan, child);
  400. }
  401.  
  402. function createHiddenElem(tag, id) {
  403. var elem=document.createElement(tag);
  404. elem.setAttribute('id', id);
  405. elem.setAttribute('style', 'display:none;');
  406. page.doc.body.appendChild(elem);
  407. return elem;
  408. }
  409.  
  410. function injectScript(code) {
  411. var script=document.createElement('script');
  412. script.type='application/javascript';
  413. script.textContent=code;
  414. page.doc.body.appendChild(script);
  415. page.doc.body.removeChild(script);
  416. }
  417.  
  418. function createMyPlayer (player) {
  419. /* Get My Options */
  420. getMyOptions ();
  421.  
  422. /* Player Settings */
  423. player['panelHeight'] = 18;
  424. player['panelPadding'] = 2;
  425.  
  426. /* The Panel */
  427. var panelWidth = player['playerWidth'] - player['panelPadding'] * 2;
  428. player['playerPanel'] = createMyElement ('div', '', '', '', '', player);
  429. styleMyElement (player['playerPanel'], {width: panelWidth + 'px', height: player['panelHeight'] + 'px', padding: player['panelPadding'] + 'px', backgroundColor: '#F4F4F4', textAlign: 'center'});
  430. appendMyElement (player['playerWindow'], player['playerPanel']);
  431.  
  432. /* Panel Items */
  433. var panelItemBorder = 1;
  434. var panelItemHeight = player['panelHeight'] - panelItemBorder * 2;
  435. /* Panel Logo */
  436. player['panelLogo'] = createMyElement ('div', userscript + ':', 'click', 'logo', '', player);
  437. player['panelLogo'].title = 'ViewTube: click to visit the script web page';
  438. styleMyElement (player['panelLogo'], {height: panelItemHeight + 'px', border: '1px solid #F4F4F4', borderRadius: '3px', padding: '0px', display: 'inline', color: '#336699', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
  439. appendMyElement (player['playerPanel'], player['panelLogo']);
  440.  
  441. /* Panel Video Menu */
  442. player['videoMenu'] = createMyElement ('select', '', 'change', '', 'video', player);
  443. player['videoMenu'].title = 'Videos: select the video format for playback';
  444. styleMyElement (player['videoMenu'], {width: '200px', height: panelItemHeight + 'px', border: '1px solid #F4F4F4', borderRadius: '3px', padding: '0px', display: 'inline', backgroundColor: '#F4F4F4', color: '#336699', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', verticalAlign: 'baseline', cursor: 'pointer'});
  445. appendMyElement (player['playerPanel'], player['videoMenu'] );
  446. for (var videoCode in player['videoList']) {
  447. player['videoItem'] = createMyElement ('option', videoCode, '', '', '', player);
  448. styleMyElement (player['videoItem'], {padding: '0px', display: 'block', backgroundColor: '#F4F4F4', color: '#336699', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
  449. appendMyElement (player['videoMenu'], player['videoItem']);
  450. }
  451.  
  452. /* Panel Plugin Menu */
  453. player['pluginMenu'] = createMyElement ('select', '', 'change', '', 'plugin', player);
  454. player['pluginMenu'].title = 'Plugins: select the video plugin for playback';
  455. styleMyElement (player['pluginMenu'], {width: '70px', height: panelItemHeight + 'px', border: '1px solid #F4F4F4', borderRadius: '3px', padding: '0px', display: 'inline', backgroundColor: '#F4F4F4', color: '#336699', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', verticalAlign: 'baseline', cursor: 'pointer'});
  456. appendMyElement (player['playerPanel'], player['pluginMenu'] );
  457. for (var p = 0; p < plugins.length; p++) {
  458. player['pluginItem'] = createMyElement ('option', plugins[p], '', '', '', player);
  459. styleMyElement (player['pluginItem'], {padding: '0px', display: 'block', backgroundColor: '#F4F4F4', color: '#336699', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
  460. appendMyElement (player['pluginMenu'], player['pluginItem']);
  461. }
  462. player['pluginMenu'].value = option['plugin'];
  463. /* Panel Play Button */
  464. player['buttonPlay'] = createMyElement ('div', 'Play', 'click', 'play', '', player);
  465. player['buttonPlay'].title = 'Play/Stop: click to start/stop video playback';
  466. styleMyElement (player['buttonPlay'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 3px', display: 'inline', color: '#37B704', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
  467. // if (option['autoplay']) styleMyElement (player['buttonPlay'], {display: 'none'});
  468. appendMyElement (player['playerPanel'], player['buttonPlay']);
  469. /* Panel Get Button */
  470. player['buttonGet'] = createMyElement ('div', 'Get', 'click', 'get', '', player);
  471. player['buttonGet'].title = 'Get: click to download the selected video format';
  472. styleMyElement (player['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'});
  473. appendMyElement (player['playerPanel'], player['buttonGet']);
  474.  
  475. /* Panel Autoplay Button */
  476. if (feature['autoplay']) {
  477. player['buttonAutoplay'] = createMyElement ('div', 'AP', 'click', 'autoplay', '', player);
  478. player['buttonAutoplay'].title = 'Autoplay: click to enable/disable auto playback on page load';
  479. styleMyElement (player['buttonAutoplay'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#CCCCCC', fontSize: '12px', cursor: 'pointer'});
  480. if (option['autoplay']) styleMyElement (player['buttonAutoplay'], {color: '#008080', textShadow: '0px 1px 1px #CCCCCC'});
  481. appendMyElement (player['playerPanel'], player['buttonAutoplay']);
  482. }
  483.  
  484. /* Panel Definition Button */
  485. if (feature['definition']) {
  486. player['buttonDefinition'] = createMyElement ('div', option['definition'], 'click', 'definition', '', player);
  487. player['buttonDefinition'].title = 'Definition: click to change the preferred video definition';
  488. styleMyElement (player['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'});
  489. appendMyElement (player['playerPanel'], player['buttonDefinition']);
  490. }
  491.  
  492. /* Panel Container Button */
  493. if (feature['container']) {
  494. player['buttonContainer'] = createMyElement ('div', option['container'], 'click', 'container', '', player);
  495. player['buttonContainer'].title = 'Container: click to change the preferred video container';
  496. styleMyElement (player['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'});
  497. appendMyElement (player['playerPanel'], player['buttonContainer']);
  498. }
  499.  
  500. /* Panel Widesize Button */
  501. if (feature['widesize']) {
  502. if (option['widesize']) player['buttonWidesize'] = createMyElement ('div', '&lt;', 'click', 'widesize', '', player);
  503. else player['buttonWidesize'] = createMyElement ('div', '&gt;', 'click', 'widesize', '', player);
  504. player['buttonWidesize'].title = 'Widesize: click to enter player widesize or return to normal size';
  505. styleMyElement (player['buttonWidesize'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#C05800', fontSize: '12px', textShadow: '1px 1px 2px #CCCCCC', cursor: 'pointer'});
  506. appendMyElement (player['playerPanel'], player['buttonWidesize']);
  507. }
  508. /* Panel Fullsize Button */
  509. if (feature['fullsize']) {
  510. if (option['fullsize']) player['buttonFullsize'] = createMyElement ('div', '-', 'click', 'fullsize', '', player);
  511. else player['buttonFullsize'] = createMyElement ('div', '+', 'click', 'fullsize', '', player);
  512. player['buttonFullsize'].title = 'Fullsize: click to enter player fullsize or return to normal size';
  513. styleMyElement (player['buttonFullsize'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#C05800', fontSize: '12px', textShadow: '1px 1px 2px #CCCCCC', cursor: 'pointer'});
  514. appendMyElement (player['playerPanel'], player['buttonFullsize']);
  515. }
  516.  
  517. /* The Content */
  518. player['contentWidth'] = player['playerWidth'];
  519. player['contentHeight'] = player['playerHeight'] - player['panelHeight'] - player['panelPadding'] * 2;
  520. player['playerContent'] = createMyElement ('div', '', '', '', '');
  521. styleMyElement (player['playerContent'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px', backgroundColor: '#000', color: '#AD0000', fontSize: '14px', textAlign: 'center', position: 'relative'});
  522. appendMyElement (player['playerWindow'], player['playerContent']);
  523. /* The Video Thumbnail */
  524. if (player['videoThumb']) {
  525. player['contentImage'] = createMyElement ('img', player['videoThumb'], 'click', 'play', '', player);
  526. player['contentImage'].title = 'Click to start video playback';
  527. // styleMyElement (player['contentImage'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px', border: '0px', cursor: 'pointer'});
  528. styleMyElement (player['contentImage'], {maxWidth: '100%', maxHeight: '100%', position: 'absolute', top: '0px', bottom: '0px', left: '0px', right: '0px', margin: 'auto', border: '0px', cursor: 'pointer'});
  529.  
  530. // make sure small thumbnails will fill up the content area
  531. player['contentImage'].addEventListener('load', function () {
  532. // if image is wider than content area, scale its width, otherwise its height
  533. if (this.width/this.height >= player['contentWidth']/player['contentHeight']) {
  534. this.style.width = '1920px';
  535. }
  536. else {
  537. this.style.height = '1080px';
  538. }
  539. });
  540. }
  541.  
  542. /* Disabled Features */
  543. if (!feature['autoplay']) option['autoplay'] = false;
  544. if (!feature['widesize']) option['widesize'] = false;
  545. if (!feature['fullsize']) option['fullsize'] = false;
  546. /* Resize My Player */
  547. if (option['widesize']) resizeMyPlayer(player, 'widesize');
  548. if (option['fullsize']) resizeMyPlayer(player, 'fullsize');
  549. /* Select My Video */
  550. if (feature['definition'] || feature['container']) selectMyVideo (player);
  551. /* Play My Video */
  552. playMyVideo (player, option['autoplay']);
  553. }
  554.  
  555. function selectMyVideo (player) {
  556. var vdoCont = (option['container'] != 'Any') ? [option['container']] : option['containers'];
  557. var vdoDef = option['definitions'];
  558. var vdoList = {};
  559. for (var vC = 0; vC < vdoCont.length; vC++) {
  560. if (vdoCont[vC] != 'Any') {
  561. for (var vD = 0; vD < vdoDef.length; vD++) {
  562. var format = vdoDef[vD] + ' ' + vdoCont[vC];
  563. if (!vdoList[vdoDef[vD]]) {
  564. for (var vL in player['videoList']) {
  565. if (vL == format) {
  566. vdoList[vdoDef[vD]] = vL;
  567. break;
  568. }
  569. }
  570. }
  571. }
  572. }
  573. }
  574. if (option['definition'] == 'UHD') {
  575. if (vdoList['Ultra High Definition']) player['videoPlay'] = vdoList['Ultra High Definition'];
  576. else if (vdoList['Full High Definition']) player['videoPlay'] = vdoList['Full High Definition'];
  577. else if (vdoList['High Definition']) player['videoPlay'] = vdoList['High Definition'];
  578. else if (vdoList['Standard Definition']) player['videoPlay'] = vdoList['Standard Definition'];
  579. else if (vdoList['Low Definition']) player['videoPlay'] = vdoList['Low Definition'];
  580. else if (vdoList['Very Low Definition']) player['videoPlay'] = vdoList['Very Low Definition'];
  581. }
  582. else if (option['definition'] == 'FHD') {
  583. if (vdoList['Full High Definition']) player['videoPlay'] = vdoList['Full High Definition'];
  584. else if (vdoList['High Definition']) player['videoPlay'] = vdoList['High Definition'];
  585. else if (vdoList['Standard Definition']) player['videoPlay'] = vdoList['Standard Definition'];
  586. else if (vdoList['Low Definition']) player['videoPlay'] = vdoList['Low Definition'];
  587. else if (vdoList['Very Low Definition']) player['videoPlay'] = vdoList['Very Low Definition'];
  588. }
  589. else if (option['definition'] == 'HD') {
  590. if (vdoList['High Definition']) player['videoPlay'] = vdoList['High Definition'];
  591. else if (vdoList['Standard Definition']) player['videoPlay'] = vdoList['Standard Definition'];
  592. else if (vdoList['Low Definition']) player['videoPlay'] = vdoList['Low Definition'];
  593. else if (vdoList['Very Low Definition']) player['videoPlay'] = vdoList['Very Low Definition'];
  594. }
  595. else if (option['definition'] == 'SD') {
  596. if (vdoList['Standard Definition']) player['videoPlay'] = vdoList['Standard Definition'];
  597. else if (vdoList['Low Definition']) player['videoPlay'] = vdoList['Low Definition'];
  598. else if (vdoList['Very Low Definition']) player['videoPlay'] = vdoList['Very Low Definition'];
  599. }
  600. else if (option['definition'] == 'LD') {
  601. if (vdoList['Low Definition']) player['videoPlay'] = vdoList['Low Definition'];
  602. else if (vdoList['Very Low Definition']) player['videoPlay'] = vdoList['Very Low Definition'];
  603. }
  604. else if (option['definition'] == 'VLD') {
  605. if (vdoList['Very Low Definition']) player['videoPlay'] = vdoList['Very Low Definition'];
  606. else if (vdoList['Low Definition']) player['videoPlay'] = vdoList['Low Definition'];
  607. }
  608. player['videoMenu'].value = player['videoPlay'];
  609. }
  610.  
  611. function playMyVideo (player, play) {
  612. if (play) {
  613. player['isPlaying'] = true;
  614. modifyMyElement (player['buttonPlay'], 'div', 'Stop', false);
  615. styleMyElement (player['buttonPlay'], {color: '#AD0000'});
  616. if (option['plugin'] == 'HTML5') {
  617. if (player['videoPlay'] == 'DASH MP4') {
  618. player['contentVideo'] = createVideoElement ('video', 'DASH', player);
  619. }
  620. else player['contentVideo'] = createVideoElement ('video', player['videoList'][player['videoPlay']], player);
  621. }
  622. else if (navigator.appName == 'Netscape') player['contentVideo'] = createVideoElement ('embed', player['videoList'][player['videoPlay']], player);
  623. else createVideoElement ('object', player['videoList'][player['videoPlay']], player);
  624. }
  625. else {
  626. player['isPlaying'] = false;
  627. modifyMyElement (player['buttonPlay'], 'div', 'Play', false);
  628. styleMyElement (player['buttonPlay'], {color: '#37B704'});
  629. modifyMyElement (player['playerContent'], 'div', '', true);
  630. if (player['videoDuration']) {
  631. var hours = Math.floor(player['videoDuration'] / 3600);
  632. var minutes = Math.floor((player['videoDuration'] % 3600) / 60);
  633. var seconds = (player['videoDuration'] % 3600) % 60;
  634. var duration = (hours > 0 ? (hours + ':' + (minutes > 9 ? minutes : '0' + minutes)) : minutes) + ':' + (seconds > 9 ? seconds : '0' + seconds);
  635. player['durationElem'] = createMyElement ('div',duration , '', '', '', player);
  636. styleMyElement (player['durationElem'], {position: 'absolute', backgroundColor: '#000000', color: '#FFFFFF', fontSize: '14px',fontWeight: 'bold', textAlign: 'right',
  637. right: '5px', bottom: '10px',paddingLeft: '2px', paddingRight: '2px', zIndex: '9'});
  638. appendMyElement (player['playerContent'], player['durationElem']);
  639. }
  640.  
  641. if (player['contentImage']) appendMyElement (player['playerContent'], player['contentImage']);
  642. else showMyMessage ('!thumb');
  643. }
  644. }
  645.  
  646. function getMyVideo (player) {
  647. var vdoURL = player['videoList'][player['videoPlay']];
  648. if (player['videoTitle']) {
  649. var vdoD = ' (' + player['videoPlay'] + ')';
  650. vdoD = vdoD.replace(/Ultra High Definition/, 'UHD');
  651. vdoD = vdoD.replace(/Full High Definition/, 'FHD');
  652. vdoD = vdoD.replace(/High Definition/, 'HD');
  653. vdoD = vdoD.replace(/Standard Definition/, 'SD');
  654. vdoD = vdoD.replace(/Very Low Definition/, 'VLD');
  655. vdoD = vdoD.replace(/Low Definition/, 'LD');
  656. vdoD = vdoD.replace(/\sFLV|\sMP4|\sWebM|\s3GP/g, '');
  657. vdoURL = vdoURL + '&title=' + player['videoTitle'] + vdoD;
  658. }
  659. if (option['autoget']) page.win.location.href = vdoURL;
  660. else {
  661. var vdoLink = 'Get <a href="' + vdoURL + '">Link</a>';
  662. modifyMyElement (player['buttonGet'] , 'div', vdoLink, false);
  663. player['isGetting'] = true;
  664. }
  665. }
  666.  
  667. function resizeMyPlayer (player, size) {
  668. if (size == 'widesize') {
  669. if (option['widesize']) {
  670. modifyMyElement (player['buttonWidesize'], 'div', '&lt;', false);
  671. var playerWidth = player['playerWideWidth'];
  672. var playerHeight= player['playerWideHeight'];
  673. var sidebarMargin = player['sidebarMarginWide'];
  674. var playlistMargin = player['playerWideHeight'];
  675. }
  676. else {
  677. modifyMyElement (player['buttonWidesize'], 'div', '&gt;', false);
  678. var playerWidth = player['playerWidth'];
  679. var playerHeight= player['playerHeight'];
  680. var sidebarMargin = player['sidebarMarginNormal'];
  681. var playlistMargin = 0;
  682. }
  683. }
  684. else if (size == 'fullsize') {
  685. if (option['fullsize']) {
  686. var playerPosition = 'fixed';
  687. var playerWidth = page.win.innerWidth || page.doc.documentElement.clientWidth;
  688. var playerHeight = page.win.innerHeight || page.doc.documentElement.clientHeight;
  689. var playerIndex = '2147483647';
  690. var frames = document.getElementsByTagName('iframe');
  691. for (var i = 0 ; i <frames.length; i++) styleMyElement(frames[i], {display: 'none'});
  692. setTimeout(function(){ if (option['fullsize']) {var frames = document.getElementsByTagName('iframe'); for (var i = 0 ; i <frames.length; i++) styleMyElement(frames[i], {display: 'none'});}},3000);
  693. if (!player['isFullsize']) {
  694. if (feature['widesize']) styleMyElement (player['buttonWidesize'], {display: 'none'});
  695. modifyMyElement (player['buttonFullsize'], 'div', '-', false);
  696. styleMyElement (page.body, {overflow: 'hidden'});
  697. if (!player['resizeListener']) player['resizeListener'] = function() {resizeMyPlayer(player, 'fullsize')};
  698. page.win.addEventListener ('resize', player['resizeListener'], false);
  699. OrgPlayerIndex = player['playerWindow'].style['zIndex'];
  700. OrgHeadWindowIndex = '';
  701. if (HeadWindow && HeadWindow.style) {
  702. OrgHeadWindowIndex = HeadWindow.style['zIndex'];
  703. styleMyElement(HeadWindow, {zIndex: -10});
  704. }
  705. player['isFullsize'] = true;
  706. }
  707. }
  708. else {
  709. var playerPosition = 'relative';
  710. var playerWidth = (option['widesize']) ? player['playerWideWidth'] : player['playerWidth'];
  711. var playerHeight = (option['widesize']) ? player['playerWideHeight'] : player['playerHeight'];
  712. var playerIndex = OrgPlayerIndex;
  713. var frames = document.getElementsByTagName('iframe');
  714. for (var i = 0 ; i <frames.length; i++) styleMyElement(frames[i], {display: ''});
  715. if (feature['widesize']) styleMyElement (player['buttonWidesize'], {display: 'inline'});
  716. modifyMyElement (player['buttonFullsize'], 'div', '+', false);
  717. styleMyElement (page.body, {overflow: 'auto'});
  718. page.win.removeEventListener ('resize', player['resizeListener'], false);
  719. if (HeadWindow && HeadWindow.style) styleMyElement(HeadWindow, {zIndex: OrgHeadWindowIndex});
  720. var frames = document.getElementsByTagName('iframe')
  721. for (var i = 0 ; i <frames.length; i++) {
  722. styleMyElement(frames[i], { display: ''});
  723. }
  724. player['isFullsize'] = false;
  725. }
  726. }
  727.  
  728. /* Resize The Player */
  729. if (size == 'widesize') {
  730. styleMyElement (player['sidebarWindow'], {marginTop: sidebarMargin + 'px'});
  731. // Playlist position fix for youtube
  732. var ytPlaylist = getMyElement ('', 'div', 'id', 'player-playlist', -1, false);
  733. if (ytPlaylist) styleMyElement (ytPlaylist, {top: playlistMargin + 'px'});
  734. styleMyElement (player['playerWindow'], {width: playerWidth + 'px', height: playerHeight + 'px'});
  735. }
  736. else {
  737. styleMyElement (player['playerWindow'], {position: playerPosition, top: '0px', left: '0px', width: playerWidth + 'px', height: playerHeight + 'px', zIndex: playerIndex});
  738. }
  739. /* Resize The Panel */
  740. var panelWidth = playerWidth - player['panelPadding'] * 2;
  741. styleMyElement (player['playerPanel'], {width: panelWidth + 'px'});
  742.  
  743. /* Resize The Content */
  744. player['contentWidth'] = playerWidth;
  745. player['contentHeight'] = playerHeight - player['panelHeight'] - player['panelPadding'] * 2;
  746. styleMyElement (player['playerContent'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px'});
  747. // if (player['contentImage']) styleMyElement (player['contentImage'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px', border: '0px'});
  748. if (player['isPlaying']) {
  749. player['contentVideo'].width = player['contentWidth'];
  750. player['contentVideo'].height = player['contentHeight'];
  751. styleMyElement (player['contentVideo'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px'});
  752. }
  753. }
  754.  
  755. function cleanMyContent (content, unesc) {
  756. var myNewContent = content;
  757. if (!content) return myNewContent;
  758. if (unesc) myNewContent = unescape (myNewContent);
  759. myNewContent = myNewContent.replace (/\\u0025/g,'%');
  760. myNewContent = myNewContent.replace (/\\u0026/g,'&');
  761. myNewContent = myNewContent.replace (/\\/g,'');
  762. myNewContent = myNewContent.replace (/\n/g,'');
  763. return myNewContent;
  764. }
  765.  
  766. function getMyContent (url, pattern, clean) {
  767. var myPageContent, myVideosParse, myVideosContent;
  768. var isIE = (navigator.appName.indexOf('Internet Explorer') != -1) ? true : false;
  769. var getMethod = (url != page.url || isIE) ? 'XHR' : 'DOM';
  770. if (getMethod == 'DOM') {
  771. myPageContent = getMyElement ('', 'html', 'tag', '', 0, true);
  772. if (!myPageContent) myPageContent = getMyElement ('', 'body', '', '', -1, true);
  773. if (clean) myPageContent = cleanMyContent (myPageContent, true);
  774. myVideosParse = myPageContent.match (pattern);
  775. myVideosContent = (myVideosParse) ? myVideosParse[1] : null;
  776. if (myVideosContent) return myVideosContent;
  777. else getMethod = 'XHR';
  778. }
  779. if (getMethod == 'XHR') {
  780. var xmlHTTP = new XMLHttpRequest();
  781. xmlHTTP.open('GET', url, false);
  782. xmlHTTP.send();
  783. if (pattern == 'XML') {
  784. myVideosContent = xmlHTTP.responseXML;
  785. }
  786. else if (pattern == 'TEXT') {
  787. myVideosContent = xmlHTTP.responseText;
  788. }
  789. else {
  790. myPageContent = xmlHTTP.responseText;
  791. if (clean) myPageContent = cleanMyContent (myPageContent, true);
  792. myVideosParse = myPageContent.match (pattern);
  793. myVideosContent = (myVideosParse) ? myVideosParse[1] : null;
  794. }
  795. return myVideosContent;
  796. }
  797. }
  798.  
  799. function setMyOptions (key, value) {
  800. var key_extended = key + "_" + page.url.match(/https?:\/\/(www\.)?(.*?)\//)[2];
  801. if (typeof GM_setValue === 'function') {
  802. GM_setValue(key_extended, value);
  803. }
  804. else {
  805. try {
  806. localStorage.setItem(key_extended, value);
  807. }
  808. catch(e) {
  809. var date = new Date();
  810. date.setTime(date.getTime() + (356*24*60*60*1000));
  811. var expires = '; expires=' + date.toGMTString();
  812. page.doc.cookie = key_extended + '=' + value + expires + '; path=/';
  813. }
  814. }
  815. }
  816.  
  817. function getMyOption (key) {
  818. var key_extended = key + "_" + page.url.match(/https?:\/\/(www\.)?(.*?)\//)[2];
  819. if ((typeof GM_getValue === 'function') ){
  820. return GM_getValue(key_extended, null);
  821. }
  822. else
  823. try {
  824. return localStorage.setItem(key_extended);
  825. }
  826. catch(e) {
  827. var cookies = page.doc.cookie.split(';');
  828. for (var i=0; i < cookies.length; i++) {
  829. var cookie = cookies[i];
  830. while (cookie.charAt(0) == ' ') cookie = cookie.substring(1, cookie.length);
  831. if (cookie.indexOf(key) == 0) {
  832. return cookie.substring(key.length + 1, cookie.length);
  833. }
  834. }
  835. }
  836. }
  837.  
  838. function getMyOptions () {
  839. var tmpOption;
  840. tmpOption = getMyOption('viewtube_plugin');
  841. if (plugins.indexOf(tmpOption) == -1) tmpOption = plugins[0];
  842. option['plugin'] = tmpOption ? tmpOption : option['plugin'];
  843. option['autoplay'] = getMyOption('viewtube_autoplay');
  844. option['autoplay'] = (option['autoplay'] == 'true' || option['autoplay'] == true) ? true : false;
  845. tmpOption = getMyOption('viewtube_definition');
  846. option['definition'] = tmpOption ? tmpOption : option['definition'];
  847. tmpOption = getMyOption('viewtube_container');
  848. option['container'] = tmpOption ? tmpOption : option['container'];
  849. option['widesize'] = getMyOption('viewtube_widesize');
  850. option['widesize'] = (option['widesize'] == 'true' || option['widesize'] == true) ? true : false;
  851. option['fullsize'] = false;
  852. }
  853.  
  854. function showMyMessage (cause, content) {
  855. var myScriptLogo = createMyElement ('div', userscript, '', '', '');
  856. styleMyElement (myScriptLogo, {margin: '0px auto', padding: '10px', color: '#666666', fontSize: '24px', textAlign: 'center', textShadow: '#FFFFFF -1px -1px 2px'});
  857. var myScriptMess = createMyElement ('div', '', '', '', '');
  858. styleMyElement (myScriptMess, {border: '1px solid #F4F4F4', margin: '5px auto 5px auto', padding: '10px', backgroundColor: '#FFFFFF', color: '#AD0000', textAlign: 'center'});
  859. if (cause == '!player') {
  860. var myScriptAlert = createMyElement ('div', '', '', '', '');
  861. styleMyElement (myScriptAlert, {position: 'absolute', top: '30%', left: '35%', border: '1px solid #F4F4F4', borderRadius: '3px', padding: '10px', backgroundColor: '#F8F8F8', fontSize: '14px', textAlign: 'center', zIndex: '99999'});
  862. appendMyElement (myScriptAlert, myScriptLogo);
  863. var myNoPlayerMess = 'Couldn\'t get the player element. Please report it <a href="' + contact + '">here</a>.';
  864. modifyMyElement (myScriptMess, 'div', myNoPlayerMess, false);
  865. appendMyElement (myScriptAlert, myScriptMess);
  866. var myScriptAlertButton = createMyElement ('div', 'OK', 'click', 'close', myScriptAlert);
  867. 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'});
  868. appendMyElement (myScriptAlert, myScriptAlertButton);
  869. appendMyElement (page.body, myScriptAlert);
  870. }
  871. else if (cause == '!thumb') {
  872. var myNoThumbMess = '<br><br>Couldn\'t get the thumbnail for this video. Please report it <a href="' + contact + '">here</a>.';
  873. modifyMyElement (player['playerContent'], 'div', myNoThumbMess, false);
  874. }
  875. else {
  876. appendMyElement (myPlayerWindow, myScriptLogo);
  877. if (cause == '!content') {
  878. var myNoContentMess = 'Couldn\'t get the videos content. Please report it <a href="' + contact + '">here</a>.';
  879. modifyMyElement (myScriptMess, 'div', myNoContentMess, false);
  880. }
  881. else if (cause == '!videos') {
  882. var myNoVideosMess = 'Couldn\'t get any video. Please report it <a href="' + contact + '">here</a>.';
  883. modifyMyElement (myScriptMess, 'div', myNoVideosMess, false);
  884. }
  885. else if (cause == '!support') {
  886. var myNoSupportMess = 'This video uses the RTMP protocol and is not supported.';
  887. modifyMyElement (myScriptMess, 'div', myNoSupportMess, false);
  888. }
  889. else if (cause == 'embed') {
  890. var myEmbedMess = 'This is an embedded video. You can watch it <a href="' + content + '">here</a>.';
  891. modifyMyElement (myScriptMess, 'div', myEmbedMess, false);
  892. }
  893. else if (cause == 'other') {
  894. modifyMyElement (myScriptMess, 'div', content, false);
  895. }
  896. appendMyElement (myPlayerWindow, myScriptMess);
  897. }
  898. }
  899.  
  900. function crossXmlHttpRequest(details) { // cross-browser GM_xmlhttpRequest
  901. if (typeof GM_xmlhttpRequest === 'function') { // Greasemonkey, Tampermonkey, Firefox extension, Chrome script
  902. GM_xmlhttpRequest(details);
  903. } else if (typeof window.opera !== 'undefined' && window.opera && typeof opera.extension !== 'undefined' &&
  904. typeof opera.extension.postMessage !== 'undefined') { // Opera 12 extension
  905. opera.extension.postMessage({'action':'xhr', 'url':details.url});
  906. opera.extension.onmessage = function(event) {
  907. if (event.data.action === 'xhr-response' && event.data.error === false) {
  908. if (details['onload']) {
  909. details['onload']({responseText:event.data.response, readyState:4, status:200});
  910. }
  911. }
  912. }
  913. } else if (typeof window.opera === 'undefined' && typeof XMLHttpRequest === 'function') { // Opera 15+ extension
  914. var xhr=new XMLHttpRequest();
  915. xhr.onreadystatechange = function() {
  916. if (xhr.readyState == 4) {
  917. if (details['onload'] && xhr.status >= 200 && xhr.status < 300) {
  918. details['onload']({responseText:xhr.responseText, readyState:xhr.readyState, status:xhr.status});
  919. }
  920. }
  921. }
  922. xhr.open(details.method, details.url, true);
  923. xhr.send();
  924. }
  925. }
  926. function getMyContentGM(url, pattern, clean, callback) {
  927. var myPageContent, myVideosParse, myVideosContent;
  928. var isIE = (navigator.appName.indexOf('Internet Explorer') != -1) ? true : false;
  929. var getMethod = (url != page.url || isIE) ? 'XHR' : 'DOM';
  930. if (getMethod == 'DOM') {
  931. myPageContent = getMyElement ('', 'html', 'tag', '', 0, true);
  932. if (!myPageContent) myPageContent = getMyElement ('', 'body', '', '', -1, true);
  933. if (clean) myPageContent = cleanMyContent (myPageContent, true);
  934. myVideosParse = myPageContent.match (pattern);
  935. myVideosContent = (myVideosParse) ? myVideosParse[1] : null;
  936. if (myVideosContent) callback(myVideosContent);
  937. else getMethod = 'XHR';
  938. }
  939. if (getMethod == 'XHR') {
  940. crossXmlHttpRequest({
  941. method: 'GET',
  942. url: url,
  943. onload: function(response) {
  944. if (pattern == 'TEXT') {
  945. myVideosContent = response.responseText;
  946. }
  947. else {
  948. myPageContent = response.responseText;
  949. if (clean) myPageContent = cleanMyContent (myPageContent, true);
  950. myVideosParse = myPageContent.match (pattern);
  951. myVideosContent = (myVideosParse) ? myVideosParse[1] : null;
  952. }
  953. callback(myVideosContent);
  954. }
  955. });
  956. }
  957. }
  958.  
  959.  
  960. // ==========Websites========== //
  961.  
  962. // Fixes
  963. var blockObject = null;
  964. var blockInterval = 50;
  965. page.win.setInterval(function() {
  966. // Block videos
  967. if (blockObject && blockInterval > 0) {
  968. var elEmbeds = getMyElement (blockObject, 'embed', 'tag', '', -1, false) || getMyElement (blockObject, 'object', 'tag', '', -1, false);
  969. if (elEmbeds.length > 0) {
  970. for (var e = 0; e < elEmbeds.length; e++) {
  971. var elEmbed = elEmbeds[e];
  972. if (elEmbed && elEmbed.id != 'vtVideo' && elEmbed.parentNode) {
  973. removeMyElement (elEmbed.parentNode, elEmbed);
  974. }
  975. }
  976. }
  977. var elVideos = getMyElement (blockObject, 'video', 'tag', '', -1, false);
  978. if (elVideos.length > 0) {
  979. for (var v = 0; v < elVideos.length; v++) {
  980. var elVideo = elVideos[v];
  981. if (elVideo && elVideo.id != 'vtVideo' && elVideo.currentSrc) {
  982. modifyMyElement (elVideo, 'video', 'none', true);
  983. }
  984. }
  985. }
  986. if (blockInterval > 0) blockInterval--;
  987. }
  988. }, 500);
  989.  
  990. // =====YouTube===== //
  991. /* Redirect Categories */
  992. if (page.url.indexOf('gaming.youtube.com') != -1) {
  993. page.win.location.href = page.url.replace('gaming', 'www');
  994. }
  995.  
  996. else if (page.url.indexOf('www.youtube.com/') != -1) {
  997.  
  998. var decodeArray=[];
  999. var searchstring;
  1000. ytPlayerResize = function () {return null;};
  1001.  
  1002. function findSignatureCode(ytScriptSrc) {
  1003. var arr=[];
  1004. ytScriptSrc = ytScriptSrc.replace(/(\r\n|\n|\r)/gm, '');
  1005. var functionName = ytScriptSrc.match(/"signature"\s*,\s*(.*?)\(/);
  1006. if (functionName == null) return;
  1007. functionName = functionName[1];
  1008. if (functionName.indexOf('$') == 0) functionName = "\\" + functionName;
  1009. var regCode = new RegExp('function '+functionName+'\\s*\\(\\w+\\)\\s*{\\w+=\\w+\\.split\\(""\\);(.+);return \\w+\\.join');
  1010. var functionCode = ytScriptSrc.match('function '+functionName+'\\s*\\(\\w+\\)\\s*{\\w+=\\w+\\.split\\(""\\);(.+);return \\w+\\.join');
  1011. if (!functionCode) functionCode = ytScriptSrc.match(functionName+'=function+\\s*\\(\\w+\\)\\s*{\\w+=\\w+\\.split\\(""\\);(.+?);return \\w+\\.join')
  1012. if (functionCode == null) return;
  1013. functionCode = functionCode[1];
  1014. var functionCodePieces = functionCode.split(';');
  1015. var decodevariable = functionCodePieces[0].match(/(\w+=)?(.*?)\./)[2];
  1016. var decodefunctions = ytScriptSrc.match('var\\s+'+decodevariable+'=\\{.*?\\}\\}');
  1017. if (decodefunctions) {
  1018. var freverse = decodefunctions[0].match(decodevariable +'=.*(\\{|,)(.*?)\\:function.*?reverse\\(.*\\)\\}')[2];
  1019. var fslice = decodefunctions[0].match(decodevariable +'=.*(\\{|,)(.*?)\\:function.*?sp?lice\\(.*\\)\\}')[2];
  1020. var fswap = decodefunctions[0].match(decodevariable +'=.*(\\{|,)(.*?)\\:function.*?length];.*\\}')[2];
  1021. } else return;
  1022. for (var i=0; i<functionCodePieces.length; i++) {
  1023. functionCodePieces[i]=functionCodePieces[i].trim();
  1024. if (functionCodePieces[i].length>0)
  1025. if (functionCodePieces[i].indexOf(fslice) >= 0) { // slice
  1026. var slice=functionCodePieces[i].match(fslice+'\\s*\\(\\s*\\w*\\s*,(.+)\\s*\\)')[1];
  1027. slice=parseInt(slice, 10);
  1028. if (typeof slice === 'number') {
  1029. arr.push(-slice);
  1030. } else return;
  1031. } else if (functionCodePieces[i].indexOf(freverse) >= 0) {
  1032. arr.push(0);
  1033. } else if (functionCodePieces[i].indexOf(fswap) >= 0) {
  1034. var inline=functionCodePieces[i].match(fswap+'\\s*\\(\\s*\\w*\\s*,(.+)\\s*\\)')[1];
  1035. inline=parseInt(inline, 10);
  1036. if (typeof inline === 'number') {
  1037. arr.push(inline);
  1038. } else return;
  1039. } else if (functionCodePieces[i].indexOf(',') >= 0) {
  1040. var swap=functionCodePieces[i].match(regSwap)[1];
  1041. swap=parseInt(swap, 10);
  1042. if (typeof swap === 'number') {
  1043. arr.push(swap);
  1044. } else return;
  1045. } else return;
  1046. }
  1047. return arr;
  1048. }
  1049.  
  1050. function decryptSignature(sig) {
  1051. function swap(a,b){var c=a[0];a[0]=a[b%a.length];a[b]=c;return a};
  1052. function decode(sig, arr) { // encoded decryption
  1053. if (typeof sig !== 'string') return null;
  1054. var sigA=sig.split('');
  1055. for (var i=0;i<arr.length;i++) {
  1056. var act=parseInt(arr[i]);
  1057. if (typeof act !== 'number') return null;
  1058. sigA=(act>0)?swap(sigA, act):((act==0)?sigA.reverse():sigA.slice(-act));
  1059. }
  1060. return sigA.join('');
  1061. }
  1062. if (sig==null) return '';
  1063. if (decodeArray) {
  1064. var sig2=decode(sig, decodeArray);
  1065. if (sig2 && sig2.length == 81) return sig2;
  1066. }
  1067. return sig;
  1068. }
  1069. function yt_run(isMutation) {
  1070. /* Player Size */
  1071. var ytSidebarMarginNormal = 382;
  1072. var ytSidebarWindow = getMyElement ('', 'div', 'id', 'watch7-sidebar', -1, false);
  1073. if (ytSidebarWindow) var ytSidebarWindowStyle = ytSidebarWindow.currentStyle || window.getComputedStyle(ytSidebarWindow);
  1074. if (ytSidebarWindowStyle) {
  1075. ytSidebarMarginNormal = parseInt(ytSidebarWindowStyle.marginTop.replace('px', ''));
  1076. styleMyElement (ytSidebarWindow, {marginTop: ytSidebarMarginNormal + 'px'});
  1077. }
  1078. var ytPlayerWidth, ytPlayerHeight;
  1079. var ytPlayerWideWidth, ytPlayerWideHeight;
  1080. var ytSidebarMarginWide;
  1081. var ytScreenWidth, ytScreenHeight;
  1082.  
  1083. function ytSizes() {
  1084. ytScreenWidth = page.win.innerWidth || page.doc.documentElement.clientWidth;
  1085. ytScreenHeight = page.win.innerHeight || page.doc.documentElement.clientHeight;
  1086. if (ytScreenWidth >= 1720 && ytScreenHeight >= 980) {
  1087. ytPlayerWidth = 1280;
  1088. ytPlayerHeight = 742;
  1089. ytPlayerWideWidth = 1706;
  1090. ytPlayerWideHeight = 982;
  1091. }
  1092. else if (ytScreenWidth >= 1294 && ytScreenHeight >= 630) {
  1093. ytPlayerWidth = 854;
  1094. ytPlayerHeight = 502;
  1095. ytPlayerWideWidth = 1280;
  1096. ytPlayerWideHeight = 742;
  1097. }
  1098. else {
  1099. ytPlayerWidth = 640;
  1100. ytPlayerHeight = 382;
  1101. ytPlayerWideWidth = 1066;
  1102. ytPlayerWideHeight = 622;
  1103. }
  1104. ytSidebarMarginWide = ytPlayerHeight + ytSidebarMarginNormal - 12;
  1105. }
  1106.  
  1107. page = {win: window, doc: document, body: document.body, url: window.location.href}
  1108. /* Get Player Window */
  1109. var ytPlayerBgColor = '#FFFFFF';
  1110. var ytPlayerWindow = getMyElement ('', 'div', 'id', 'player', -1, false);
  1111. if (!ytPlayerWindow) {
  1112. ytPlayerWindow = getMyElement ('', 'div', 'id', 'p', -1, false);
  1113. ytPlayerBgColor = 'inherit';
  1114. feature['widesize'] = false; }
  1115. if (!ytPlayerWindow) {
  1116. showMyMessage ('!player');
  1117. }
  1118. else {
  1119. var ytVideoID = null;
  1120. var ytVideosContent = null;
  1121. var ytVideosEncodedFmts = null;
  1122. var ytVideosAdaptiveFmts = null;
  1123. var ytVideosDashmpd;
  1124.  
  1125. /* Clean Player Window */
  1126. var ytWatchPlayer = getMyElement ('', 'div', 'id', 'player-api', -1, false);
  1127. if (ytWatchPlayer) styleMyElement (ytWatchPlayer, {display: 'none'});
  1128.  
  1129. // Stop playlist Autoplay
  1130. var ytNavControl = getMyElement ('', 'div', 'class', 'playlist-nav-controls', 0, false);
  1131. if (ytNavControl) {
  1132. injectScript ('var NextVidEnabled = true;ytspf.enabled = false;ytspf.config["navigate-limit"] = 0;_spf_state.config["navigate-limit"] = 0;var NextVidStopperGetNextValues = function () {var nextLink = document.getElementsByClassName("playlist-behavior-controls")[0].getElementsByTagName("a")[1].href;var nextLinkStart = nextLink.search("v=");var nextLinkEnd = nextLink.search("&");return nextLink.substring(nextLinkStart + 2, nextLinkEnd);};for (var key in _yt_www) {var stringFunction = "" + _yt_www[key];if (stringFunction.search("window.spf.navigate") != -1) {_yt_www[key] = function (a, b) {if (a.search(NextVidStopperGetNextValues()) == -1 || NextVidEnabled == false) {window.location = a;}};}}');
  1133. }
  1134.  
  1135. /* Get Video Thumbnail */
  1136. ytVideoID = page.url.match (/(\?|&)v=(.*?)(&|$)/);
  1137. ytVideoID = (ytVideoID) ? ytVideoID[2] : null;
  1138.  
  1139. var ytVideoThumb = getMyContent (page.url, 'link\\s+itemprop="thumbnailUrl"\\s+href="(.*?)"', false);
  1140. if (!ytVideoThumb) ytVideoThumb = getMyContent (page.url, 'meta\\s+property="og:image"\\s+content="(.*?)"', false);
  1141. if (!ytVideoThumb) {
  1142. if (ytVideoID) ytVideoThumb = page.win.location.protocol + '//img.youtube.com/vi/' + ytVideoID + '/0.jpg';
  1143. }
  1144.  
  1145. /* Get Video Title */
  1146. var ytVideoTitle = getMyContent (page.url, 'meta\\s+itemprop="name"\\s+content="(.*?)"', false);
  1147. if (!ytVideoTitle) ytVideoTitle = getMyContent (page.url, 'meta\\s+property="og:title"\\s+content="(.*?)"', false);
  1148. if (!ytVideoTitle) ytVideoTitle = page.doc.title;
  1149. if (ytVideoTitle) {
  1150. ytVideoTitle = ytVideoTitle.replace(/&quot;/g, '\'').replace(/&#34;/g, '\'').replace(/"/g, '\'');
  1151. ytVideoTitle = ytVideoTitle.replace(/&#39;/g, '\'').replace(/'|’/g, '\'');
  1152. ytVideoTitle = ytVideoTitle.replace(/&amp;/g, '&');
  1153. // ytVideoTitle = ytVideoTitle.replace(/\?/g, '').replace(/[#:\*]/g, '-').replace(/\//g, '-');
  1154. ytVideoTitle = ytVideoTitle.replace(/^\s+|\s+$/, '').replace(/\.+$/g, '');
  1155. ytVideoTitle = ytVideoTitle.replace(/^YouTube\s-\s/, '').replace(/\s-\sYouTube$/, '');
  1156. }
  1157. var ytVideoDuration = getMyContent (page.url, 'meta\\s+itemprop="duration"\\s+content="(.*?)"', false);
  1158. if (ytVideoDuration) {
  1159. ytVideoDuration = parseInt(ytVideoDuration.match(/\d{1,3}M/) ? ytVideoDuration.match(/(\d{1,3})M/)[1] :0) * 60 + parseInt(ytVideoDuration.match(/\d{1,2}S/) ? ytVideoDuration.match(/(\d{1,2})S/)[1] :0);
  1160. }
  1161. var ytVideoAvailable = getMyElement ('', 'div', 'id', 'player-unavailable', -1, false);
  1162. if (ytVideoAvailable && ytVideoAvailable.className.indexOf('hid') == -1) styleMyElement (ytVideoAvailable, {display: 'inline'});
  1163. myPlayerWindow = getMyElement ('', 'div', 'id', 'MyytWindow', -1, false);
  1164. if (myPlayerWindow) removeMyElement(myPlayerWindow.parentNode,myPlayerWindow);
  1165.  
  1166. /* Get Videos Content */
  1167. var ytScriptURL;
  1168. if (ytVideoAvailable && (ytVideoAvailable.className.indexOf('hid') != -1 || getMyElement ('', 'div', 'id', 'watch7-player-age-gate-content', -1, false))) {
  1169. if (isMutation) {
  1170. var injectedElement = document.getElementById('download-youtube-video-debug-info9');
  1171. if (injectedElement==null) {
  1172. injectedElement = createHiddenElem('pre', 'download-youtube-video-debug-info9');
  1173. }
  1174. injectScript ('if (typeof ytplayer.config == "object" && ytplayer.config != null) document.getElementById("download-youtube-video-debug-info9").appendChild(document.createTextNode(\'"video_id":"\'+ytplayer.config.args.video_id+\'", "js":"\'+ytplayer.config.assets.js+\'", "adaptive_fmts":"\'+ytplayer.config.args.adaptive_fmts+\'", "dashmpd":"\'+ytplayer.config.args.dashmpd+\'", "url_encoded_fmt_stream_map":"\'+ytplayer.config.args.url_encoded_fmt_stream_map+\'"\'));');
  1175. var code = getMyElement('','pre','id','download-youtube-video-debug-info9',-1,false).innerHTML;
  1176. if (code) {
  1177. if (ytVideoID == code.match(/\"video_id\":\s*\"([^\"]+)\"/)[1]) {
  1178. ytVideosEncodedFmts=code.match(/\"url_encoded_fmt_stream_map\":\s*\"([^\"]+)\"/)[1].replace(/&amp;/g,'\\u0026');
  1179. if (ytVideosEncodedFmts == 'undefined') ytVideosEncodedFmts = null;
  1180. if (ytVideosEncodedFmts) ytVideosEncodedFmts = cleanMyContent(ytVideosEncodedFmts, false);
  1181. ytVideosAdaptiveFmts=code.match(/\"adaptive_fmts\":\s*\"([^\"]+)\"/)[1].replace(/&amp;/g,'\\u0026');
  1182. if (ytVideosAdaptiveFmts == 'undefined') ytVideosAdaptiveFmts = null;
  1183. if (ytVideosAdaptiveFmts) ytVideosAdaptiveFmts = cleanMyContent(ytVideosAdaptiveFmts, false);
  1184. ytVideosDashmpd=code.match(/\"dashmpd\":\s*\"([^\"]+)\"/)[1].replace(/&amp;/g,'\\u0026');
  1185. ytScriptURL=code.match(/\"js\":\s*\"([^\"]+)\"/)[1];
  1186. if (!ytScriptURL) ytScriptURL = getMyContent(page.url.replace(/watch.*?v=/, 'embed/').replace(/&.*$/, ''), '"js":\\s*"(.*?)"', true);
  1187. }
  1188. removeMyElement(injectedElement.parentNode, injectedElement);
  1189. }
  1190. }
  1191. else if (!ytVideosEncodedFmts && !ytVideosAdaptiveFmts) {
  1192. ytVideosEncodedFmts = getMyContent(page.url, '"url_encoded_fmt_stream_map":\\s*"(.*?)"', false);
  1193. if (ytVideosEncodedFmts) ytVideosEncodedFmts = cleanMyContent(ytVideosEncodedFmts, false);
  1194. ytVideosAdaptiveFmts = getMyContent(page.url, '"adaptive_fmts":\\s*"(.*?)"', false);
  1195. if (ytVideosAdaptiveFmts) ytVideosAdaptiveFmts = cleanMyContent(ytVideosAdaptiveFmts, false);
  1196. ytVideosDashmpd = getMyContent(page.url, '"dashmpd":\\s+"(.*?)"', false);
  1197. if (ytVideosDashmpd) ytVideosDashmpd = cleanMyContent(ytVideosDashmpd, false);
  1198. if (!ytVideosEncodedFmts && !ytVideosAdaptiveFmts) {
  1199. var ytVideoSts = getMyContent(page.url.replace(/watch.*?v=/, 'embed/').replace(/&.*$/, ''), '"sts"\\s*:\\s*(\\d+)', false);
  1200. var ytVideosInfoURL = 'https://www.youtube.com/get_video_info?video_id=' + ytVideoID + '&eurl=https://youtube.googleapis.com/v/' + ytVideoID + '&sts=' + ytVideoSts;
  1201. var ytVideosInfo = getMyContent(ytVideosInfoURL, 'TEXT', false);
  1202. if (ytVideosInfo) {
  1203. ytVideosEncodedFmts = ytVideosInfo.match(/url_encoded_fmt_stream_map=(.*?)&/);
  1204. ytVideosEncodedFmts = (ytVideosEncodedFmts) ? ytVideosEncodedFmts[1] : null;
  1205. if (ytVideosEncodedFmts) {
  1206. ytVideosEncodedFmts = cleanMyContent(ytVideosEncodedFmts, true);
  1207. ytVideosContent = ytVideosEncodedFmts;
  1208. }
  1209. if (!ytVideosAdaptiveFmts) {
  1210. ytVideosAdaptiveFmts = ytVideosInfo.match(/adaptive_fmts=(.*?)&/);
  1211. ytVideosAdaptiveFmts = (ytVideosAdaptiveFmts) ? ytVideosAdaptiveFmts[1] : null;
  1212. if (ytVideosAdaptiveFmts) ytVideosAdaptiveFmts = cleanMyContent(ytVideosAdaptiveFmts, true);
  1213. }
  1214. if (!ytVideosDashmpd) {
  1215. ytVideosDashmpd = ytVideosInfo.match(/dashmpd=(.*?)&/);
  1216. ytVideosDashmpd = (ytVideosDashmpd) ? ytVideosDashmpd[1] : null;
  1217. if (ytVideosDashmpd) ytVideosDashmpd = cleanMyContent(ytVideosDashmpd, true);
  1218. }
  1219. }
  1220. }
  1221. }
  1222. if (ytVideosEncodedFmts || ytVideosAdaptiveFmts) styleMyElement(ytVideoAvailable, {display: 'none'});
  1223. }
  1224. if (ytVideosEncodedFmts) {
  1225. ytVideosContent = ytVideosEncodedFmts;
  1226. }
  1227. if (ytVideosAdaptiveFmts) {
  1228. ytVideosAdaptiveFmts = ytVideosAdaptiveFmts.replace(/clen=\d+&/g, '');
  1229. ytVideosAdaptiveFmts = ytVideosAdaptiveFmts.replace(/lmt=\d+&/g, '');
  1230. if (ytVideosContent) ytVideosContent += ',' + ytVideosAdaptiveFmts;
  1231. else ytVideosContent = ytVideosAdaptiveFmts;
  1232. }
  1233.  
  1234. /* Get HLS Content */
  1235. if (!ytVideosContent) {
  1236. var ytHLSVideos, ytHLSContent;
  1237. ytHLSVideos = getMyContent(page.url, '"hlsvp":\\s*"(.*?)"', false);
  1238. if (ytHLSVideos) ytHLSVideos = cleanMyContent(ytHLSVideos, false);
  1239. }
  1240. function getYoutubeVideos(ytVideosContent, yturl) {
  1241. if (yturl != page.url) return;
  1242.  
  1243. /* Parse HLS */
  1244. function ytHLS(ytHLSVideos) {
  1245. var ytHLSFormats = {
  1246. '92': 'Very Low Definition MP4',
  1247. '93': 'Low Definition MP4',
  1248. '94': 'Standard Definition MP4',
  1249. '95': 'High Definition MP4'
  1250. };
  1251. ytVideoList["Any Definition MP4"] = ytHLSVideos;
  1252. if (ytHLSContent) {
  1253. var ytHLSMatcher = new RegExp('(http.*?m3u8)', 'g');
  1254. ytHLSVideos = ytHLSContent.match(ytHLSMatcher);
  1255. var ytHLSVideo, ytVideoCodeParse, ytVideoCode, myVideoCode;
  1256. if (ytHLSVideos) {
  1257. for (var i = 0; i < ytHLSVideos.length; i++) {
  1258. ytHLSVideo = ytHLSVideos[i];
  1259. ytVideoCodeParse = ytHLSVideo.match(/\/itag\/(\d{1,3})\//);
  1260. ytVideoCode = (ytVideoCodeParse) ? ytVideoCodeParse[1] : null;
  1261. if (ytVideoCode) {
  1262. myVideoCode = ytHLSFormats[ytVideoCode];
  1263. if (myVideoCode && ytHLSVideo) {
  1264. ytVideoList[myVideoCode] = ytHLSVideo;
  1265. }
  1266. }
  1267. }
  1268. }
  1269. }
  1270. ytVideoTitle = null;
  1271. ytPlayer (yturl);
  1272. }
  1273.  
  1274. function ytPlayer (yturl) {
  1275. if (yturl != page.url) return;
  1276. window.removeEventListener('resize', ytPlayerResize, false);
  1277.  
  1278. /* Create Player */
  1279. var ytDefaultVideo = 'Low Definition MP4';
  1280. var player = {
  1281. 'playerSocket': ytPlayerWindow,
  1282. 'playerWindow': myPlayerWindow,
  1283. 'videoList': ytVideoList,
  1284. 'videoPlay': ytDefaultVideo,
  1285. 'videoThumb': ytVideoThumb,
  1286. 'videoDuration': ytVideoDuration,
  1287. 'playerWidth': ytPlayerWidth,
  1288. 'playerHeight': ytPlayerHeight,
  1289. 'playerWideWidth': ytPlayerWideWidth,
  1290. 'playerWideHeight': ytPlayerWideHeight,
  1291. 'sidebarWindow': ytSidebarWindow,
  1292. 'sidebarMarginNormal': ytSidebarMarginNormal,
  1293. 'sidebarMarginWide': ytSidebarMarginWide
  1294. };
  1295.  
  1296. ytPlayerResize = function () {
  1297. ytSizes();
  1298. var ytWatchAppBar = getMyElement ('', 'div', 'id', 'watch-appbar-playlist', -1, false);
  1299. if (ytWatchAppBar) styleMyElement (ytWatchAppBar, {height: + ytPlayerHeight + 'px'});
  1300. player['playerWidth'] = ytPlayerWidth;
  1301. player['playerHeight'] = ytPlayerHeight;
  1302. player['playerWideWidth'] = ytPlayerWideWidth;
  1303. player['playerWideHeight'] = ytPlayerWideHeight;
  1304. player['sidebarMarginWide'] = ytSidebarMarginWide;
  1305. resizeMyPlayer(player, 'widesize');
  1306. }
  1307.  
  1308. option['definitions'] = ['Ultra High Definition', 'Full High Definition', 'High Definition', 'Standard Definition', 'Low Definition', 'Very Low Definition'];
  1309. option['containers'] = ['MP4', 'WebM', 'FLV', '3GP', 'Any'];
  1310. createMyPlayer (player);
  1311.  
  1312. /* Update Sizes */
  1313. window.addEventListener('resize', ytPlayerResize,false);
  1314. }
  1315.  
  1316. /* Get Sizes */
  1317. ytSizes();
  1318.  
  1319. /* Hide Player Window */
  1320. var ytPlaceholderPlayer = getMyElement ('', 'div', 'id', 'placeholder-player', -1, false);
  1321. if (ytPlaceholderPlayer) styleMyElement (ytPlaceholderPlayer, {display: 'none'});
  1322.  
  1323. /* Hide Sidebar Ads */
  1324. var ytSidebarAds = getMyElement ('', 'div', 'id', 'watch7-sidebar-ads', -1, false);
  1325. if (ytSidebarAds) styleMyElement (ytSidebarAds, {display: 'none'});
  1326.  
  1327. /* Playlist */
  1328. var ytWatchAppBar = getMyElement ('', 'div', 'id', 'watch-appbar-playlist', -1, false);
  1329. if (ytWatchAppBar) styleMyElement (ytWatchAppBar, {height: + ytPlayerHeight + 'px'});
  1330.  
  1331. /* My Player Window */
  1332. myPlayerWindow = createMyElement ('div', '', '', '', '');
  1333. myPlayerWindow.id = 'MyytWindow';
  1334. styleMyElement (ytPlayerWindow, {top: '0px'});
  1335. styleMyElement (myPlayerWindow, {position: 'relative', width: ytPlayerWidth + 'px', height: ytPlayerHeight +'px', backgroundColor: ytPlayerBgColor, zIndex: '99999'});
  1336. appendMyElement(ytPlayerWindow, myPlayerWindow);
  1337. blockObject = ytPlayerWindow;
  1338. blockInterval = 20;
  1339.  
  1340. /* Get Videos */
  1341. var ytVideoAvailable = getMyElement ('', 'div', 'id', 'player-unavailable', -1, false);
  1342. if (ytVideosContent) {
  1343. var ytVideoList = {};
  1344. var ytVideoFound = false;
  1345. var veVideoFound = false;
  1346. if (ytVideosContent.match(/VevoImages/)) {
  1347. var veVideoFormats = {
  1348. 'High': 'Standard Definition MP4'
  1349. ,'Med': 'Low Definition MP4'
  1350. ,'Low': 'Ultra Low Definition MP4'
  1351. ,'HTTP Live Streaming': 'HTTP Live Streaming'
  1352. ,'564000': 'Very Low Definition MP4'
  1353. ,'864000': 'Low Definition MP4'
  1354. ,'1328000':'Standard Definition MP4'
  1355. ,'1728000':'Standard Definition HBR MP4'
  1356. ,'2528000':'High Definition MP4'
  1357. ,'3328000':'High Definition HBR MP4'
  1358. ,'4328000':'Full High Definition MP4'
  1359. ,'4392000':'Full High Definition MP4'
  1360. ,'5328000':'Full High Definition HBR MP4'
  1361. ,'5392000':'Full High Definition HBR MP4'
  1362. }
  1363. var veVideosJSON = JSON.parse(ytVideosContent);
  1364. if (veVideosJSON) {
  1365. if (ytVideoAvailable) styleMyElement (ytVideoAvailable, {display: 'none'});
  1366. var veVideo, veVideoVersion;
  1367. for (var i = 0; i < veVideosJSON.video.videoVersions.length - 1; i++) {
  1368. if (veVideosJSON.video.videoVersions[i].sourceType == 2) {
  1369. if (veVideosJSON.video.videoVersions[i].version in {3:1,4:1}) {
  1370. for (var veVideoFormat in veVideoFormats) {
  1371. veVideo = veVideosJSON.video.videoVersions[i].data.match('rendition name="' + veVideoFormat + '" url="(.*?)"');
  1372. if (veVideo) {
  1373. ytVideoFound = true;
  1374. veVideoFound = true;
  1375. ytVideoList[veVideoFormats[veVideoFormat]] = veVideo[1];
  1376. }
  1377. }
  1378. }
  1379. }
  1380. if (veVideoFound) break;
  1381. }
  1382. veVideoFound = false;
  1383. for (var i = 0; i < veVideosJSON.video.videoVersions.length - 1; i++) {
  1384. if (veVideosJSON.video.videoVersions[i].sourceType == 3) {
  1385. for (var veVideoFormat in veVideoFormats) {
  1386. veVideo = veVideosJSON.video.videoVersions[i].data.match('rendition name="' + veVideoFormat + '" url="(.*?)"');
  1387. if (veVideo) {
  1388. ytVideoFound = true;
  1389. veVideoFound = true;
  1390. ytVideoList[veVideoFormats[veVideoFormat] + ' MP4'] = veVideo[1];
  1391. }
  1392. }
  1393. }
  1394. if (veVideoFound) break;
  1395. }
  1396. veVideoFound = false;
  1397. for (var i = 0; i < veVideosJSON.video.videoVersions.length - 1; i++) {
  1398. if (veVideosJSON.video.videoVersions[i].sourceType == 4) {
  1399. for (var veVideoFormat in veVideoFormats) {
  1400. veVideo = veVideosJSON.video.videoVersions[i].data.match('rendition name="' + veVideoFormat + '" url="(.*?)"');
  1401. if (veVideo) {
  1402. ytVideoFound = true;
  1403. veVideoFound = true;
  1404. ytVideoList[veVideoFormats[veVideoFormat] + ' MP4'] = veVideo[1];
  1405. }
  1406. }
  1407. }
  1408. if (veVideoFound) break;
  1409. }
  1410. veVideoFound = false;
  1411. for (var i = 0; i < veVideosJSON.video.videoVersions.length - 1; i++) {
  1412. if (veVideosJSON.video.videoVersions[i].url && veVideosJSON.video.videoVersions[i].url.match('//h264-((lvl3)|(aws)).vevo.com/')) {
  1413. for (var veVideoFormat in veVideoFormats) {
  1414. if (veVideosJSON.video.videoVersions[i].quality == veVideoFormat) {
  1415. ytVideoFound = true;
  1416. veVideoFound = true;
  1417. ytVideoList[veVideoFormats[veVideoFormat]] = veVideosJSON.video.videoVersions[i].url;
  1418. }
  1419. }
  1420. }
  1421. }
  1422. veVideoFound = false;
  1423. for (var i = 0; i < veVideosJSON.video.videoVersions.length - 1; i++) {
  1424. if (veVideosJSON.video.videoVersions[i].url && veVideosJSON.video.videoVersions[i].url.match('//hls-((lvl3)|(aws)|(aka)).vevo.com/')) {
  1425. ytVideoFound = true;
  1426. veVideoFound = true;
  1427. ytVideoList[veVideoFormats['HTTP Live Streaming']] = veVideosJSON.video.videoVersions[i].url;
  1428. }
  1429. }
  1430. veVideoFound = false;
  1431. for (var i = 0; i < veVideosJSON.video.videoVersions.length - 1; i++) {
  1432. if (veVideosJSON.video.videoVersions[i].sourceType == 5 && veVideosJSON.video.videoVersions[i].version == 1) {
  1433. veVideo = veVideosJSON.video.videoVersions[i].data.match('rendition name="HTTP\\s?Level3" url="(.*?)"');
  1434. if (veVideo) veVideoFound = true;
  1435. }
  1436. else if (veVideosJSON.video.videoVersions[i].url && veVideosJSON.video.videoVersions[i].url.match('//smil-((lvl3)|(aws)|(aka)).vevo.com/')) {
  1437. veVideo = veVideosJSON.video.videoVersions[i].url
  1438. if (veVideo) veVideoFound = true;
  1439. }
  1440. if (veVideoFound) break;
  1441. }
  1442. if (veVideoFound) getMyContentGM(veVideo[1],'TEXT',false, function (vesmilfile) {
  1443. var veurl = yturl;
  1444. for (veVideoFormat in veVideoFormats) {
  1445. if (vesmilfile.match(veVideoFormat)) {
  1446. ytVideoList[veVideoFormats[veVideoFormat]] = "http://smil.lvl3.vevo.com" + vesmilfile.match('video src="mp4:(.*?)" system-bitrate="' + veVideoFormat + '"')[1];
  1447. }
  1448. }
  1449. ytPlayer(veurl);
  1450. });
  1451. if (!veVideoFound) if (ytVideoFound) ytPlayer(yturl); else showMyMessage ('!videos');
  1452. }
  1453. } else {
  1454. var ytVideoFormats = {
  1455. '5': 'Very Low Definition FLV',
  1456. '17': 'Very Low Definition 3GP',
  1457. '18': 'Low Definition MP4',
  1458. '22': 'High Definition MP4',
  1459. '34': 'Low Definition FLV',
  1460. '35': 'Standard Definition FLV',
  1461. '36': 'Low Definition 3GP',
  1462. '37': 'Full High Definition MP4',
  1463. '38': 'Ultra High Definition MP4',
  1464. '43': 'Low Definition WebM',
  1465. '44': 'Standard Definition WebM',
  1466. '45': 'High Definition WebM',
  1467. '46': 'Full High Definition WebM',
  1468. '82': 'Low Definition 3D MP4',
  1469. '83': 'Standard Definition 3D MP4',
  1470. '84': 'High Definition 3D MP4',
  1471. '85': 'Full High Definition 3D MP4',
  1472. '100': 'Low Definition 3D WebM',
  1473. '101': 'Standard Definition 3D WebM',
  1474. '102': 'High Definition 3D WebM',
  1475. '135': 'Standard Definition Video MP4',
  1476. '136': 'High Definition Video MP4',
  1477. '137': 'Full High Definition Video MP4',
  1478. '138': 'Ultra High Definition Video MP4',
  1479. '139': 'Low Bitrate Audio MP4',
  1480. '140': 'Medium Bitrate Audio MP4',
  1481. '141': 'High Bitrate Audio MP4',
  1482. '171': 'Medium Bitrate Audio WebM',
  1483. '172': 'High Bitrate Audio WebM',
  1484. '244': 'Standard Definition Video WebM',
  1485. '247': 'High Definition Video WebM',
  1486. '248': 'Full High Definition Video WebM',
  1487. '249': 'Low Bitrate Audio Opus',
  1488. '250': 'Medium Bitrate Audio Opus',
  1489. '251': 'High Bitrate Audio Opus',
  1490. '266': 'Ultra High Definition Video MP4',
  1491. '272': 'Ultra High Definition Video WebM',
  1492. '298': 'High Definition Video MP4',
  1493. '299': 'Full High Definition Video MP4',
  1494. '302': 'High Definition Video WebM',
  1495. '303': 'Full High Definition Video WebM',
  1496. '313': 'Ultra High Definition Video WebM'
  1497. };
  1498. var ytVideos = ytVideosContent.split(',');
  1499. var ytVideoParse, ytVideoCodeParse, ytVideoCode, myVideoCode, ytVideo;
  1500. for (var i = 0; i < ytVideos.length; i++) {
  1501. if (!ytVideos[i].match(/^url/)) {
  1502. ytVideoParse = ytVideos[i].match(/(.*)(url=.*$)/);
  1503. if (ytVideoParse) ytVideos[i] = ytVideoParse[2] + '&' + ytVideoParse[1];
  1504. }
  1505. ytVideoCodeParse = ytVideos[i].match (/itag=(\d{1,3})/);
  1506. ytVideoCode = (ytVideoCodeParse) ? ytVideoCodeParse[1] : null;
  1507. if (ytVideoCode) {
  1508. myVideoCode = ytVideoFormats[ytVideoCode];
  1509. if (myVideoCode) {
  1510. ytVideo = ytVideos[i].replace (/url=/, '').replace(/&$/, '').replace(/&itag=\d{1,3}/, '');
  1511. if (ytVideo.match(/type=(video|audio).*?&/)) ytVideo = ytVideo.replace(/type=(video|audio).*?&/, '');
  1512. else ytVideo = ytVideo.replace(/&type=(video|audio).*$/, '');
  1513. if (ytVideo.match(/&sig=/)) ytVideo = ytVideo.replace (/&sig=/, '&signature=');
  1514. else if (ytVideo.match(/&s=/)) {
  1515. var ytSig = ytVideo.match(/&s=(.*?)(&|$)/);
  1516. if (ytSig) {
  1517. var s = decryptSignature(ytSig[1]);
  1518. ytVideo = ytVideo.replace(/&s=.*?(&|$)/, '&signature=' + s + '$1');
  1519. }
  1520. else ytVideo = '';
  1521. }
  1522. ytVideo = cleanMyContent (ytVideo, true);
  1523. if (ytVideo && ytVideo.indexOf('http') == 0) {
  1524. if (!ytVideoFound) ytVideoFound = true;
  1525. ytVideoList[myVideoCode] = ytVideo;
  1526. }
  1527. }
  1528. }
  1529. }
  1530. if (ytVideosDashmpd) {
  1531. if (ytVideosDashmpd.match(/\/signature\//)) ytVideoList['DASH MP4'] = ytVideosDashmpd;
  1532. else if (ytVideosDashmpd.match(/\/s\//)) {
  1533. var ytSig = ytVideosDashmpd.match(/\/s\/(.*?)\//);
  1534. if (ytSig) {
  1535. var s = decryptSignature(ytSig[1]);
  1536. ytVideoList['DASH MP4'] = ytVideosDashmpd.replace(/\/s\/.*?(\/.*$)/, '\/signature\/' + s + '$1');
  1537. }
  1538. }
  1539. }
  1540. if (ytVideoFound) {
  1541. ytPlayer(yturl);
  1542. }
  1543. else {
  1544. if (ytVideosContent.indexOf('conn=rtmp') != -1) showMyMessage ('!support');
  1545. else showMyMessage ('!videos');
  1546. } /* End Create Player */
  1547. }
  1548. }
  1549. else {
  1550. if (ytHLSVideos) {
  1551. ytHLSContent = getMyContent(ytHLSVideos, 'TEXT', false);
  1552. ytHLS(ytHLSVideos);
  1553. }
  1554. else {
  1555. if (ytVideoAvailable && ytVideoAvailable.className.indexOf('hid') == -1) removeMyElement(ytPlayerWindow, myPlayerWindow)
  1556. else showMyMessage ('!content');
  1557. }
  1558. }
  1559. }
  1560. /* Get Script URL */
  1561. if (!ytScriptURL) ytScriptURL = getMyContent(page.url, '"js":\\s*"(.*?)"', true);
  1562. if (!ytScriptURL) ytScriptURL = getMyContent(page.url.replace(/watch.*?v=/, 'embed/').replace(/&.*$/, ''), '"js":\\s*"(.*?)"', true);
  1563. ytScriptURL = page.win.location.protocol + ytScriptURL;
  1564. //+ unescape(escape(ytScriptURL).replace(/%5C/g, ''));
  1565. var DECODEARRDAT = 'decodeArrayData';
  1566. decodeArray = getMyOption(DECODEARRDAT);
  1567. if (decodeArray) decodeArray = decodeArray.split(',');
  1568. if (!ytVideosContent) {
  1569. // try getting the video from VEVO directly if content is blocked due to geolocation filtering
  1570. var searchitem = ytVideoTitle.replace(/\ -\ .*/g,'/').replace(/\ |\./g,'-').replace(/--/g,'-').replace(/-$/,'').replace(/\'|\)|\(|\[|\]/g,'').toLowerCase();
  1571. searchitem = searchitem.replace(/é|è|ê|ë/g,'e').replace(/á|à|â|ä|å|æ/g,'a').replace(/ó|ò|ô|ö|ø/g,'o').replace(/í|ì|î|ï/g,'i').replace(/ú|ù|û|ü/g,'u').replace(/ç/g,'c').replace(/ý|ÿ/g,'y');
  1572. searchitem = searchitem + ytVideoTitle.replace(/.*?\ -\ /,'').replace(/\ |\./g,'-').replace(/--/g,'').replace(/-$/,'').replace(/\'|,|:|\)|\(|\[|\]/g,'').toLowerCase();
  1573. if (ytVideoTitle.indexOf('\ -\ ') !=-1) {
  1574. searchstring = ytVideoTitle.replace(/\ -\ .*/g,' ').replace(/\ official\ ((music)|(video)).*|(\ ft.*)|$/i,'') + ytVideoTitle.replace(/.*?\ -\ /,'').replace(/\ official\ ((music)|(video)).*|(\ ft.*)|$/i,'');
  1575. }
  1576. else {
  1577. searchstring = ytVideoTitle.replace(/\ official\ ((music)|(video)).*|(\ ft.*)|$/i,'');
  1578. }
  1579. var xmlHTTP = new XMLHttpRequest();
  1580. xmlHTTP.open('POST', 'https://www.vevo.com/auth', false);
  1581. xmlHTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  1582. xmlHTTP.send();
  1583. var vevotoken = xmlHTTP.responseText.match(/"refresh_token":"(.*?)"/);
  1584. var vevosearch = "https://apiv2.vevo.com/search?max=10&q=" + escape(searchstring.replace(/\'|\)|\(|\[|\]/g,'').replace(/\ /g,'+')) + "&token=" + vevotoken[1];
  1585. getMyContentGM(vevosearch, 'TEXT', false, function(textVevo) {
  1586. var docurl = page.url;
  1587. var vevoJson1 = JSON.parse(textVevo);
  1588. var vevomatch = false;
  1589.  
  1590. function findVevoItem (vevoJson) {
  1591. if ((vevoJson.success === true && vevoJson.total > 0) || (vevoJson.videos && vevoJson.videos.length > 0)) {
  1592. var veVideoID, vevoDuration, vevotitle, artistsMain, artistsFeatured;
  1593. var searchitem = '';
  1594. var searchartist = '';
  1595. if (ytVideoTitle.indexOf('\ -\ ') !=-1) {
  1596. searchartist = ytVideoTitle.replace(/\ -\ .*/g,'').replace(/\ /g,'-').replace(/--/g,'-').replace(/-$/,'').replace(/\.|\'|\)|\(|\[|\]/g,'').toLowerCase();
  1597. // searchartist = searchartist.replace(/é|è|ê|ë/g,'e').replace(/á|à|â|ä|å|æ/g,'a').replace(/ó|ò|ô|ö|ø/g,'o').replace(/í|ì|î|ï/g,'i').replace(/ú|ù|û|ü/g,'u').replace(/ç/g,'c').replace(/ý|ÿ/g,'y');
  1598. searchitem = '/' + searchartist;
  1599. }
  1600. var searchtitle = ytVideoTitle.replace(/.*?\ -\ /,'').replace(/\ /g,'-').replace(/--/g,'').replace(/-$/,'').replace(/\.|\'|,|:|\)|\(|\[|\]/g,'').toLowerCase();
  1601. if (!vevoJson.result) vevoJson.result = vevoJson.videos;
  1602. for (var i = 0; i < vevoJson.result.length; i++) {
  1603. artistsMain = '';
  1604. artistsFeatured = '';
  1605. veVideoID = vevoJson.result[i].isrc;
  1606. vevotitle = vevoJson.result[i].title.substring(0, 87).replace(/’/g,'\'').replace(/"/g, '\'').trim();
  1607. if (vevoJson.result[i].artists_main) {
  1608. for (var j = 0; j < vevoJson.result[i].artists_main.length; j++) {
  1609. if (artistsMain.length > 0 ) artistsMain += ', ';
  1610. artistsMain += vevoJson.result[i].artists_main[j].name;
  1611. artistsMain = artistsMain.replace(/,?Vevo/,'');
  1612. }
  1613. }
  1614. if (vevoJson.result[i].primaryArtists) {
  1615. for (var j = 0; j < vevoJson.result[i].primaryArtists.length; j++) {
  1616. if (artistsMain.length > 0 ) artistsMain += ', ';
  1617. artistsMain += vevoJson.result[i].primaryArtists[j].name;
  1618. artistsMain = artistsMain.replace(/,?Vevo/,'');
  1619. }
  1620. }
  1621. if (vevoJson.result[i].artists_featured) {
  1622. for (var j = 0; j < vevoJson.result[i].artists_featured.length; j++) {
  1623. if (artistsFeatured.length > 0 ) artistsFeatured += ', ';
  1624. artistsFeatured += vevoJson.result[i].artists_featured[j].name;
  1625. }
  1626. }
  1627. if (vevoJson.result[i].featuredArtists) {
  1628. for (var j = 0; j < vevoJson.result[i].featuredArtists.length; j++) {
  1629. if (artistsFeatured.length > 0 ) artistsFeatured += ', ';
  1630. artistsFeatured += vevoJson.result[i].featuredArtists[j].name;
  1631. }
  1632. }
  1633. if (artistsMain.length > 0) searchitem = artistsMain + " - " + vevotitle;
  1634. else searchitem = vevotitle;
  1635. if (artistsFeatured.length > 0) searchitem = searchitem + " ft. " + artistsFeatured;
  1636. searchitem = searchitem.replace(/’/g,'\'').replace(/"/g, '\'');
  1637. if ((artistsMain + " - " + vevotitle) == ytVideoTitle || vevotitle == ytVideoTitle || searchitem == ytVideoTitle) {
  1638. vevomatch = true;
  1639. break;
  1640. }
  1641. }
  1642. if (!vevomatch) for (var i = 0; i < vevoJson.result.length; i++) {
  1643. veVideoID = vevoJson.result[i].isrc;
  1644. if (vevoJson.result[i].duration_in_seconds && (ytVideoDuration == (vevoJson.result[i].duration_in_seconds) || ytVideoDuration == (vevoJson.result[i].duration_in_seconds + 1))) {
  1645. vevomatch = true;
  1646. break;
  1647. }
  1648. }
  1649. if (vevomatch && veVideoID) {
  1650. var veVideoURL = 'http://videoplayer.vevo.com/VideoService/AuthenticateVideo?isrc=' + veVideoID;
  1651. getMyContentGM(veVideoURL,'TEXT',false,function (text){
  1652. ytVideosContent = JSON.parse(text);
  1653. if (ytVideosContent.statusCode == '909') {
  1654. veVideoURL = "https://apiv2.vevo.com/video/" + veVideoID + "?token=" + vevotoken[1];
  1655. getMyContentGM(veVideoURL,'TEXT',false,function (text){
  1656. ytVideosContent = JSON.parse(text);
  1657. var veStreamURL = "https://apiv2.vevo.com/video/" + veVideoID + "/streams?token=" + vevotoken[1];
  1658. ytVideosContent.video = {Object};
  1659. ytVideosContent.video.videoVersions = JSON.parse(getMyContent(veStreamURL,'TEXT',false));
  1660. ytVideosContent = JSON.stringify(ytVideosContent);
  1661. getYoutubeVideos(ytVideosContent, docurl);
  1662. });
  1663. } else {
  1664. if (ytVideosContent.statusCode == '0') getYoutubeVideos(text, docurl);
  1665. }
  1666. });
  1667. } else {
  1668. ytVideosContent = null;
  1669. }
  1670. }
  1671. }
  1672. if (vevoJson1) findVevoItem (vevoJson1);
  1673. if (!vevomatch) { // if not found, try mobile api
  1674. var vevosearch = "http://api.vevo.com/mobile/v1/search/videos.json?max=10&q=" + escape(searchstring.replace(/\'|\)|\(|\[|\]/g,'').replace(/\ /g,'+'));
  1675. getMyContentGM(vevosearch,'TEXT', false, function(textVevo) {
  1676. var vevoJson2 = JSON.parse(textVevo);
  1677. if (vevoJson2) findVevoItem (vevoJson2);
  1678. });
  1679. }
  1680. });
  1681. }
  1682. else if (ytScriptURL && ytVideosContent && ytVideosContent.match(/&s=/) && (!decodeArray || decodeArray.length==0)) {
  1683. try {
  1684. crossXmlHttpRequest({
  1685. method:'GET',
  1686. url:ytScriptURL,
  1687. onload:function(response) {
  1688. if (response.readyState === 4 && response.status === 200 && response.responseText) {
  1689. decodeArray = findSignatureCode(response.responseText);
  1690. setMyOptions(DECODEARRDAT, decodeArray.toString());
  1691. getYoutubeVideos(ytVideosContent, page.url);
  1692. }
  1693. else {
  1694. showMyMessage('other', 'Couldn\'t get the signature content. Please report it <a href="' + contact + '" style="color:#00892C">here</a>.');
  1695. }
  1696. },
  1697. onerror: function() {
  1698. showMyMessage('other', 'Couldn\'t make the request. Make sure your browser user scripts extension supports cross-domain requests.');
  1699. }
  1700. });
  1701. } catch(e) { }
  1702. } else {
  1703. getYoutubeVideos(ytVideosContent, page.url);
  1704. try {
  1705. crossXmlHttpRequest({
  1706. method:'GET',
  1707. url:ytScriptURL,
  1708. onload:function(response) {
  1709. if (response.readyState === 4 && response.status === 200 && response.responseText) {
  1710. var retArray = findSignatureCode(response.responseText);
  1711. if (retArray && (retArray.toString() != decodeArray.toString()) && ytVideosContent.match(/&s=/)) {
  1712. decodeArray = retArray;
  1713. setMyOptions(DECODEARRDAT, decodeArray.toString());
  1714. myPlayerWindow = getMyElement ('', 'div', 'id', 'MyytWindow', -1, false);
  1715. if (myPlayerWindow) removeMyElement(myPlayerWindow.parentNode,myPlayerWindow);
  1716. getYoutubeVideos(ytVideosContent, page.url);
  1717. }
  1718. }
  1719. }
  1720. });
  1721. } catch(e) { }
  1722. }
  1723. }
  1724. }
  1725.  
  1726. function onNodeInserted(e) {
  1727. if (page.url != window.location.href) {
  1728. myPlayerWindow = getMyElement ('', 'div', 'id', 'MyytWindow', -1, false);
  1729. if (myPlayerWindow) removeMyElement(myPlayerWindow.parentNode,myPlayerWindow);
  1730. }
  1731. if (e && e.target && e.target.id=='watch7-main-container') {
  1732. setTimeout(function() { yt_run("NodeInserted"); }, 0);
  1733. }
  1734. }
  1735. if (page.url.indexOf('youtube.com/watch\?v=') != -1) yt_run();
  1736. var content=document.getElementById('content');
  1737. if (content) {
  1738. var mo=window.MutationObserver||window.MozMutationObserver||window.WebKitMutationObserver;
  1739. if(typeof mo!=='undefined') {
  1740. var observer=new mo(function(mutations) {
  1741. mutations.forEach(function(mutation) {
  1742. if(mutation.addedNodes!==null) {
  1743. for (var i=0; i<mutation.addedNodes.length; i++) {
  1744. if (mutation.addedNodes[i].id=='watch7-main-container') {
  1745. yt_run("Mutation");
  1746. break;
  1747. }
  1748. }
  1749. }
  1750. });
  1751. if (page.url != window.location.href) {
  1752. myPlayerWindow = getMyElement ('', 'div', 'id', 'MyytWindow', -1, false);
  1753. if (myPlayerWindow) removeMyElement(myPlayerWindow.parentNode,myPlayerWindow);
  1754. }
  1755. });
  1756. observer.observe(content, {childList: true, subtree: true});
  1757. } else { // MutationObserver fallback for old browsers
  1758. if (document.implementation.hasFeature('MutationEvents','2.0')) {
  1759. pagecontainer.addEventListener('DOMNodeInserted', onNodeInserted, false);
  1760. } else {
  1761. page.win.setInterval(function() {
  1762. nurl = window.location.href;
  1763. if (page.url != nurl) window.location.href = nurl;
  1764. }, 500)
  1765. }
  1766. }
  1767. }
  1768. }
  1769.  
  1770. // =====DailyMotion===== //
  1771.  
  1772. else if (page.url.indexOf('dailymotion.com/video') != -1 || page.url.indexOf('dailymotion.com/playlist') != -1) {
  1773.  
  1774. /* Redirect Playlist To Video */
  1775. if (page.url.indexOf('dailymotion.com/playlist') != -1 && page.url.indexOf('#video=') != -1) {
  1776. page.win.location.href = page.url.replace(/playlist.*#/, '').replace("=", "/");
  1777. }
  1778.  
  1779. /* Get Player Window */
  1780. var dmPlayerWindow = getMyElement ('', 'div', 'class', 'player-container', 0, false);
  1781. if (!dmPlayerWindow) {
  1782. showMyMessage ('!player');
  1783. }
  1784. else {
  1785. /* Get Video Thumbnail */
  1786. var dmVideoThumb = getMyContent (page.url, 'meta\\s+property="og:image"\\s+content="(.*?)"', false);
  1787. var dmVideoDuration = getMyContent (page.url, 'meta\\s+property="video:duration"\\s+content="(.*?)"', false);
  1788. if (dmVideoDuration) dmVideoDuration = parseInt(dmVideoDuration);
  1789.  
  1790. /* Get Videos Content */
  1791. var dmEmbed;
  1792. if (page.url.indexOf('dailymotion.com/video') != -1) dmEmbed = page.url.replace(/\/video\//, "/embed/video/");
  1793. else {
  1794. var dmVideoID = getMyContent(page.url,'data-playable="(.*?)"',false)
  1795. dmEmbed = page.url.replace(/playlist.*=/, "embed/video/");
  1796. if (dmEmbed.indexOf("embed/video/") == -1) dmEmbed = page.url.replace(/playlist.*$/, "embed/video/"+dmVideoID);
  1797. }
  1798. dmVideosContent = getMyContent (dmEmbed, 'info\\s+=\\s+\\{(.*)\\}', false);
  1799. if (!dmVideosContent) dmVideosContent = getMyContent (dmEmbed, '"qualities":\\{(.*?)\\]\\},', false);
  1800.  
  1801. /* Player Size */
  1802. var dmSidebarWidth = 320;
  1803. var dmSidebarWindow = getMyElement ('', 'div', 'class', 'sidebar', 0, false);
  1804. var dmSidebarWindowStyle = (dmSidebarWindow) ? dmSidebarWindow.currentStyle || window.getComputedStyle(dmSidebarWindow) : null;
  1805. var dmPlayerWidth, dmPlayerHeight;
  1806. var dmPlayerWideWidth, dmPlayerWideHeight;
  1807. var dmSidebarMarginWide;
  1808. function dmGetSizes() {
  1809. dmPlayerWidth = dmPlayerWindow.clientWidth;
  1810. dmPlayerHeight = Math.ceil(dmPlayerWidth / (16 / 9)) + 22;
  1811. if (dmSidebarWindow && dmSidebarWindowStyle) dmSidebarWidth = parseInt(dmSidebarWindowStyle.width);
  1812. dmPlayerWideWidth = dmPlayerWidth + dmSidebarWidth;
  1813. dmPlayerWideHeight = Math.ceil(dmPlayerWideWidth / (16 / 9)) + 22;
  1814. dmSidebarMarginWide = dmPlayerWideHeight + 30
  1815. }
  1816. function dmUpdateSizes() {
  1817. setTimeout(function() {
  1818. dmGetSizes();
  1819. player['playerWidth'] = dmPlayerWidth;
  1820. player['playerHeight'] = dmPlayerHeight;
  1821. player['playerWideWidth'] = dmPlayerWideWidth;
  1822. player['playerWideHeight'] = dmPlayerWideHeight;
  1823. player['sidebarMarginWide'] = dmSidebarMarginWide;
  1824. resizeMyPlayer(player, 'widesize');
  1825. styleMyElement (dmPlayerWindow, {overflow: 'visible', height: '100%'});
  1826. },350);
  1827. }
  1828. dmGetSizes();
  1829.  
  1830. /* My Player Window */
  1831. var myPlayerWindow = createMyElement ('div', '', '', '', '');
  1832. styleMyElement (myPlayerWindow, {position: 'relative',width: dmPlayerWidth + 'px', height: dmPlayerHeight + 'px', backgroundColor: '#F4F4F4', zIndex: '99999'});
  1833. modifyMyElement (dmPlayerWindow, 'div', '', false, true);
  1834. appendMyElement (dmPlayerWindow, myPlayerWindow);
  1835. blockObject = dmPlayerWindow;
  1836.  
  1837. /* Fix Visibility & Height */
  1838. var dmPlayerJSBox = getMyElement ('', 'div', 'class', 'js-player-box', 0, false);
  1839. if (dmPlayerJSBox) styleMyElement(dmPlayerJSBox, {overflow: 'visible', height: '100%', backgroundColor: '#F4F4F4'});
  1840. else styleMyElement(dmPlayerWindow.parentNode, {overflow: 'visible', height: '100%', backgroundColor: '#F4F4F4'});
  1841. page.win.setTimeout(function() {styleMyElement (dmPlayerWindow, {overflow: 'visible', height: '100%'});}, 2000);
  1842.  
  1843. /* Fix Right Ad Issue */
  1844. var dmMcRight = getMyElement ('', 'div', 'id', 'mc_Right', -1, false);
  1845. if (dmMcRight) {
  1846. var dmWaitForAdTime = 20;
  1847. var dmPlayerWidthPrev = dmPlayerWidth;
  1848. var dmWaitForAdFunc = page.win.setInterval(function() {
  1849. if(dmMcRight.clientWidth) {
  1850. dmUpdateSizes();
  1851. if (dmPlayerWidth != dmPlayerWidthPrev) clearInterval(dmWaitForAdFunc);
  1852. }
  1853. dmWaitForAdTime--;
  1854. if (dmWaitForAdTime == 0) clearInterval(dmWaitForAdFunc);
  1855. }, 250);
  1856. }
  1857.  
  1858. /* Resize Event */
  1859. page.win.addEventListener('resize', dmUpdateSizes, false);
  1860.  
  1861. /* Hide Top Ads */
  1862. var dmMcTop = getMyElement ('', 'div', 'id', 'mc_Top', -1, false);
  1863. if (dmMcTop) styleMyElement(dmMcTop, {display: 'none'});
  1864.  
  1865. /* Get Videos */
  1866. if (dmVideosContent) {
  1867. var dmVideoFormats = {'240': 'Very Low Definition MP4', '380': 'Low Definition MP4', '480': 'Standard Definition MP4',
  1868. '720': 'High Definition MP4', '1080': 'Full High Definition MP4', '.*?x-mpegURL': 'HTTP Live Streaming M3U8'};
  1869. var dmVideoList = {};
  1870. var dmVideoFound = false;
  1871. var dmVideoParser, dmVideoParse, myVideoCode, dmVideo;
  1872. for (var dmVideoCode in dmVideoFormats) {
  1873. dmVideoParser = '"' + dmVideoCode + '".*?"url":"(.*?)"';
  1874. dmVideoParse = dmVideosContent.match (dmVideoParser);
  1875. dmVideo = (dmVideoParse) ? dmVideoParse[1] : null;
  1876. if (dmVideo) {
  1877. if (!dmVideoFound) dmVideoFound = true;
  1878. dmVideo = cleanMyContent(dmVideo, true);
  1879. myVideoCode = dmVideoFormats[dmVideoCode];
  1880. if (!dmVideoList[myVideoCode]) dmVideoList[myVideoCode] = dmVideo;
  1881. }
  1882. }
  1883.  
  1884. if (dmVideoFound) {
  1885.  
  1886. /* Create Player */
  1887. var dmDefaultVideo = 'Low Definition MP4';
  1888. var player = {
  1889. 'playerSocket': dmPlayerWindow,
  1890. 'playerWindow': myPlayerWindow,
  1891. 'videoList': dmVideoList,
  1892. 'videoPlay': dmDefaultVideo,
  1893. 'videoThumb': dmVideoThumb,
  1894. 'videoDuration': dmVideoDuration,
  1895. 'playerWidth': dmPlayerWidth,
  1896. 'playerHeight': dmPlayerHeight,
  1897. 'playerWideWidth': dmPlayerWideWidth,
  1898. 'playerWideHeight': dmPlayerWideHeight,
  1899. 'sidebarWindow': dmSidebarWindow,
  1900. 'sidebarMarginNormal': 0,
  1901. 'sidebarMarginWide': dmSidebarMarginWide
  1902. };
  1903. feature['container'] = false;
  1904. option['definitions'] = ['Full High Definition', 'High Definition', 'Standard Definition', 'Low Definition', 'Very Low Definition'];
  1905. option['containers'] = ['MP4'];
  1906. createMyPlayer (player);
  1907.  
  1908. /* Fix panel */
  1909. styleMyElement(player['playerContent'], {marginTop: '7px'});
  1910.  
  1911. /* Fix Info Position On Widesize */
  1912. player['buttonWidesize'].addEventListener('click', function() {
  1913. styleMyElement (dmPlayerWindow.parentNode, {minHeight: player['contentHeight'] + 50 + 'px'});
  1914. }, false);
  1915. } else {
  1916. showMyMessage ('!videos');
  1917. }
  1918. } else {
  1919. showMyMessage ('!content');
  1920. }
  1921. }
  1922. }
  1923.  
  1924. // =====Vimeo===== //
  1925. else if (page.url.match(/https?:\/\/(www\.)?vimeo.com\//)) {
  1926.  
  1927. function vimeo_run(viPlayerId) {
  1928. if (viPlayerId && page.url == window.location.href) return;
  1929. page = {win: window, doc: document, body: document.body, url: window.location.href};
  1930.  
  1931. var PlayerHeight, PlayerWidth, viVideo, myVideoCode;
  1932. var viVideoID = null;
  1933. var viVideoSignature = null;
  1934. var viVideoTimestamp = null;
  1935. var viPlayerWindow = null;
  1936. var viVideoRegex;
  1937. var viVideoFormats = {'HLS': 'HTTP Live Streaming','1080p': 'Full High Definition MP4','720p': 'High Definition MP4', '360p': 'Low Definition MP4', '270p': 'Very Low Definition MP4'};
  1938.  
  1939. /* Video Type */
  1940. var viVideoPage = page.url.match(/vimeo.com\/\d+/) ? true : false;
  1941. /* Get Player Window */
  1942. for (i=0; i<getMyElement ('', 'div', 'class', 'player_container', -1, false).length; i++) {
  1943. var viPlayerWindow = getMyElement ('', 'div', 'class', 'player_container', i, false);
  1944. styleMyElement (viPlayerWindow.parentNode, {height: '100%', transformStyle: 'flat', transform: 'none'});
  1945. if (page.body.innerHTML.match(/open\("GET","(https?\:\/\/player.*?)"/)) PlayerHeight = viPlayerWindow.clientHeight;
  1946. else PlayerHeight = viPlayerWindow.clientHeight + 22;
  1947. PlayerWidth = viPlayerWindow.clientWidth;
  1948. var viScreenWidth = page.win.innerWidth || page.doc.documentElement.clientWidth;
  1949. var viPlayerLeft = Math.floor((viScreenWidth - PlayerWidth) / 2);
  1950. if (!viPlayerWindow) {
  1951. showMyMessage ('!player');
  1952. } else {
  1953. /* Get Videos Content */
  1954. viVideoRegex = 'data-fallback-url=".*?(\\d{6,10})\\/.*?"';
  1955. viVideoID = page.body.innerHTML.match(RegExp(viVideoRegex,'g'))[i];
  1956. if (viVideoID) viVideoID = viVideoID.match(RegExp(viVideoRegex))[1];
  1957. viVideoURL = page.win.location.protocol + "//vimeo.com/" + viVideoID;
  1958. getMyContentGM(viVideoURL,'TEXT',false, function (res1) {
  1959. var viVideoSource = res1.match(/open\("GET","(https?\:\/\/player.*?)"/);
  1960. if (viVideoSource) viVideoSource = viVideoSource[1];
  1961. else viVideoSource = res1.match('data-config-url="(.*?)"')[1].replace(/&amp;/g, '&');
  1962. getMyContentGM(viVideoSource,'TEXT',false, function (res2) {
  1963. /* Get Videos */
  1964. var viVideosContent = JSON.parse(res2);
  1965. var viVideoList = {};
  1966. var myVideoCode;
  1967. var viVideoFound = false;
  1968. if (viVideosContent) {
  1969. var viVideoID = viVideosContent.video.id;
  1970. var viVideoThumb = viVideosContent.video.thumbs['960'];
  1971. if (!viVideoThumb) viVideoThumb = viVideosContent.video.thumbs['1280'];
  1972. if (!viVideoThumb) viVideoThumb = viVideosContent.video.thumbs['640'];
  1973. var viVideoDuration = viVideosContent.video.duration;
  1974. } else {
  1975. showMyMessage ('!content');
  1976. }
  1977.  
  1978. /* My Player Window */
  1979. var viPlayerWindow = getMyElement ('', 'div', 'class', 'player_container', -1, false);
  1980. var viVideoRegex = 'data-fallback-url=".*?(\\d{6,10})\\/.*?"';
  1981. for (i=0;i<viPlayerWindow.length;i++) {
  1982. if (viPlayerWindow[i].innerHTML.match(viVideoRegex) && viPlayerWindow[i].innerHTML.match(viVideoRegex)[1] == viVideoID) {
  1983. viPlayerWindow = viPlayerWindow[i];
  1984. break;
  1985. }
  1986. }
  1987. var viPlayerElement = getMyElement (viPlayerWindow, 'div', 'class', 'player', 0, false);
  1988. cleanMyElement (viPlayerElement, true);
  1989. modifyMyElement (viPlayerElement, 'div', '', true);
  1990. myPlayerWindow = getMyElement (viPlayerWindow, 'div', 'class', 'MyviWindow', 0, false);
  1991. if (myPlayerWindow) removeMyElement(myPlayerWindow.parentNode,myPlayerWindow);
  1992. myPlayerWindow = createMyElement ('div', '', '', '', '');
  1993. myPlayerWindow.className = 'MyviWindow';
  1994. styleMyElement (myPlayerWindow, {position: 'relative', width: PlayerWidth + 'px', height: PlayerHeight + 'px', backgroundColor: '#F4F4F4', zIndex: '99999'});
  1995.  
  1996. // if (viVideoPage) {
  1997. modifyMyElement (viPlayerWindow, 'div', '', false, true);
  1998. styleMyElement (viPlayerWindow, {height: '100%', left: viPlayerLeft + 'px', transform: 'none'});
  1999. // }
  2000. // else {
  2001. // modifyMyElement (viPlayerWindow, 'div', '', true);
  2002. // styleMyElement (viPlayerWindow, {height: '100%'});
  2003. // }
  2004.  
  2005. appendMyElement (viPlayerWindow, myPlayerWindow);
  2006. if (viVideosContent) {
  2007. if (viVideosContent.request.files.hls) viVideoList[viVideoFormats['HLS']] = viVideosContent.request.files.hls.url;
  2008. for (var viVideoCode in viVideoFormats) {
  2009. for (var i=0; i < viVideosContent.request.files.progressive.length; i++) {
  2010. if (viVideosContent.request.files.progressive[i].quality == viVideoCode) {
  2011. viVideoFound = true;
  2012. myVideoCode = viVideoFormats[viVideoCode];
  2013. viVideoList[myVideoCode] = viVideosContent.request.files.progressive[i].url;
  2014. }
  2015. }
  2016. }
  2017. }
  2018. if (viVideoFound) {
  2019. /* Create Player */
  2020. var viDefaultVideo = 'Low Definition MP4';
  2021. var player = {
  2022. 'playerSocket': viPlayerWindow,
  2023. 'playerWindow': myPlayerWindow,
  2024. 'videoList': viVideoList,
  2025. 'videoPlay': viDefaultVideo,
  2026. 'videoThumb': viVideoThumb,
  2027. 'videoDuration': viVideoDuration,
  2028. 'playerWidth': PlayerWidth,
  2029. 'playerHeight': PlayerHeight
  2030. };
  2031. feature['container'] = false;
  2032. feature['widesize'] = false;
  2033. option['definitions'] = ['High Definition', 'Low Definition', 'Very Low Definition'];
  2034. option['containers'] = ['MP4'];
  2035. debugger;
  2036. HeadWindow = getMyElement('', 'div', 'id', 'topnav_desktop', -1, false);
  2037. // HeadWindow = getMyElement('', 'div', 'class', 'topnav_desktop_wrapper', 0, false);
  2038. // HeadWindow = getMyElement('', 'div', 'class', 'body_ribbon', 0, false);
  2039. createMyPlayer (player);
  2040.  
  2041. /* Fix panel */
  2042. if (viVideoPage) styleMyElement(player['playerContent'], {marginTop: '5px'});
  2043. else styleMyElement(player['playerContent'], {marginTop: '3px'});
  2044.  
  2045. } else {
  2046. showMyMessage ('!videos');
  2047. }
  2048. });
  2049. });
  2050. }
  2051. }
  2052. }
  2053.  
  2054. function onNodeInserted(e) {
  2055. if (e && e.target && (typeof e.target.className !== 'undefined') && e.target.className.className == 'video-wrapper') {
  2056. setTimeout(function() { vimeo_run(); }, 0);
  2057. }
  2058. }
  2059.  
  2060. var paginationholder = getMyElement ('', 'div', 'class', 'pagination_holder', 0, false);
  2061. vimeo_run();
  2062. var content=document.getElementById('content');
  2063. window.addEventListener("hashchange", onNodeInserted(), false)
  2064. var mo=window.MutationObserver||window.MozMutationObserver||window.WebKitMutationObserver;
  2065. if (content && typeof mo!=='undefined') {
  2066. var observer=new mo(function(mutations) {
  2067. mutations.forEach(function(mutation) {
  2068. if(mutation.addedNodes!==null && mutation.addedNodes.length > 0) {
  2069. for (var i=0; i<mutation.addedNodes.length; i++) {
  2070. if (typeof mutation.addedNodes[i].className !== 'undefined') if (mutation.addedNodes[i].className == 'video-wrapper') {
  2071. vimeo_run(mutation.addedNodes);
  2072. break;
  2073. }
  2074. }
  2075. }
  2076. });
  2077. });
  2078. observer.observe(content, {childList: true, subtree: true});
  2079. } else {
  2080. page.win.setInterval(function() {
  2081. nurl = window.location.href;
  2082. if (page.url != nurl) vimeo_run(); //window.location.href = nurl;
  2083. }, 500)
  2084. }
  2085. }
  2086.  
  2087. // VEVO
  2088. else if (page.url.match(/https?:\/\/(www\.)?vevo.com\//)) {
  2089. var oldurl;
  2090. var vePlayerWindow;
  2091. var ve1PlayerWindow;
  2092.  
  2093. function vevo_run(vePlayerId) {
  2094. var PlayerHeight, PlayerWidth, PlayerWideHeight, PlayerWideWidth, veVideo, myVideoCode;
  2095. if (oldurl == page.url) return;
  2096. oldurl = page.url;
  2097. function createMyvePlayer() {
  2098. try {window.removeEventListener('resize', vePlayerResize, false)} catch(e) {};
  2099. var veDefaultVideo = 'Standard Definition MP4';
  2100. var player = {
  2101. 'playerSocket': vePlayerWindow,
  2102. 'playerWindow': myPlayerWindow,
  2103. 'videoList': veVideoList,
  2104. 'videoPlay': veDefaultVideo,
  2105. 'videoThumb': veVideoThumb,
  2106. 'videoDuration': veVideoDuration,
  2107. 'playerWidth': PlayerWidth,
  2108. 'playerHeight': PlayerHeight,
  2109. 'sidebarWindow': veSidebarWindow,
  2110. 'playerWideWidth': PlayerWideWidth,
  2111. 'playerWideHeight': PlayerWideHeight
  2112. };
  2113.  
  2114. vePlayerResize = function () {
  2115. veSizes();
  2116. player['playerWidth'] = PlayerWidth;
  2117. player['playerHeight'] = PlayerHeight;
  2118. player['playerWideWidth'] = PlayerWideWidth;
  2119. player['playerWideHeight'] = PlayerWideHeight;
  2120. var veInfoWindow = getMyElement ('', 'div', 'class', 'watch-info', 0, false);
  2121. if (veInfoWindow) styleMyElement (veInfoWindow, {position: 'absolute', top: '0px', left: Math.floor(PlayerWidth + 1) + 'px'});
  2122. resizeMyPlayer(player, 'widesize');
  2123. };
  2124.  
  2125. feature['container'] = false;
  2126. option['definitions'] = ['Ultra High Definition', 'Full High Definition', 'High Definition', 'Standard Definition', 'Low Definition', 'Very Low Definition'];
  2127. option['containers'] = ['MP4'];
  2128. HeadWindow = getMyElement('', 'div', 'class', 'site ng-scope', 0, false);
  2129.  
  2130. createMyPlayer (player);
  2131.  
  2132. /* Update Sizes */
  2133. window.addEventListener('resize', vePlayerResize,false);
  2134. }
  2135.  
  2136. function veSizes() {
  2137. var veScreenWidth = page.win.innerWidth || page.doc.documentElement.clientWidth;
  2138. var veScreenHeight = page.win.innerHeight || page.doc.documentElement.clientHeight;
  2139. if (veScreenWidth > 1400) {
  2140. PlayerWidth = 850;
  2141. PlayerHeight = 479;
  2142. PlayerWideWidth = 1201;
  2143. PlayerWideHeight = 677;
  2144. }
  2145. else {
  2146. PlayerWidth = 639;
  2147. PlayerHeight = 359;
  2148. PlayerWideWidth = 993;
  2149. PlayerWideHeight = 558;
  2150. }
  2151. }
  2152.  
  2153. var veVideoFormats = {
  2154. 'High': 'High Definition MP4'
  2155. ,'Med': 'Standard Definition MP4'
  2156. ,'Low': 'Ultra Low Definition MP4'
  2157. ,'HTTP Live Streaming': 'HTTP Live Streaming'
  2158. ,'564000': 'Very Low Definition MP4'
  2159. ,'864000': 'Low Definition MP4'
  2160. ,'1328000':'Standard Definition MP4'
  2161. ,'1728000':'Standard Definition HBR MP4'
  2162. ,'2528000':'High Definition MP4'
  2163. ,'3328000':'High Definition HBR MP4'
  2164. ,'4392000':'Full High Definition MP4'
  2165. ,'4328000':'Full High Definition MP4'
  2166. ,'5392000':'Full High Definition HBR MP4'
  2167. ,'5328000':'Full High Definition HBR MP4'
  2168. };
  2169. var veVideoList = {};
  2170. var veVideoFound1 = false;
  2171. var veVideoFound2 = false;
  2172.  
  2173. /* Get Player Window */
  2174. vePlayerWindow = getMyElement ('', 'div', 'class', 'player', 0, false);
  2175. if (!vePlayerWindow) vePlayerWindow = getMyElement ('', 'div', 'class', 'hero', 0, false);
  2176. if (!vePlayerWindow) {
  2177. showMyMessage ('!player');
  2178. }
  2179. else {
  2180. /* Get Videos Content */
  2181. var veVideoID = page.url.match(/((https?:\/\/(www\.)?vevo.com\/watch.*\/)|(vevo:))(\w{10,12})(\?|$)/);
  2182. veVideoID = veVideoID ? veVideoID[5] : null;
  2183. if (!veVideoID) veVideoID = getMyContent(page.url,'"embedURL" href=.*?videoId=(.*?)\&amp;',false);
  2184. var veVideoPlayer = getMyContent(page.url, 'meta\\s+property="og:video"\\s+content="(.*?)"', false);
  2185. var xmlHTTP = new XMLHttpRequest();
  2186. xmlHTTP.open('POST', 'https://www.vevo.com/auth', false);
  2187. xmlHTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  2188. xmlHTTP.send();
  2189. var vevotoken = xmlHTTP.responseText.match(/"refresh_token":"(.*?)"/);
  2190.  
  2191. var veVideoURL = "https://apiv2.vevo.com/video/" + veVideoID + "?token=" + vevotoken[1];
  2192. var veVideosContent = getMyContent(veVideoURL, 'TEXT', false);
  2193. if (veVideosContent) {
  2194. var veVideosJSON = JSON.parse(veVideosContent);
  2195. var veVideoThumb = veVideosContent.match('"imageUrl":"(.*?)"');
  2196. if (!veVideoThumb) veVideoThumb = veVideosContent.match('"thumbnailUrl":"(.*?)"')
  2197. if (veVideoThumb) veVideoThumb = veVideoThumb[1];
  2198. }
  2199. else {
  2200. showMyMessage ('!content');
  2201. }
  2202.  
  2203. cleanMyElement (vePlayerWindow, false);
  2204. var veSidebarWindow = getMyElement('', 'div', 'class', 'hero', 0, false);
  2205. styleMyElement (veSidebarWindow, {height: 'auto'});
  2206. /* My Player Window */
  2207. veSizes();
  2208.  
  2209. if (myPlayerWindow) {
  2210. modifyMyElement (myPlayerWindow, 'div', '', true);
  2211. } else {
  2212. var vePlayer = getMyElement(vePlayerWindow, 'div', 'class', 'flash-player', 0, false);
  2213. if (!vePlayer) vePlayer = getMyElement ('', 'div', 'id', 'freewheel-container', -1, false);
  2214. if (vePlayer) {
  2215. removeMyElement(vePlayer.parentNode, vePlayer);
  2216. modifyMyElement (vePlayer, 'div', '', true);
  2217. styleMyElement (vePlayer, {display: 'none'});
  2218. }
  2219. myPlayerWindow = createMyElement ('div', '', '', '', '');
  2220. styleMyElement (myPlayerWindow, {position: 'relative', width: PlayerWidth + 'px', height: PlayerHeight + 'px', backgroundColor: '#F4F4F4', zIndex: '18',fontFamily: '"Arial","Helvetica","sans-serif"', margin: '0 auto'});
  2221. var vePlayerError = getMyElement ('', 'div', 'class', 'video-error', 0, false);
  2222. if (vePlayerError) {
  2223. removeMyElement(vePlayerError.parentNode, vePlayerError);
  2224. }
  2225. appendMyElement (vePlayerWindow, myPlayerWindow);
  2226. var veInfoWindow = getMyElement ('', 'div', 'class', 'watch-info', 0, false);
  2227. if (veInfoWindow) styleMyElement (veInfoWindow, {position: 'absolute', top: '0px', left: Math.floor(PlayerWidth + 1) + 'px'});
  2228. }
  2229.  
  2230. if (veVideosJSON) {
  2231. var veStreamURL = "https://apiv2.vevo.com/video/" + veVideoID + "/streams?token=" + vevotoken[1];
  2232. veVideosJSON.video = {Object};
  2233. veVideosJSON.video.videoVersions = JSON.parse(getMyContent(veStreamURL,'TEXT',false));
  2234. var veVideo, veVideoVersion;
  2235. for (var i = 0; i < veVideosJSON.video.videoVersions.length - 1; i++) {
  2236. if (veVideosJSON.video.videoVersions[i].sourceType == 2) {
  2237. if (veVideosJSON.video.videoVersions[i].version in {3:1,4:1}) {
  2238. for (var veVideoFormat in veVideoFormats) {
  2239. veVideo = veVideosJSON.video.videoVersions[i].data.match('rendition name="' + veVideoFormat + '" url="(.*?)"');
  2240. if (veVideo) {
  2241. veVideoFound1 = true;
  2242. veVideoList[veVideoFormats[veVideoFormat]] = veVideo[1];
  2243. }
  2244. }
  2245. }
  2246. }
  2247. if (veVideoFound1) break;
  2248. }
  2249. for (var i = 0; i < veVideosJSON.video.videoVersions.length - 1; i++) {
  2250. if (veVideosJSON.video.videoVersions[i].sourceType == 3) {
  2251. for (var veVideoFormat in veVideoFormats) {
  2252. veVideo = veVideosJSON.video.videoVersions[i].data.match('rendition name="' + veVideoFormat + '" url="(.*?)"');
  2253. if (veVideo) {
  2254. veVideoFound1 = true;
  2255. veVideoFound2 = true;
  2256. veVideoList[veVideoFormats[veVideoFormat] + ' MP4'] = veVideo[1];
  2257. }
  2258. }
  2259. }
  2260. if (veVideoFound2) break;
  2261. }
  2262. veVideoFound2 = false;
  2263. for (var i = 0; i < veVideosJSON.video.videoVersions.length - 1; i++) {
  2264. if (veVideosJSON.video.videoVersions[i].url && veVideosJSON.video.videoVersions[i].url.match('//h264-((lvl3)|(aws)).vevo.com/')) {
  2265. for (var veVideoFormat in veVideoFormats) {
  2266. if (veVideosJSON.video.videoVersions[i].quality == veVideoFormat) {
  2267. veVideoFound1 = true;
  2268. veVideoFound2 = true;
  2269. veVideoList[veVideoFormats[veVideoFormat]] = veVideosJSON.video.videoVersions[i].url;
  2270. }
  2271. }
  2272. }
  2273. }
  2274. veVideoFound2 = false;
  2275. for (var i = 0; i < veVideosJSON.video.videoVersions.length - 1; i++) {
  2276. if (veVideosJSON.video.videoVersions[i].url && veVideosJSON.video.videoVersions[i].url.match('//hls-((lvl3)|(aws)|(aka)).vevo.com/')) {
  2277. veVideoFound1 = true;
  2278. veVideoFound2 = true;
  2279. veVideoList[veVideoFormats['HTTP Live Streaming']] = veVideosJSON.video.videoVersions[i].url;
  2280. }
  2281. }
  2282. veVideoFound2 = false;
  2283. for (var i = 0; i < veVideosJSON.video.videoVersions.length - 1; i++) {
  2284. if (veVideosJSON.video.videoVersions[i].sourceType == 5 && veVideosJSON.video.videoVersions[i].version == 1) {
  2285. veVideo = veVideosJSON.video.videoVersions[i].data.match('rendition name="HTTP\\s?Level3" url="(.*?)"');
  2286. if (veVideo) veVideoFound2 = true;
  2287. }
  2288. else if (veVideosJSON.video.videoVersions[i].url && veVideosJSON.video.videoVersions[i].url.match('//smil-((lvl3)|(aws)|(aka)).vevo.com/')) {
  2289. veVideo = veVideosJSON.video.videoVersions[i].url
  2290. if (veVideo) veVideoFound2 = true;
  2291. }
  2292. if (veVideoFound2) break;
  2293. }
  2294. if (veVideoFound2) getMyContentGM(veVideo[1],'TEXT',false, function (vesmilfile) {
  2295. for (veVideoFormat in veVideoFormats) {
  2296. if (vesmilfile.match(veVideoFormat)) {
  2297. veVideoList[veVideoFormats[veVideoFormat]] = "http://smil.lvl3.vevo.com" + vesmilfile.match('video src="mp4:(.*?)" system-bitrate="' + veVideoFormat + '"')[1];
  2298. }
  2299. }
  2300. createMyvePlayer();
  2301. });
  2302. if (!veVideoFound2) if (veVideoFound1) createMyvePlayer(); else showMyMessage ('!videos');
  2303. }
  2304. }
  2305. }
  2306.  
  2307. function start_vevo() {
  2308. var elWait = 50;
  2309. var refreshIntervalId = page.win.setInterval(function() {
  2310. if (getMyElement('', 'div', 'class', 'flash-player', 0, false) || getMyElement ('', 'div', 'id', 'html5-player', -1, false)
  2311. || getMyElement ('', 'div', 'class', 'video-error', 0, false)) {
  2312. page.win.clearInterval(refreshIntervalId);
  2313. page = {win: window, doc: document, body: document.body, url: window.location.href}
  2314. vevo_run();
  2315. } else if (elWait > 0) {
  2316. elWait--;
  2317. } else {
  2318. page.win.clearInterval(refreshIntervalId);
  2319. }
  2320. }, 500);
  2321. }
  2322.  
  2323. start_vevo();
  2324.  
  2325. var nId = getMyContent(page.url,'"embedURL" href=.*?videoId=(.*?)\&amp;',false);
  2326. page.win.setInterval(function() {
  2327. if (getMyContent(page.url,'"embedURL" href=.*?videoId=(.*?)\&amp;',false) != nId) {
  2328. nId = getMyContent(page.url,'"embedURL" href=.*?videoId=(.*?)\&amp;',false);
  2329. page.url = window.location.href;
  2330. if (getMyElement ('', 'div', 'class', 'watch-info', 0, false)) vevo_run(); else window.location.href = page.url;
  2331. }
  2332. }, 500)
  2333. }
  2334. // =====MetaCafe===== //
  2335.  
  2336. else if (page.url.indexOf('metacafe.com/watch') != -1) {
  2337. /* Get Player Window */
  2338. var mcPlayerWindow = getMyElement ('', 'div', 'class', 'mc-video-player', 0, false);
  2339. if (!mcPlayerWindow) mcPlayerWindow = getMyElement ('', 'div', 'id', 'ItemContainer', -1, false);
  2340. if (!mcPlayerWindow) {
  2341. showMyMessage ('!player');
  2342. }
  2343. else {
  2344. /* Check Video Availability */
  2345. if (mcPlayerWindow.innerHTML.indexOf('This Video cannot be played on this device.') != -1) return;
  2346.  
  2347. /* Hide Ads */
  2348. var mcTopAd = getMyElement ('', 'div', 'id', 'BillboardContainer', -1, false);
  2349. if (mcTopAd) styleMyElement(mcTopAd, {display: 'none'});
  2350. var mcTopAd2 = getMyElement ('', 'div', 'id', 'taboola-header-thumbnails', -1, false);
  2351. if (mcTopAd2) styleMyElement(mcTopAd2, {display: 'none'});
  2352.  
  2353. /* Get Video Thumbnail */
  2354. var mcVideoThumb = getMyContent (page.url, '"preview":"(.*?)"', true);
  2355. // var mcVideoDuration = getMyContent (page.url, 'meta\\s+property="video:duration"\\s+content="(.*?)"', false);
  2356. // if (mcVideoDuration) mcVideoDuration = parseInt(mcVideoDuration);
  2357.  
  2358. /* Get Videos Content */
  2359. var mcVideosContent = getMyContent (page.url, 'var flashvars\\s+=\\s+({.*?});', false);
  2360. var mcVideo = cleanMyContent(mcVideo, true);
  2361.  
  2362. /* My Player Window */
  2363. myPlayerWindow = createMyElement ('div', '', '', '', '');
  2364. var PlayerHeight = mcPlayerWindow.clientHeight + 22;
  2365. var PlayerWidth = mcPlayerWindow.clientWidth;
  2366. styleMyElement (myPlayerWindow, {position: 'relative', width: PlayerWidth + 'px', height: PlayerHeight + 'px', backgroundColor: '#F4F4F4', zIndex: '10'});
  2367. modifyMyElement (mcPlayerWindow, 'div', '', true);
  2368. styleMyElement (mcPlayerWindow, {height: '100%'});
  2369. // cleanMyElement (mcPlayerWindow, false);
  2370. // if (mcPlayerWindow.children[0] && mcPlayerWindow.children[0].href == "http://get.adobe.com/flashplayer") removeMyElement(mcPlayerWindow, mcPlayerWindow.children[0]);
  2371. appendMyElement (mcPlayerWindow, myPlayerWindow);
  2372.  
  2373. blockObject = mcPlayerWindow;
  2374.  
  2375. /* Get Videos */
  2376. if (mcVideosContent || mcVideo) {
  2377. var mcVideoList = {};
  2378. var mcVideoFound = false;
  2379. if (mcVideosContent) {
  2380. mcVideosContent = JSON.parse(mcVideosContent);
  2381. // mcVideosContent = cleanMyContent(mcVideosContent, true);
  2382. var mcVideoFormats = {'HLS': 'HTTP Live Streaming', 'HLS240': 'Low Definition HLS','HLS360': 'High Definition HLS', 'Standard': 'Standard Definition MP4'};
  2383. var mcVideom3u, mcVideoSrc, myVideoCode, mcVideoPath;
  2384. for (var i=0; i < mcVideosContent.sources.length; i++) {
  2385. mcVideoList[mcVideoFormats['HLS']] = mcVideosContent.sources[i].src;
  2386. mcVideoSrc = mcVideosContent.sources[i].src;
  2387. mcVideoPath = mcVideoSrc.match("(^.*\\/).*?$");
  2388. mcVideoPath = (mcVideoPath) ? mcVideoPath[1] : null;
  2389. mcVideom3u = getMyContent(mcVideoSrc,'TEXT',false);
  2390. mcVideoList[mcVideoFormats['HLS240']] = mcVideoPath + mcVideom3u.match('(.*240p\\.m3u8)')[1];
  2391. mcVideoList[mcVideoFormats['HLS360']] = mcVideoPath + mcVideom3u.match('(.*360p\\.m3u8)')[1];
  2392. mcVideoFound = true;
  2393. }
  2394. mcVideoList[mcVideoFormats[2]] = mcVideosContent.flashvars.video_url + '?key=' + mcVideosContent.flashvars.license_code;
  2395. }
  2396. if (mcVideoFound) {
  2397. /* Get Watch Sidebar */
  2398. var mcSidebarWindow = getMyElement ('', 'div', 'class', 'mc-right-block', 0, false);
  2399. /* Create Player */
  2400. var mcDefaultVideo = 'HTTP Live Streaming';
  2401. var player = {
  2402. 'playerSocket': mcPlayerWindow,
  2403. 'playerWindow': myPlayerWindow,
  2404. 'videoList': mcVideoList,
  2405. 'videoPlay': mcDefaultVideo,
  2406. 'videoThumb': mcVideoThumb,
  2407. // 'videoDuration': mcVideoDuration,
  2408. 'playerWidth': PlayerWidth,
  2409. 'playerHeight': PlayerHeight,
  2410. 'playerWideWidth': 1140,
  2411. 'playerWideHeight': 672,
  2412. 'sidebarWindow': mcSidebarWindow,
  2413. 'sidebarMarginNormal': 0,
  2414. 'sidebarMarginWide': 466
  2415. };
  2416. option['definitions'] = ['Standard Definition', 'Low Definition'];
  2417. option['containers'] = ['MP4', 'Any'];
  2418. HeadWindow = getMyElement ('', 'div', 'id', 'mc-header', -1, false);
  2419. createMyPlayer (player);
  2420. }
  2421. else {
  2422. showMyMessage ('!videos');
  2423. }
  2424. }
  2425. else {
  2426. var ytVideoId = page.url.match (/\/yt-(.*?)\//);
  2427. if (ytVideoId && ytVideoId[1]) {
  2428. var ytVideoLink = 'http://youtube.com/watch?v=' + ytVideoId[1];
  2429. showMyMessage ('embed', ytVideoLink);
  2430. }
  2431. else {
  2432. showMyMessage ('!content');
  2433. }
  2434. }
  2435. }
  2436. }
  2437.  
  2438. // =====Break===== //
  2439.  
  2440. else if (page.url.indexOf('break.com/video') != -1 || page.url.indexOf('break.com/movies') != -1) {
  2441.  
  2442. /* Get Player Window */
  2443. var brPlayerWindow = getMyElement ('', 'div', 'id', 'video-player', -1, false);
  2444. if (!brPlayerWindow) {
  2445. showMyMessage ('!player');
  2446. }
  2447. else {
  2448. /* Get Video ID */
  2449. var brVideoID = getMyContent(page.url, 'id="js-video-player-iframe".*?src="/embed/(\\d+)(\\?|")',false);
  2450. if (!brVideoID) brVideoID = getMyContent (page.url, 'meta\\s+name="embed_video_url"\\s+content=".*/(\\d+)/"', false);
  2451. if (!brVideoID) {
  2452. brVideoID = page.url.match(/(\d+)$/);
  2453. brVideoID = (brVideoID) ? brVideoID[1] : null;
  2454. }
  2455.  
  2456. /* Get Videos Content */
  2457. var brSource = page.win.location.protocol + '//' + page.win.location.hostname + '/embed/' + brVideoID;
  2458. var brVideosContent = getMyContent (brSource, 'TEXT', false);
  2459.  
  2460. /* Player Size */
  2461. var brScreenWidth;
  2462. var brPlayerWidth, brPlayerHeight;
  2463. var brPlayerWideWidth, brPlayerWideHeight;
  2464. var brSidebarMarginWide = 720;
  2465. function brSizes() {
  2466. brScreenWidth = page.win.innerWidth || page.doc.documentElement.clientWidth;
  2467. if (page.url.indexOf('break.com/movies') != -1) {
  2468. if (brScreenWidth >= 1400) {
  2469. brPlayerWidth = 1152;
  2470. brPlayerHeight = 690;
  2471. }
  2472. else {
  2473. brPlayerWidth = 912;
  2474. brPlayerHeight = 546;
  2475. }
  2476. }
  2477. else {
  2478. if (brScreenWidth >= 1400) {
  2479. brPlayerWidth = 832;
  2480. brPlayerHeight = 490;
  2481. brPlayerWideWidth = 1152;
  2482. brPlayerWideHeight = 690;
  2483. brSidebarMarginWide = 850;
  2484. }
  2485. else {
  2486. brPlayerWidth = 592;
  2487. brPlayerHeight = 356;
  2488. brPlayerWideWidth = 910;
  2489. brPlayerWideHeight = 534;
  2490. }
  2491. }
  2492. }
  2493. brSizes();
  2494.  
  2495. /* My Player Window */
  2496. myPlayerWindow = createMyElement ('div', '', '', '', '');
  2497. styleMyElement (myPlayerWindow, {position: 'relative', width: brPlayerWidth + 'px', height: brPlayerHeight + 'px', backgroundColor: '#F4F4F4'});
  2498. modifyMyElement (brPlayerWindow, 'div', '', true);
  2499. styleMyElement (brPlayerWindow, {height: '100%', overflow: 'visible', paddingBottom: '20px'});
  2500. appendMyElement (brPlayerWindow, myPlayerWindow);
  2501.  
  2502. /* Update Sizes */
  2503. page.win.addEventListener('resize', function() {
  2504. brSizes();
  2505. player['playerWidth'] = brPlayerWidth;
  2506. player['playerHeight'] = brPlayerHeight;
  2507. player['playerWideWidth'] = brPlayerWideWidth;
  2508. player['playerWideHeight'] = brPlayerWideHeight;
  2509. player['sidebarMarginWide'] = brSidebarMarginWide;
  2510. resizeMyPlayer('widesize');
  2511. }, false);
  2512.  
  2513. /* Get Videos */
  2514. if (brVideosContent) {
  2515. var brVideoList = {};
  2516. var brVideoFormats = {};
  2517. var brVideoFound = false;
  2518. 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'};
  2519. var brVideoPath, brVideoToken, brVideoThumb, brVideo, myVideoCode;
  2520. if (page.url.indexOf('break.com/video') != -1) {
  2521. brVideoPath = brVideosContent.match (/"videoUri":\s"(.*?)496_kbps/);
  2522. brVideoPath = (brVideoPath) ? brVideoPath[1] : null;
  2523. }
  2524. else {
  2525. brVideoPath = brVideosContent.match (/"hlsUri":\s"(.*?)"/);
  2526. brVideoPath = (brVideoPath) ? brVideoPath[1] : null;
  2527. }
  2528. brVideoToken = brVideosContent.match (/"AuthToken":\s"(.*?)"/);
  2529. brVideoToken = (brVideoToken) ? brVideoToken[1] : null;
  2530. brVideoThumb = brVideosContent.match (/"thumbUri":\s"(.*?)"/);
  2531. brVideoThumb = (brVideoThumb) ? brVideoThumb[1] : null;
  2532.  
  2533. if (brVideoPath && brVideoToken) {
  2534. for (var brVideoCode in brVideoFormats) {
  2535. if (brVideosContent.match(brVideoCode)) {
  2536. if (!brVideoFound) brVideoFound = true;
  2537. myVideoCode = brVideoFormats[brVideoCode];
  2538. if (page.url.indexOf('break.com/video') != -1) brVideo = brVideoPath + brVideoCode + '?' + brVideoToken;
  2539. else brVideo = brVideoPath + brVideoCode + '.m3u8?' + brVideoToken;
  2540. brVideoList[myVideoCode] = brVideo;
  2541. }
  2542. }
  2543. }
  2544. if (brVideoFound) {
  2545. /* Get Watch Sidebar */
  2546. var brSidebarWindow = getMyElement ('', 'aside', 'class', 'sidebar', 0, false);
  2547.  
  2548. /* Create Player */
  2549. var brDefaultVideo = 'Low Definition MP4';
  2550. var brWindowWidth = page.win.innerWidth || page.doc.documentElement.clientWidth;
  2551. player = {
  2552. 'playerSocket': brPlayerWindow,
  2553. 'playerWindow': myPlayerWindow,
  2554. 'videoList': brVideoList,
  2555. 'videoPlay': brDefaultVideo,
  2556. 'videoThumb': brVideoThumb,
  2557. 'playerWidth': brPlayerWidth,
  2558. 'playerHeight': brPlayerHeight,
  2559. 'playerWideWidth': brPlayerWideWidth,
  2560. 'playerWideHeight': brPlayerWideHeight,
  2561. 'sidebarWindow': brSidebarWindow,
  2562. 'sidebarMarginNormal': 10,
  2563. 'sidebarMarginWide': brSidebarMarginWide
  2564. };
  2565. if (page.url.indexOf('break.com/movies') != -1) feature['widesize'] = false;
  2566. HeadWindow = getMyElement('', 'div', 'class', 'SiteNav', 0, false);
  2567. option['definitions'] = ['Very Low Definition', 'Low Definition', 'Standard Definition', 'High Definition', 'Full High Definition'];
  2568. option['containers'] = ['MP4', 'FLV', 'Any'];
  2569. createMyPlayer (player);
  2570. }
  2571. else {
  2572. var ytVideoId = brVideosContent.match (/"youtubeId":\s"(.*?)"/);
  2573. if (ytVideoId && ytVideoId[1]) {
  2574. var ytVideoLink = 'http://youtube.com/watch?v=' + ytVideoId[1];
  2575. showMyMessage ('embed', ytVideoLink);
  2576. }
  2577. else {
  2578. showMyMessage ('!videos');
  2579. }
  2580. }
  2581. }
  2582. else {
  2583. showMyMessage ('!content');
  2584. }
  2585. }
  2586. }
  2587.  
  2588. // =====FunnyOrDie===== //
  2589. else if (page.url.indexOf('funnyordie.com/videos') != -1) {
  2590. function fod_run(viPlayerId) {
  2591. /* Get Player Window */
  2592. var fodPlayerWindow = getMyElement ('', 'div', 'id', 'player-container', -1, false);
  2593. if (!fodPlayerWindow) {
  2594. showMyMessage ('!player');
  2595. }
  2596. else {
  2597. /* Get Video Thumbnail */
  2598. var fodVideoThumb = getMyContent (page.url, 'meta\\s+property="og:image"\\s+content="(.*?)"', false);
  2599. if (fodVideoThumb) fodVideoThumb = fodVideoThumb.replace (/large/, 'fullsize');
  2600.  
  2601. /* Get Videos Content */
  2602. var fodVideosContent = getMyContent (page.url, '<video([\\s\\S]*?)video>', false);
  2603.  
  2604. /* Clean Player Window */
  2605. var fodPlayerContainer = getMyElement ('', 'div', 'id', 'videoContainer', -1, false);
  2606. var PlayerHeight = fodPlayerContainer.clientHeight + 22;
  2607. var PlayerWidth = fodPlayerContainer.clientWidth;
  2608. if (fodPlayerContainer) styleMyElement (fodPlayerContainer, {display: 'none'});
  2609. blockObject = fodPlayerContainer;
  2610.  
  2611. /* My Player Window */
  2612. myPlayerWindow = createMyElement ('div', '', '', '', '');
  2613. styleMyElement (myPlayerWindow, {position: 'relative', width: PlayerWidth + 'px', height: PlayerHeight + 'px', backgroundColor: '#F4F4F4', margin: '0px auto'});
  2614. styleMyElement (fodPlayerWindow, {height: '100%', overflow: 'visible'});
  2615. fodPlayerContainer.parentNode.insertBefore (myPlayerWindow, fodPlayerContainer);
  2616.  
  2617. /* Get Videos */
  2618. if (fodVideosContent) {
  2619. 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'};
  2620. var fodVideoList = {};
  2621. var fodVideoFound = false;
  2622. var fodVideoPath, fodVideoCodes, fodVideo, myVideoCode;
  2623. fodVideoPath = fodVideosContent.match(/src="(.*?)v\d+.*?\.mp4"/);
  2624. fodVideoPath = (fodVideoPath) ? fodVideoPath[1] : null;
  2625. fodVideoCodes = fodVideosContent.match (/v([^\/]*?)\/master/)
  2626. if (!fodVideoCodes) fodVideoCodes = fodVideosContent.match (/src=".*?\/v(\d{3,4})\./);
  2627. fodVideoCodes = (fodVideoCodes) ? fodVideoCodes[1] : '';
  2628. if (fodVideoPath && fodVideoCodes) {
  2629. for (var fodVideoCode in fodVideoFormats) {
  2630. if (fodVideoCodes.indexOf(fodVideoCode.replace(/v/, '').replace(/\..*/, "")) != -1) {
  2631. if (!fodVideoFound) fodVideoFound = true;
  2632. fodVideo = page.win.location.protocol + fodVideoPath + fodVideoCode;
  2633. myVideoCode = fodVideoFormats[fodVideoCode];
  2634. fodVideoList[myVideoCode] = fodVideo;
  2635. }
  2636. }
  2637. }
  2638. else {
  2639. for (var fodVideoCode in fodVideoFormats) {
  2640. fodVideo = page.win.location.protocol + fodVideoPath + fodVideoCode;
  2641. if (fodVideosContent.match(fodVideo)) {
  2642. if (!fodVideoFound) fodVideoFound = true;
  2643. myVideoCode = fodVideoFormats[fodVideoCode];
  2644. fodVideoList[myVideoCode] = fodVideo;
  2645. }
  2646. }
  2647. }
  2648.  
  2649. if (fodVideoFound) {
  2650. /* Create Player */
  2651. fodDefaultVideo = 'Low Definition MP4';
  2652. var player = {
  2653. 'playerSocket': fodPlayerWindow,
  2654. 'playerWindow': myPlayerWindow,
  2655. 'videoList': fodVideoList,
  2656. 'videoPlay': fodDefaultVideo,
  2657. 'videoThumb': fodVideoThumb,
  2658. 'playerWidth': PlayerWidth,
  2659. 'playerHeight': PlayerHeight
  2660. };
  2661. feature['container'] = false;
  2662. feature['widesize'] = false;
  2663. option['definitions'] = ['High Definition', 'Low Definition'];
  2664. option['containers'] = ['MP4'];
  2665. createMyPlayer (player);
  2666. styleMyElement (player['playerPanel'], {height: '24px'});
  2667. }
  2668. else {
  2669. showMyMessage ('!videos');
  2670. }
  2671. }
  2672. else {
  2673. showMyMessage ('!content');
  2674. }
  2675. }
  2676. }
  2677.  
  2678. function onNodeInserted(e) {
  2679. if (e && e.target && e.target.textContent == "10") {
  2680. nurl = window.location.href;
  2681. if (page.url != nurl) window.location.href = nurl;
  2682. }
  2683. }
  2684.  
  2685. fod_run();
  2686. var pagecontainer = getMyElement ('', 'div', 'id', 'player-container', -1, false)
  2687. if (pagecontainer) {
  2688. var mo=window.MutationObserver||window.MozMutationObserver||window.WebKitMutationObserver;
  2689. if(typeof mo!=='undefined') {
  2690. var observer=new mo(function(mutations) {
  2691. mutations.forEach(function(mutation) {
  2692. if(mutation.addedNodes!==null && mutation.addedNodes.length > 0) {
  2693. for (var i=0; i<mutation.addedNodes.length; i++) {
  2694. if (mutation.addedNodes[0].textContent == "10") {
  2695. nurl = window.location.href;
  2696. if (page.url != nurl) window.location.href = nurl;
  2697. break;
  2698. }
  2699. }
  2700. }
  2701. });
  2702. });
  2703. observer.observe(pagecontainer, {childList: true, subtree: true});
  2704. } else { // MutationObserver fallback for old browsers
  2705. pagecontainer.parentNode.addEventListener('DOMNodeInserted', onNodeInserted, false);
  2706. }
  2707. }
  2708. }
  2709.  
  2710. // =====Videojug===== //
  2711. else if (page.url.indexOf('videojug.com') != -1) {
  2712.  
  2713. /* Get Player Window */
  2714. var vjPlayerWindow;
  2715. var vjPlayerWidth = 640;
  2716. var vjPlayerHeight = 384;
  2717. var vjPlayerWide = true;
  2718. if (page.url.indexOf("videojug.com/film") != -1) vjPlayerWindow = getMyElement ('', 'div', 'class', 'top-border-only', 0, false);
  2719. else if (page.url.indexOf("videojug.com/series") != -1) {
  2720. vjPlayerWindow = getMyElement ('', 'div', 'class', 'largePlayer', 0, false);
  2721. vjPlayerWidth = 954;
  2722. vjPlayerHeight = 562;
  2723. vjPlayerWide = false;
  2724. }
  2725. else return;
  2726. if (!vjPlayerWindow) {
  2727. showMyMessage ('!player');
  2728. }
  2729. else {
  2730. /* Get Videos Content */
  2731. var vjVideoID = getMyContent (page.url, 'data-videoid="(.*?)"', true);
  2732. var vjVideoTitle = getMyContent (page.url, 'data-filenameprefix="(.*?)"', true);
  2733. var vjVideoDuration = getMyContent (page.url, 'meta\\s+itemprop="duration"\\s+content="(.*?)"', false);
  2734. if (vjVideoDuration) {
  2735. vjVideoDuration = parseInt(vjVideoDuration.match(/\d{1,3}M/) ? vjVideoDuration.match(/(\d{1,3})M/)[1] :0) * 60 + parseInt(vjVideoDuration.match(/\d{1,2}S/) ? vjVideoDuration.match(/(\d{1,2})S/)[1] :0);
  2736. }
  2737.  
  2738. /* My Player Window */
  2739. myPlayerWindow = createMyElement ('div', '', '', '', '');
  2740. styleMyElement (myPlayerWindow, {position: 'relative', width: vjPlayerWidth + 'px', height: vjPlayerHeight + 'px', backgroundColor: '#F4F4F4', zIndex: '99999'});
  2741. modifyMyElement (vjPlayerWindow, 'div', '', true);
  2742. styleMyElement (vjPlayerWindow, {height: '100%', backgroundColor: '#FFFFFF', border: 'none', boxShadow: 'none'});
  2743. if (page.url.indexOf("videojug.com/series") != -1) styleMyElement (getMyElement ('', 'div', 'class', 'content-container', 0, false), {height: '988px'});
  2744. if (!vjPlayerWide) styleMyElement (vjPlayerWindow, {width: vjPlayerWidth + 'px'});
  2745. appendMyElement (vjPlayerWindow, myPlayerWindow);
  2746.  
  2747. /* Get Videos */
  2748. if (vjVideoID && vjVideoTitle) {
  2749. var vjVideoID2 = vjVideoID.substring(0,2);
  2750. var vjVideoProtocol = page.win.location.protocol;
  2751. var vjVideoSource = vjVideoProtocol + '//' + page.win.location.hostname + '/views/film/playlist.aspx?id=' + vjVideoID;
  2752. var vjVideoShapes = getMyContent(vjVideoSource, '<Shapes>(.*?)<\/Shapes>', false);
  2753. var vjVideoFormats = {'VJ480PENG.mp4': 'Standard Definition MP4', 'VJ360PENG.mp4': 'Low Definition MP4', 'PHOENG.mp4': 'Very Low Definition MP4', 'FW8ENG.flv': 'Low Definition FLV', 'FS8ENG.flv': 'Very Low Definition FLV'};
  2754. var vjVideoList = {};
  2755. var vjVideoFound = false;
  2756. var vjVideoPart, myVideoCode, vjVideo, vjVideoThumb, vjVideoCodePart, vjVideoPattern, vjVideoLocation;
  2757. if (vjVideoShapes) {
  2758. vjVideoPart = vjVideoID2 + '/' + vjVideoID + '/' + vjVideoTitle;
  2759. for (var vjVideoCode in vjVideoFormats) {
  2760. if (vjVideoCode.indexOf('VJ') != -1) vjVideoCodePart = vjVideoCode.substring(0, 6);
  2761. else vjVideoCodePart = vjVideoCode.substring(0, 3);
  2762. vjVideoPattern = 'Code="' + vjVideoCodePart + '"\\s+Locations="(.*?),';
  2763. vjVideoLocation = vjVideoShapes.match(vjVideoPattern);
  2764. vjVideoLocation = (vjVideoLocation) ? vjVideoProtocol + '//' + vjVideoLocation[1] : null;
  2765. if (vjVideoLocation) {
  2766. if (!vjVideoFound) vjVideoFound = true;
  2767. vjVideo = vjVideoLocation + '/' + vjVideoPart + '__' + vjVideoCode;
  2768. myVideoCode = vjVideoFormats[vjVideoCode];
  2769. vjVideoList[myVideoCode] = vjVideo;
  2770. }
  2771. }
  2772. vjVideoThumb = 'http://content5.videojug.com/' + vjVideoPart + '.WidePlayer.jpg';
  2773. }
  2774. if (vjVideoFound) {
  2775. /* Get Watch Sidebar */
  2776. var vjSidebarWindow = getMyElement ('', 'aside', 'id', 'side-bar', -1, false);
  2777. /* Create Player */
  2778. var vjDefaultVideo = 'Low Definition MP4';
  2779. var player = {
  2780. 'playerSocket': vjPlayerWindow,
  2781. 'playerWindow': myPlayerWindow,
  2782. 'videoList': vjVideoList,
  2783. 'videoPlay': vjDefaultVideo,
  2784. 'videoThumb': vjVideoThumb,
  2785. 'videoDuration': vjVideoDuration,
  2786. 'playerWidth': vjPlayerWidth,
  2787. 'playerHeight': vjPlayerHeight,
  2788. 'playerWideWidth': 954,
  2789. 'playerWideHeight': 562,
  2790. 'sidebarWindow': vjSidebarWindow,
  2791. 'sidebarMarginNormal': 5,
  2792. 'sidebarMarginWide': 580
  2793. };
  2794. feature['widesize'] = vjPlayerWide;
  2795. option['definition'] = 'SD';
  2796. option['definitions'] = ['Standard Definition', 'Low Definition', 'Very Low Definition'];
  2797. option['containers'] = ['MP4', 'FLV', 'Any'];
  2798. HeadWindow = getMyElement('', 'header', 'tag', '', 0, false);
  2799. createMyPlayer (player);
  2800. }
  2801. else {
  2802. showMyMessage ('!videos');
  2803. }
  2804. }
  2805. else {
  2806. showMyMessage ('!content');
  2807. }
  2808. }
  2809. }
  2810.  
  2811. // =====Blip===== //
  2812. else if (page.url.indexOf('blip.tv') != -1) {
  2813.  
  2814. /* Get Page Type */
  2815. var blipPageType = getMyContent (page.url, 'meta\\s+property="video:tag"\\s+content="(.*?)"', false);
  2816. if (!blipPageType || blipPageType.indexOf('episode') == -1) return;
  2817.  
  2818. /* Get Player Window */
  2819. var blipPlayerWidth, blipPlayerHeight;
  2820. var blipPlayerWindow = getMyElement ('', 'div', 'class', 'EpisodePlayer', 0, false) || getMyElement ('', 'div', 'id', 'ErrorWrap', -1, false);
  2821. if (!blipPlayerWindow) {
  2822. blipPlayerWindow = getMyElement ('', 'div', 'id', 'PlayerEmbed', -1, false);
  2823. blipPlayerWidth = 596;
  2824. blipPlayerHeight = 334;
  2825. }
  2826. else {
  2827. blipPlayerWidth = 960;
  2828. blipPlayerHeight = 565;
  2829. }
  2830. if (!blipPlayerWindow) {
  2831. showMyMessage ('!player');
  2832. }
  2833. else {
  2834. /* Get Video Info */
  2835. var blipVideoInfo = getMyContent(page.url + '?skin=json', 'TEXT', false);
  2836.  
  2837. /* Get Video Thumbnail */
  2838. var blipVideoThumb = (blipVideoInfo) ? blipVideoInfo.match(/"thumbnailUrl":"(.*?)"/) : null;
  2839. blipVideoThumb = (blipVideoThumb) ? blipVideoThumb[1] : null;
  2840. var blipVideoDuration = getMyContent (page.url, 'meta\\s+property="video:duration"\\s+content="(.*?)"', false);
  2841. if (blipVideoDuration) blipVideoDuration = parseInt(blipVideoDuration);
  2842.  
  2843. /* Get Videos Content */
  2844. var blipVideosContent = (blipVideoInfo) ? blipVideoInfo.match(/"additionalMedia":\[(.*?)\]/) : null;
  2845. blipVideosContent = (blipVideosContent) ? blipVideosContent[1] : null;
  2846.  
  2847. /* My Player Window */
  2848. var myPlayerWindow = createMyElement ('div', '', '', '', '');
  2849. styleMyElement (myPlayerWindow, {position: 'relative', width: blipPlayerWidth + 'px', height: blipPlayerHeight + 'px', backgroundColor: '#F4F4F4'});
  2850. modifyMyElement (blipPlayerWindow, 'div', '', true);
  2851. styleMyElement (blipPlayerWindow, {paddingTop: '0px'});
  2852. appendMyElement (blipPlayerWindow, myPlayerWindow);
  2853. var blipHeader = getMyElement ('', 'div', 'id', 'Header', -1, false);
  2854. styleMyElement (blipHeader , {zIndex: '0'});
  2855.  
  2856. /* Get Videos */
  2857. if (blipVideosContent) {
  2858. var blipVideoList = {};
  2859. var blipVideoFound = false;
  2860. var blipMimeTypes = {'video/x-m4v': 'M4V', 'video/quicktime': 'MOV', 'video/mp4': 'MP4', 'video/x-flv': 'FLV'};
  2861. var blipVideos = blipVideosContent.split(',{');
  2862. var blipVideoURL, blipVideoMime, blipVideoHeight, blipVideoRole, blipVideoDef, blipVideoCode;
  2863. var blipDefaultVideo = 'Low Definition MP4';
  2864. for (var blipV = 0; blipV < blipVideos.length; blipV++) {
  2865. blipVideoMime = blipVideos[blipV].match(/"primary_mime_type":"(.*?)"/);
  2866. blipVideoMime = (blipVideoMime) ? blipVideoMime[1] : null;
  2867. if (blipMimeTypes[blipVideoMime]) {
  2868. blipVideoURL = blipVideos[blipV].match(/"url":"(.*?)"/);
  2869. blipVideoURL = (blipVideoURL) ? blipVideoURL[1] : null;
  2870. blipVideoHeight = blipVideos[blipV].match(/"media_height":"(.*?)"/);
  2871. blipVideoHeight = (blipVideoHeight) ? blipVideoHeight[1] : null;
  2872. blipVideoRole = blipVideos[blipV].match(/"role":"(.*?)"/);
  2873. blipVideoRole = (blipVideoRole) ? blipVideoRole[1] : null;
  2874. if (blipVideoURL && blipVideoHeight && blipVideoRole) {
  2875. if (!blipVideoFound) blipVideoFound = true;
  2876. if (blipVideoHeight >= 200 && blipVideoHeight < 400) blipVideoDef = 'Low Definition';
  2877. else if (blipVideoHeight >= 400 && blipVideoHeight < 700) blipVideoDef = 'Standard Definition';
  2878. else if (blipVideoHeight >= 700) blipVideoDef = 'High Definition';
  2879. blipVideoCode = blipVideoDef + ' ' + blipMimeTypes[blipVideoMime];
  2880. blipVideoList[blipVideoCode] = blipVideoURL;
  2881. if (blipVideoRole == 'Source') blipDefaultVideo = blipVideoCode;
  2882. }
  2883. }
  2884. }
  2885.  
  2886. if (blipVideoFound) {
  2887. /* Create Player */
  2888. var player = {
  2889. 'playerSocket': blipPlayerWindow,
  2890. 'playerWindow': myPlayerWindow,
  2891. 'videoList': blipVideoList,
  2892. 'videoPlay': blipDefaultVideo,
  2893. 'videoThumb': blipVideoThumb,
  2894. 'videoDuration': blipVideoDuration,
  2895. 'playerWidth': blipPlayerWidth,
  2896. 'playerHeight': blipPlayerHeight
  2897. };
  2898. feature['widesize'] = false;
  2899. option['definitions'] = ['High Definition', 'Standard Definition', 'Low Definition'];
  2900. option['containers'] = ['MP4', 'M4V', 'MOV', 'FLV', 'Any'];
  2901. createMyPlayer (player);
  2902. }
  2903. else {
  2904. showMyMessage ('!videos');
  2905. }
  2906. }
  2907. else {
  2908. showMyMessage ('!content');
  2909. }
  2910. }
  2911. }
  2912.  
  2913. // =====Veoh===== //
  2914. else if (page.url.indexOf('veoh.com/watch') != -1) {
  2915.  
  2916. /* Get Video Availability */
  2917. if (getMyElement ('', 'div', 'class', 'veoh-video-player-error', 0, false)) return;
  2918. /* Get Player Window */
  2919. var vePlayerWindow = getMyElement ('', 'div', 'id', 'videoPlayerContainer', -1, false);
  2920. if (!vePlayerWindow) {
  2921. showMyMessage ('!player');
  2922. }
  2923. else {
  2924. /* Get Videos Content */
  2925. var veVideosContent = getMyContent (page.url, '__watch.videoDetailsJSON = \'\\{(.*?)\\}\'', false);
  2926. veVideosContent = cleanMyContent (veVideosContent, true);
  2927.  
  2928. /* Get Video Thumbnail */
  2929. var veVideoThumbGet = veVideosContent.match (/"highResImage":"(.*?)"/);
  2930. var veVideoThumb = (veVideoThumbGet) ? veVideoThumbGet[1] : null;
  2931. var veVideoDuration = getMyContent (page.url, 'meta\\s+name="item-duration"\\s+content="(.*?)"', false);
  2932. if (veVideoDuration) veVideoDuration = parseInt(veVideoDuration);
  2933.  
  2934. /* My Player Window */
  2935. var myPlayerWindow = createMyElement ('div', '', '', '', '');
  2936. styleMyElement (myPlayerWindow, {position: 'relative', width: '640px', height: '382px', backgroundColor: '#F4F4F4', zIndex: '99999'});
  2937. modifyMyElement (vePlayerWindow, 'div', '', true);
  2938. styleMyElement (vePlayerWindow, {height: '100%'});
  2939. appendMyElement (vePlayerWindow, myPlayerWindow);
  2940.  
  2941. /* Get Videos */
  2942. if (veVideosContent) {
  2943. var veVideoFormats = {'fullPreviewHashLowPath': 'Very Low Definition MP4', 'fullPreviewHashHighPath': 'Low Definition MP4'};
  2944. var veVideoList = {};
  2945. var veVideoFound = false;
  2946. var veVideoParser, veVideoParse, veVideo, myVideoCode;
  2947. for (var veVideoCode in veVideoFormats) {
  2948. veVideoParser = veVideoCode + '":"(.*?)"';
  2949. veVideoParse = veVideosContent.match (veVideoParser);
  2950. veVideo = (veVideoParse) ? veVideoParse[1] : null;
  2951. if (veVideo) {
  2952. if (!veVideoFound) veVideoFound = true;
  2953. myVideoCode = veVideoFormats[veVideoCode];
  2954. veVideoList[myVideoCode] = veVideo;
  2955. }
  2956. }
  2957.  
  2958. if (veVideoFound) {
  2959. /* Get Watch Sidebar */
  2960. var veSidebarWindow = getMyElement ('', 'div', 'id', 'videoToolsContainer', -1, false);
  2961. if (veSidebarWindow) styleMyElement(veSidebarWindow, {marginTop: '-380px'});
  2962.  
  2963. /* Create Player */
  2964. var veDefaultVideo = 'Low Definition MP4';
  2965. var player = {
  2966. 'playerSocket': vePlayerWindow,
  2967. 'playerWindow': myPlayerWindow,
  2968. 'videoList': veVideoList,
  2969. 'videoPlay': veDefaultVideo,
  2970. 'videoThumb': veVideoThumb,
  2971. 'videoDuration': veVideoDuration,
  2972. 'playerWidth': 640,
  2973. 'playerHeight': 382,
  2974. 'playerWideWidth': 970,
  2975. 'playerWideHeight': 568,
  2976. 'sidebarWindow': veSidebarWindow,
  2977. 'sidebarMarginNormal': -380,
  2978. 'sidebarMarginWide': 20
  2979. };
  2980. feature['container'] = false;
  2981. option['definition'] = 'LD';
  2982. option['definitions'] = ['Low Definition', 'Very Low Definition'];
  2983. option['containers'] = ['MP4'];
  2984. createMyPlayer (player);
  2985. }
  2986. else {
  2987. var veVideoSource = getMyContent(page.url, '"videoContentSource":"(.*?)"', false);
  2988. if (veVideoSource == 'YouTube') var ytVideoId = getMyContent(page.url, '"videoId":"yapi-(.*?)"', false);
  2989. if (ytVideoId) {
  2990. var ytVideoLink = 'http://youtube.com/watch?v=' + ytVideoId;
  2991. showMyMessage ('embed', ytVideoLink);
  2992. }
  2993. else {
  2994. showMyMessage ('!videos');
  2995. }
  2996. }
  2997. }
  2998. else {
  2999. showMyMessage ('!content');
  3000. }
  3001. }
  3002.  
  3003. }
  3004.  
  3005. // =====Viki===== //
  3006. else if (page.url.indexOf('viki.com/videos') != -1) {
  3007.  
  3008. /* Get Player Window */
  3009. var vkPlayerWindow = getMyElement ('', 'div', 'id', 'viki-player', -1, false);
  3010. if (!vkPlayerWindow) {
  3011. showMyMessage ('!player');
  3012. }
  3013. else {
  3014. /* Get Video ID */
  3015. var vkVideoID = page.url.match(/videos\/(.*?)v/);
  3016. vkVideoID = (vkVideoID) ? vkVideoID[1] : null;
  3017.  
  3018. /* Get Videos Content */
  3019. var vkVideosContent;
  3020. if (vkVideoID) vkVideosContent = getMyContent (page.win.location.protocol + '//' + page.win.location.host + '/player5_fragment/' + vkVideoID + 'v.json', 'TEXT', false);
  3021. var vkVideoDuration = getMyContent(page.url, '"duration":(.*?),', false);
  3022. /* My Player Window */
  3023. var myPlayerWindow = createMyElement ('div', '', '', '', '');
  3024. styleMyElement (myPlayerWindow, {position: 'relative', width: '950px', height: '556px', backgroundColor: '#F4F4F4'});
  3025. modifyMyElement (vkPlayerWindow, 'div', '',false, true);
  3026. appendMyElement (vkPlayerWindow, myPlayerWindow);
  3027. blockObject = vkPlayerWindow;
  3028. blockInterval = 20;
  3029.  
  3030. /* Get Videos */
  3031. if (vkVideosContent) {
  3032. var vkVideoList = {};
  3033. var vkVideo = vkVideosContent.match(/"video_url":"(.*?)"/);
  3034. vkVideo = (vkVideo) ? vkVideo[1] : null;
  3035. var vkVideoThumb = vkVideosContent.match(/"image_url":"(.*?)"/);
  3036. vkVideoThumb = (vkVideoThumb) ? vkVideoThumb[1] : null;
  3037. /* Create Player */
  3038. if (vkVideo) {
  3039. var vkDefaultVideo = 'Low Definition MP4';
  3040. vkVideoList[vkDefaultVideo] = vkVideo
  3041. var player = {
  3042. 'playerSocket': vkPlayerWindow,
  3043. 'playerWindow': myPlayerWindow,
  3044. 'videoList': vkVideoList,
  3045. 'videoPlay': vkDefaultVideo,
  3046. 'videoDuration': vkVideoDuration,
  3047. 'videoThumb': vkVideoThumb,
  3048. 'playerWidth': 950,
  3049. 'playerHeight': 556
  3050. };
  3051. feature['definition'] = false;
  3052. feature['container'] = false;
  3053. feature['widesize'] = false;
  3054. option['definition'] = 'LD';
  3055. option['definitions'] = ['Low Definition'];
  3056. option['containers'] = ['MP4'];
  3057. createMyPlayer (player);
  3058. }
  3059. else {
  3060. showMyMessage ('!videos');
  3061. }
  3062. }
  3063. else {
  3064. showMyMessage ('!content');
  3065. }
  3066. }
  3067.  
  3068. }
  3069.  
  3070. // =====IMDB===== //
  3071. /* Redirect To imdb.com */
  3072. else if (page.url.indexOf('imdb.org') !== -1) window.location.href = page.win.location.href.replace(/imdb\.org/, 'imdb.com');
  3073. else if (page.url.indexOf('imdb.com/video') != -1) {
  3074. function imdb_run(imdb_PlayerId) {
  3075. /* Get Player Window */
  3076. var imdbPlayerWindow = getMyElement ('', 'div', 'id', 'player-article', -1, false);
  3077. if (imdbPlayerWindow) {
  3078. var imdbPlayerWidth = 670;
  3079. var imdbPlayerHeight = 398;
  3080. } else {
  3081. imdbPlayerWindow = getMyElement ('', 'div', 'class', 'video-player vp-full', 0, false);
  3082. // var imdbPlayerWidth = 854;
  3083. var imdbPlayerWidth = imdbPlayerWindow.clientWidth;
  3084. var imdbPlayerHeight = imdbPlayerWindow.clientHeight;
  3085. if (imdbPlayerHeight < 340) imdbPlayerHeight = 340;
  3086. }
  3087. if (!imdbPlayerWindow) {
  3088. // return
  3089. showMyMessage ('!player');
  3090. }
  3091. else {
  3092. imdbVideoID = getMyContent (page.url, '"viconst":"(.*?)"', false);
  3093. if (!imdbVideoID) {
  3094. imdbVideoID = page.url.match(/vi\d{5,}/);
  3095. if (imdbVideoID) imdbVideoID = imdbVideoID[0]; else imdbVideoID = getMyContent (page.url, '"viconst":"(.*?)"', true);
  3096. }
  3097. /* My Player Window */
  3098. var myPlayerWindow = createMyElement ('div', '', '', '', '');
  3099. var imdbPlayerElement = getMyElement ('', 'div', 'id', 'imdb-video', -1, false)
  3100. if (imdbPlayerElement) cleanMyElement(imdbPlayerElement, true);
  3101. styleMyElement (myPlayerWindow, {position: 'relative', width: imdbPlayerWidth + 'px', height: imdbPlayerHeight + 'px', backgroundColor: '#F4F4F4'});
  3102. modifyMyElement (imdbPlayerWindow, 'div', '', true);
  3103. appendMyElement (imdbPlayerWindow, myPlayerWindow);
  3104.  
  3105. /* Get Videos Content */
  3106. var imdbVideoList = {};
  3107. var imdbVideoFormats = {'1': 'Low Definition MP4', '2': 'Standard Definition MP4', '3': 'High Definition MP4'};
  3108. var imdbVideoThumb, imdbDefaultVideo, imdbURL, imdbVideo, myVideoCode;
  3109. var imdbVideoFound = false;
  3110. var imdbVideoRTMP = false;
  3111. for (var imdbVideoCode in imdbVideoFormats) {
  3112. imdbURL = page.win.location.protocol + '//' + page.win.location.hostname + '/video/imdb/' + imdbVideoID + '/player?uff=' + imdbVideoCode;
  3113. imdbVideo = getMyContent (imdbURL, 'so.addVariable\\("file",\\s+"(.*?)"\\);', true);
  3114. if (!imdbVideoThumb) imdbVideoThumb = getMyContent (imdbURL, 'so.addVariable\\("image",\\s+"(.*?)"\\);', true);
  3115. if (imdbVideo) {
  3116. if (imdbVideo.indexOf('rtmp') != -1) {
  3117. if (!imdbVideoRTMP) imdbVideoRTMP = true;
  3118. } else {
  3119. if (!imdbVideoFound) imdbVideoFound = true;
  3120. myVideoCode = imdbVideoFormats[imdbVideoCode];
  3121. imdbVideoList[myVideoCode] = imdbVideo;
  3122. if (!imdbDefaultVideo) imdbDefaultVideo = myVideoCode;
  3123. }
  3124. }
  3125. }
  3126.  
  3127. if (imdbVideoFound) {
  3128. /* Get Watch Sidebar */
  3129. var imdbSidebarWindow = getMyElement ('', 'div', 'id', 'sidebar', -1, false);
  3130. if (imdbSidebarWindow) styleMyElement (imdbSidebarWindow, {marginTop: '-400px'});
  3131. /* Create Player */
  3132. var player = {
  3133. 'playerSocket': imdbPlayerWindow,
  3134. 'playerWindow': myPlayerWindow,
  3135. 'videoList': imdbVideoList,
  3136. 'videoPlay': imdbDefaultVideo,
  3137. 'videoThumb': imdbVideoThumb,
  3138. 'playerWidth': imdbPlayerWidth,
  3139. 'playerHeight': imdbPlayerHeight,
  3140. 'playerWideWidth': 1010,
  3141. 'playerWideHeight': 592,
  3142. 'sidebarWindow': imdbSidebarWindow,
  3143. 'sidebarMarginNormal': -400,
  3144. 'sidebarMarginWide': 0
  3145. };
  3146. feature['container'] = false;
  3147. option['definitions'] = ['High Definition', 'Standard Definition', 'Low Definition'];
  3148. option['containers'] = ['MP4'];
  3149. createMyPlayer (player);
  3150. }
  3151. else {
  3152. if (imdbVideoRTMP) showMyMessage ('!support');
  3153. else showMyMessage ('!videos');
  3154. }
  3155. }
  3156. }
  3157. function onNodeInserted(e) {
  3158. if (e && e.target && (typeof e.target.id !== 'undefined') && e.target.id == 'imdb-video-player') {
  3159. setTimeout(function() { imdb_run(); }, 0);
  3160. }
  3161. }
  3162.  
  3163. if (page.url.indexOf('video/playlist') == -1) imdb_run();
  3164. else {
  3165. var content = getMyElement ('', 'body', '', '', -1, false);
  3166. if (content) {
  3167. var mo=window.MutationObserver||window.MozMutationObserver||window.WebKitMutationObserver;
  3168. if(typeof mo!=='undefined') {
  3169. var observer=new mo(function(mutations) {
  3170. mutations.forEach(function(mutation) {
  3171. if(mutation.addedNodes!==null && mutation.addedNodes.length > 0) {
  3172. for (var i=0; i<mutation.addedNodes.length; i++) {
  3173. if ((typeof mutation.addedNodes[i].id !== 'undefined') && (mutation.addedNodes[i].id == 'imdb-video-player')) {
  3174. imdb_run(mutation.addedNodes);
  3175. break;
  3176. }
  3177. }
  3178. }
  3179. });
  3180. });
  3181. observer.observe(content, {childList: true, subtree: true, characterData:true});
  3182. } else { // MutationObserver fallback for old browsers
  3183. content.parentNode.addEventListener('DOMNodeInserted', onNodeInserted, true);
  3184. }
  3185. }
  3186. }
  3187. }
  3188.  
  3189. // =====Crackle===== //
  3190. else if (page.url.indexOf('crackle.com/') != -1) {
  3191. /* Get Page Type */
  3192. var crPageType = getMyContent (page.url, 'meta\\s+property="og:type"\\s+content="(.*?)"', false);
  3193. if (!crPageType || crPageType.indexOf('video') == -1) return;
  3194. /* Get Player Window */
  3195. var crPlayerWindow = getMyElement ('', 'div', 'id', 'main', -1, false);
  3196. if (!crPlayerWindow) {
  3197. showMyMessage ('!player');
  3198. }
  3199. else {
  3200. /* Get Videos Content */
  3201. var crVideoPath = getMyContent (page.url, 'images-us-am.crackle.com\/(.*?_)tnl', false);
  3202. if (!crVideoPath) {
  3203. var crVideoID = getMyContent (page.url, 'mediaId:\\s*(.*?),', false);
  3204. if (crVideoID) {
  3205. var crVidWallCache = page.win.location.protocol + '//' + page.win.location.hostname + '/app/vidwallcache.aspx?flags=-1&fm=' + crVideoID + '&partner=20';
  3206. crVideoPath = getMyContent (crVidWallCache, '\\sp="(.*?)"', false);
  3207. }
  3208. }
  3209.  
  3210. var crVideoDuration = parseInt(getMyContent (page.url, 'endTime:(.*?),', false));
  3211.  
  3212. /* My Player Window */
  3213. var myPlayerWindow = createMyElement ('div', '', '', '', '');
  3214. styleMyElement (myPlayerWindow, {position: 'relative', width: '970px', height: '570px', backgroundColor: '#F4F4F4'});
  3215. modifyMyElement (crPlayerWindow, 'div', '', true);
  3216. styleMyElement (crPlayerWindow, {width: '970px', height: '600px', backgroundColor: '#FFFFFF'});
  3217. appendMyElement (crPlayerWindow, myPlayerWindow);
  3218. /* Get Videos */
  3219. if (crVideoPath) {
  3220. var crVideoList = {};
  3221. var crVideoFormats = {'360p.mp4': 'Low Definition MP4', '480p.mp4': 'Standard Definition MP4'};
  3222. var crVideoThumb, crVideo, myVideoCode;
  3223. for (var crVideoCode in crVideoFormats) {
  3224. crVideo = 'http://media-us-am.crackle.com/' + crVideoPath + crVideoCode;
  3225. myVideoCode = crVideoFormats[crVideoCode];
  3226. crVideoList[myVideoCode] = crVideo;
  3227. }
  3228. crVideoThumb = 'http://images-us-am.crackle.com/' + crVideoPath + 'tnl.jpg';
  3229.  
  3230. /* Create Player */
  3231. var crDefaultVideo = 'Low Definition MP4';
  3232. var player = {
  3233. 'playerSocket': crPlayerWindow,
  3234. 'playerWindow': myPlayerWindow,
  3235. 'videoList': crVideoList,
  3236. 'videoPlay': crDefaultVideo,
  3237. 'videoThumb': crVideoThumb,
  3238. 'videoDuration': crVideoDuration,
  3239. 'playerWidth': 970,
  3240. 'playerHeight': 570
  3241. };
  3242. feature['container'] = false;
  3243. feature['widesize'] = false;
  3244. option['definition'] = 'SD';
  3245. option['definitions'] = ['Standard Definition', 'Low Definition'];
  3246. option['containers'] = ['MP4'];
  3247. createMyPlayer (player);
  3248. /* Fix Thumbnails */
  3249. var crThumbs = getMyElement('', 'div', 'class', 'thumbnail', -1, false);
  3250. for (var crT = 0; crT < crThumbs.length; crT++) {
  3251. if (crThumbs[crT].innerHTML.indexOf('AddObjectToQueue') != -1) {
  3252. var crLink = crThumbs[crT].innerHTML.match(/,\s+\d+,\s+'(.*?)'/);
  3253. crLink = (crLink) ? crLink[1] : null;
  3254. var crImg = crThumbs[crT].innerHTML.match(/src="(.*?)"/);
  3255. crImg = (crImg) ? crImg[1] : null;
  3256. crThumbs[crT].innerHTML = '<img src="' + crImg + '" onclick="window.location.href=\'' + crLink + '\'" style="cursor:pointer">';
  3257. }
  3258. }
  3259. }
  3260. else {
  3261. showMyMessage ('!videos');
  3262. }
  3263. }
  3264. }
  3265.  
  3266. // =====Facebook===== //
  3267. else if (page.url.match('facebook.com/(video.php|.*/videos/)')) {
  3268. /* Get Player Window */
  3269. var fbPlayerWindow = getMyElement ('', 'div', 'class', 'stageWrapper', 0, false);
  3270. if (!fbPlayerWindow) {
  3271. showMyMessage ('!player');
  3272. }
  3273. else {
  3274. /* Get Videos Content */
  3275. var fbVideosContent = getMyContent(page.url, '"params","(.*?)"', false);
  3276. var fbPattern = /\\u([\d\w]{4})/gi;
  3277. fbVideosContent = fbVideosContent.replace(fbPattern, function (match, group) {
  3278. return String.fromCharCode(parseInt(group, 16));
  3279. });
  3280. fbVideosContent = unescape(fbVideosContent);
  3281.  
  3282. /* My Player Window */
  3283. var myPlayerWindow = createMyElement ('div', '', '', '', '');
  3284. styleMyElement (myPlayerWindow, {position: 'relative', width: '720px', height: '428px', backgroundColor: '#F4F4F4'});
  3285. modifyMyElement (fbPlayerWindow, 'div', '', true);
  3286. appendMyElement (fbPlayerWindow, myPlayerWindow);
  3287. /* Get Videos */
  3288. if (fbVideosContent) {
  3289. var fbVideoDuration = fbVideosContent.match(/duration":(.*?),/);
  3290. if (fbVideoDuration) fbVideoDuration = parseInt(fbVideoDuration[1]);
  3291. var fbVideoList = {};
  3292. var fbVideoFormats = {'sd_src': 'Low Definition MP4', 'hd_src': 'High Definition MP4'};
  3293. var fbVideoFound = false;
  3294. var fbVideoPattern, fbVideo, myVideoCode, fbVideoThumb, fbDefaultVideo;
  3295. for (var fbVideoCode in fbVideoFormats) {
  3296. fbVideoPattern = '"' + fbVideoCode + '":"(.*?)"';
  3297. fbVideo = fbVideosContent.match(fbVideoPattern);
  3298. fbVideo = (fbVideo) ? fbVideo[1] : null;
  3299. if (fbVideo) {
  3300. fbVideo = cleanMyContent(fbVideo, false);
  3301. if (!fbVideoFound) fbVideoFound = true;
  3302. myVideoCode = fbVideoFormats[fbVideoCode];
  3303. if (fbVideo.indexOf('.flv') != -1) myVideoCode = myVideoCode.replace('MP4', 'FLV');
  3304. fbVideoList[myVideoCode] = fbVideo;
  3305. if (!fbDefaultVideo) fbDefaultVideo = myVideoCode;
  3306. }
  3307. fbVideoThumb = fbVideosContent.match(/"thumbnail_src":"(.*?)"/);
  3308. fbVideoThumb = (fbVideoThumb) ? fbVideoThumb[1] : null;
  3309. if (fbVideoThumb) fbVideoThumb = cleanMyContent(fbVideoThumb, false);
  3310. else fbVideoThumb = 'https://www.facebook.com/images/fb_icon_325x325.png';
  3311. }
  3312. if (fbVideoFound) {
  3313. /* Create Player */
  3314. var player = {
  3315. 'playerSocket': fbPlayerWindow,
  3316. 'playerWindow': myPlayerWindow,
  3317. 'videoList': fbVideoList,
  3318. 'videoPlay': fbDefaultVideo,
  3319. 'videoThumb': fbVideoThumb,
  3320. 'videoDuration': fbVideoDuration,
  3321. 'playerWidth': 720,
  3322. 'playerHeight': 428
  3323. };
  3324. feature['widesize'] = false;
  3325. option['definitions'] = ['High Definition', 'Low Definition'];
  3326. option['containers'] = ['MP4', 'FLV', 'Any'];
  3327. HeadWindow = getMyElement('', 'div', 'id', 'blueBarNAXAnchor', -1, false);
  3328. createMyPlayer (player);
  3329. }
  3330. else {
  3331. showMyMessage ('!videos');
  3332. }
  3333. }
  3334. else {
  3335. showMyMessage ('!content');
  3336. }
  3337. }
  3338. }
  3339.  
  3340. // =====YahooScreen===== //
  3341. else if (page.url.indexOf('screen.yahoo.com') != -1) {
  3342. /* Get Player Window */
  3343. var ysPlayerWindow = getMyElement ('', 'div', 'id', 'ym-player', -1, false);
  3344. if (ysPlayerWindow) ysPlayerWindow = ysPlayerWindow.parentNode;
  3345. if (!ysPlayerWindow) {
  3346. showMyMessage ('!player');
  3347. }
  3348. else {
  3349. /* Get Videos Content */
  3350. var ysVideosContent;
  3351. var ysVideoID = getMyContent (page.url, '"data":{"sapi":{"id":"(.*?)"', false);
  3352. if (!ysVideoID) ysVideoID = getMyContent (page.url, '"first_videoid":"(.*?)"', false);
  3353.  
  3354. if (ysVideoID) ysVideosContent = getMyContent('https://video.media.yql.yahoo.com/v1/video/sapi/streams/' + ysVideoID + '?protocol=http&region=US', '"streams":\\[(.*?)\\]', false);
  3355. /* Get Video Thumbnail */
  3356. var ysVideoThumb = getMyContent(page.url, '"thumbnails":\\[{"tag":"original","url":"(.*?)"', false);
  3357. if (!ysVideoThumb) ysVideoThumb = getMyContent (page.url, 'meta\\s+property="og:image"\\s+content="(.*?)"', false);
  3358. var ysVideoDuration = getMyContent(page.url, '"duration":(.*?),', false);
  3359.  
  3360. /* My Player Window */
  3361. var myPlayerWindow = createMyElement ('div', '', '', '', '');
  3362. var ysPlayerWidth = ysPlayerWindow.offsetWidth;
  3363. var ysPlayerHeight = ysPlayerWindow.offsetHeight - 6;
  3364. if (ysPlayerHeight <= 300) { ysPlayerWidth = 604; ysPlayerHeight = 340 }
  3365. styleMyElement (myPlayerWindow, {position: 'relative', width: ysPlayerWidth + 'px', height: ysPlayerHeight+ 'px', backgroundColor: '#F4F4F4', margin: '0px auto'});
  3366. modifyMyElement (ysPlayerWindow, 'div', '', true);
  3367. appendMyElement (ysPlayerWindow, myPlayerWindow);
  3368. /* Get Videos */
  3369. if (ysVideosContent) {
  3370. var ysVideoList = {};
  3371. var ysVideoFound = false;
  3372. var ysVideoFormats = {'240': 'Very Low Definition', '360': 'Low Definition', '432': 'Low Definition', '540': 'Standard Definition', '720': 'High Definition', '1080': 'Full High Definition'};
  3373. var ysVideoParts = ysVideosContent.split('},');
  3374. var ysVideoPart, ysVideoPath, ysVideoHost, ysVideoHeight, ysVideoType, myVideoCode;
  3375. for (var i = 0; i < ysVideoParts.length; i++) {
  3376. ysVideoPart = ysVideoParts[i];
  3377. ysVideoPath = ysVideoPart.match(/"path":"(.*?)"/);
  3378. ysVideoPath = (ysVideoPath) ? ysVideoPath[1] : null;
  3379. ysVideoHost = ysVideoPart.match(/"host":"(.*?)"/);
  3380. ysVideoHost = (ysVideoHost) ? ysVideoHost[1] : null;
  3381. ysVideoHeight = ysVideoPart.match(/"height":(\d+),/);
  3382. ysVideoHeight = (ysVideoHeight) ? ysVideoHeight[1].replace('.0','') : null;
  3383. ysVideoType = ysVideoPart.match(/"mime_type":"(.*?)"/);
  3384. ysVideoType = (ysVideoType) ? ysVideoType[1] : null;
  3385. if (ysVideoPath && ysVideoHost && ysVideoHeight && ysVideoType) {
  3386. for (var ysVideoCode in ysVideoFormats) {
  3387. if (ysVideoCode == ysVideoHeight) {
  3388. if (!ysVideoFound) ysVideoFound = true;
  3389. myVideoCode = ysVideoFormats[ysVideoCode]
  3390. if (ysVideoType == 'video/mp4') myVideoCode += ' MP4';
  3391. else if (ysVideoType == 'video/webm') myVideoCode += ' WebM';
  3392. ysVideoList[myVideoCode] = ysVideoHost + ysVideoPath;
  3393. }
  3394. }
  3395. }
  3396. }
  3397. if (ysVideoFound) {
  3398. /* Create Player */
  3399. var ysDefaultVideo = 'Low Definition MP4';
  3400. var player = {
  3401. 'playerSocket': ysPlayerWindow,
  3402. 'playerWindow': myPlayerWindow,
  3403. 'videoList': ysVideoList,
  3404. 'videoPlay': ysDefaultVideo,
  3405. 'videoThumb': ysVideoThumb,
  3406. 'videoDuration': ysVideoDuration,
  3407. 'playerWidth': ysPlayerWidth,
  3408. 'playerHeight': ysPlayerHeight
  3409. };
  3410. feature['widesize'] = false;
  3411. option['definitions'] = ['Full High Definition', 'High Definition', 'Standard Definition', 'Low Definition', 'Very Low Definition'];
  3412. option['containers'] = ['MP4', 'WebM', 'Any'];
  3413. HeadWindow = getMyElement ('', 'div', 'id', 'yucsHead', -1, false);
  3414. createMyPlayer (player);
  3415. styleMyElement(player['playerContent'], {marginTop: '5px'});
  3416. }
  3417. else {
  3418. showMyMessage ('!videos');
  3419. }
  3420. }
  3421. else {
  3422. showMyMessage ('!content');
  3423. }
  3424. }
  3425. }
  3426.  
  3427. })();