ViewTube_GM

Watch videos from video sharing websites without Flash Player.

当前为 2016-03-20 提交的版本,查看 最新版本

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