ViewTube_GM

Watch videos from video sharing websites without Flash Player.

目前为 2015-08-21 提交的版本。查看 最新版本

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