ViewTube_GM

Watch videos from video sharing websites without Flash Player.

目前为 2016-01-07 提交的版本,查看 最新版本

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