ViewTube_GM

Watch videos from video sharing websites without Flash Player.

当前为 2014-07-18 提交的版本,查看 最新版本

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