ViewTube_GM

Watch videos from video sharing websites without Flash Player.

当前为 2015-04-17 提交的版本,查看 最新版本

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