ViewTube_GM

Watch videos from video sharing websites without Flash Player.

当前为 2015-07-30 提交的版本,查看 最新版本

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