ViewTube_GM

Watch videos from video sharing websites without Flash Player.

当前为 2014-09-23 提交的版本,查看 最新版本

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