ViewTube_GM

Watch videos from video sharing websites without Flash Player.

目前为 2015-02-10 提交的版本,查看 最新版本

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