- // ==UserScript==
- // @name ViewTube_GM
- // @version 2015.08.21
- // @description Watch videos from video sharing websites without Flash Player.
- // @author trupf
- // @namespace https://userscripts.org/users/trupf
- // @icon http://s3.amazonaws.com/uso_ss/icon/87011/large.png
- // @_require https://raw.github.com/Dash-Industry-Forum/dash.js/v1.1.2/dash.all.js
- // @include http://youtube.com*
- // @include http://www.youtube.com*
- // @include https://youtube.com*
- // @include https://www.youtube.com*
- // @include http://dailymotion.com*
- // @include http://www.dailymotion.com*
- // @include https://dailymotion.com*
- // @include https://www.dailymotion.com*
- // @include http://vimeo.com*
- // @include http://www.vimeo.com*
- // @include https://vimeo.com*
- // @include https://www.vimeo.com*
- // @include http://metacafe.com*
- // @include http://www.metacafe.com*
- // @include https://metacafe.com*
- // @include https://www.metacafe.com*
- // @include http://break.com*
- // @include http://www.break.com*
- // @include https://break.com*
- // @include https://www.break.com*
- // @include http://funnyordie.com*
- // @include http://www.funnyordie.com*
- // @include https://funnyordie.com*
- // @include https://www.funnyordie.com*
- // @include http://videojug.com*
- // @include http://www.videojug.com*
- // @include https://videojug.com*
- // @include https://www.videojug.com*
- // @include http://blip.tv*
- // @include http://www.blip.tv*
- // @include https://blip.tv*
- // @include https://www.blip.tv*
- // @include http://veoh.com*
- // @include http://www.veoh.com*
- // @include https://veoh.com*
- // @include https://www.veoh.com*
- // @include http://www.imdb.org/*
- // @include http://www.imdb.com/video*
- // @include https://www.imdb.com/video*
- // @include http://crackle.com*
- // @include http://www.crackle.com*
- // @include https://crackle.com*
- // @include https://www.crackle.com*
- // @include http://viki.com*
- // @include http://www.viki.com*
- // @include https://viki.com*
- // @include https://www.viki.com*
- // @include http://vevo.com*
- // @include http://www.vevo.com*
- // @include https://vevo.com*
- // @include https://www.vevo.com*
- // @include http://facebook.com*
- // @include http://www.facebook.com*
- // @include https://facebook.com*
- // @include https://www.facebook.com*
- // @include https://screen.yahoo.com*
- // @license GPLv3
- // @grant GM_xmlhttpRequest
- // @grant GM_setValue
- // @grant GM_getValue
- // @grant GM_log
- // @grant unsafeWindow
- // @run-at document-end
-
- // ==/UserScript==
-
-
- /*
-
- Copyright (C) 2010 - 2014 Tobias Rupf
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- This Program is mainly based on the work of Sebastian Luncan
- (Website: http://isebaro.com/viewtube)
-
- Youtube Signature decryption and mutation observers by Gantt.
- (see http://userscripts.org/scripts/show/25105)
-
- */
-
- (function() {
-
- // ==========Variables========== //
-
- // Userscript
- var userscript = 'ViewTube_GM';
-
- // Page
- var page = {win: window, doc: document, body: document.body, url: window.location.href};
- var dashplayer;
-
- // Player
- //var player = {};
- var myPlayerWindow, HeadWindow, OrgHeadWindowIndex;
- var feature = {'autoplay': true, 'definition': true, 'container': true, 'dash': false, 'direct': false, 'widesize': true, 'fullsize': true};
- var plugins = ['HTML5'];
- if ((navigator.appVersion.indexOf('Chrome/') == -1) || (parseInt(navigator.appVersion.substr(navigator.appVersion.indexOf('Chrome/')+7,2)) < 35)
- || ((navigator.platform.indexOf('Win') != -1) && (parseInt(navigator.appVersion.substr(navigator.appVersion.indexOf('Chrome/')+7,2)) < 45))) {
- plugins = ['Auto'].concat(plugins);
- plugins = plugins.concat(['MPEG', 'MP4', 'FLV', 'VLC']);
- if (navigator.platform.indexOf('Win') != -1) plugins = plugins.concat(['WMP', 'WMP2', 'QT']);
- else if (navigator.platform.indexOf('Mac') != -1) plugins = plugins.concat(['QT']);
- else plugins = plugins.concat(['Totem', 'Xine']);
- }
- var option = {'plugin': plugins[0], 'autoplay': false, 'autoget': false, 'definition': 'HD', 'container': 'MP4', 'widesize': false, 'fullsize': false};
- var mimetypes = {
- 'MPEG': 'video/mpeg',
- 'MP4': 'video/mp4',
- 'WebM': 'video/webm',
- 'FLV': 'video/x-flv',
- 'MOV': 'video/quicktime',
- 'M4V': 'video/x-m4v',
- 'AVI': 'video/x-msvideo',
- '3GP': 'video/3gpp',
- 'WMP': 'application/x-ms-wmp',
- 'WMP2': 'application/x-mplayer2',
- 'QT': 'video/quicktime',
- 'VLC': 'application/x-vlc-plugin',
- 'Totem': 'application/x-totem-plugin',
- 'Xine': 'application/x-xine-plugin'
- };
-
- // Links
- var website = 'https://greasyfork.org/de/scripts/1203-viewtube-gm';
- var contact = 'https://greasyfork.org/de/scripts/1203-viewtube-gm/feedback';
-
- // ==========Fixes========== //
-
- // Don't run on frames or iframes
- //if ((page.url.indexOf('imdb.com/') == -1) && (window.top != window.self)) return;
-
-
- // ==========Functions========== //
-
- function createVideoElement (type, content, player) {
- function createPlayerElement (type, content, player) {
- player['contentVideo'] = createMyElement (type, content,'','','',player);
- player['contentVideo'].width = player['contentWidth'];
- player['contentVideo'].height = player['contentHeight'];
- styleMyElement (player['contentVideo'], {position: 'relative', width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px'});
- modifyMyElement (player['playerContent'], 'div', '', true);
- appendMyElement (player['playerContent'], player['contentVideo']);
- if (type == 'video' && content == 'DASH') {
- }
- }
- setTimeout(function() { createPlayerElement(type, content, player); }, 0);
- }
-
- function createMyElement (type, content, event, action, target, player) {
- var obj = page.doc.createElement(type);
- if (content) {
- if (type == 'div') obj.innerHTML = content;
- else if (type == 'img') obj.src = content;
- else if (type == 'option') {
- obj.value = content;
- obj.innerHTML = content;
- }
- else if (type == 'video') {
- obj.controls = 'controls';
- obj.autoplay = 'autoplay';
- obj.volume = 0.5;
- 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>.';
- if (content != 'DASH') obj.src = content;
- }
- else if (type == 'object') {
- obj.data = content;
- obj.id = 'videoplayer';
- 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">';
- }
- else if (type == 'embed') {
- if (option['plugin'] == 'VLC') obj.setAttribute('target', content);
- else obj.src = content;
- obj.id = 'videoplayer';
- 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">';
- }
- }
- if (type == 'video' || type == 'object' || type == 'embed') {
- if (option['plugin'] == 'Auto' || option['plugin'] == 'Alt' || option['plugin'] == 'HTML5') {
- if (content == 'DASH') obj.type = 'application/dash+xml';
- else obj.type = mimetypes[player['videoPlay'].replace(/.*\s/, '')];
- }
- else {
- obj.type = mimetypes[option['plugin']];
- }
- obj.id = 'vtVideo';
- }
- if (event == 'change') {
- if (target == 'video') {
- obj.addEventListener ('change', function (e) {
- if (e.target) player['videoPlay'] = e.target.value;
- else if (e.srcElement) player['videoPlay'] = e.srcElement.value;
- if (player['isGetting']) {
- modifyMyElement (player['buttonGet'] , 'div', 'Get', false);
- player['isGetting'] = false;
- }
- if (player['isPlaying']) playMyVideo(player, option['autoplay']);
- }.bind(player), false);
- }
- else if (target == 'plugin') {
- obj.addEventListener ('change', function (e) {
- if (e.target) option['plugin'] = e.target.value;
- else if (e.srcElement) option['plugin'] = e.srcElement.value;
- setMyOptions ('viewtube_plugin', option['plugin']);
- if (player['isPlaying']) playMyVideo(player, true);
- }.bind(player), false);
- }
- }
- else if (event == 'click') {
- obj.addEventListener ('click', function () {
- if (action == 'close') {
- removeMyElement(page.body, target);
- }
- else if (action == 'logo') {
- page.win.location.href = website;
- }
- else if (action == 'play') {
- playMyVideo(player, !player['isPlaying']);
- }
- else if (action == 'get') {
- getMyVideo(player);
- }
- else if (action == 'autoplay') {
- option['autoplay'] = (option['autoplay']) ? false : true;
- if (option['autoplay']) {
- // styleMyElement (player['buttonPlay'], {display: 'none'});
- styleMyElement (player['buttonAutoplay'], {color: '#008080', textShadow: '0px 1px 1px #CCCCCC'});
- if (!player['isPlaying']) playMyVideo(player, true);
- }
- else {
- // styleMyElement (player['buttonPlay'], {display: 'inline'});
- styleMyElement (player['buttonAutoplay'], {color: '#CCCCCC', textShadow: '0px 0px 0px'});
- playMyVideo(player, false);
- }
- setMyOptions ('viewtube_autoplay', option['autoplay']);
- }
- else if (action == 'definition') {
- for (var itemDef = 0; itemDef < option['definitions'].length; itemDef++) {
- if (option['definitions'][itemDef].match(/[A-Z]/g).join('') == option['definition']) {
- var nextDef = (itemDef + 1 < option['definitions'].length) ? itemDef + 1 : 0;
- option['definition'] = option['definitions'][nextDef].match(/[A-Z]/g).join('');
- break;
- }
- }
- modifyMyElement (player['buttonDefinition'], 'div', option['definition'], false);
- setMyOptions ('viewtube_definition', option['definition']);
- if (player['isGetting']) {
- modifyMyElement (player['buttonGet'] , 'div', 'Get', false);
- player['isGetting'] = false;
- }
- selectMyVideo (player);
- if (player['isPlaying']) playMyVideo(player, true);
- }
- else if (action == 'container') {
- for (var itemCont = 0; itemCont < option['containers'].length; itemCont++) {
- if (option['containers'][itemCont] == option['container']) {
- var nextCont = (itemCont + 1 < option['containers'].length) ? itemCont + 1 : 0;
- option['container'] = option['containers'][nextCont];
- break;
- }
- }
- modifyMyElement (player['buttonContainer'], 'div', option['container'], false);
- setMyOptions ('viewtube_container', option['container']);
- if (player['isGetting']) {
- modifyMyElement (player['buttonGet'] , 'div', 'Get', false);
- player['isGetting'] = false;
- }
- selectMyVideo (player);
- if (player['isPlaying']) playMyVideo(player, true);
- }
- else if (action == 'widesize') {
- option['widesize'] = (option['widesize']) ? false : true;
- setMyOptions ('viewtube_widesize', option['widesize']);
- resizeMyPlayer(player, 'widesize');
- }
- else if (action == 'fullsize') {
- option['fullsize'] = (option['fullsize']) ? false : true;
- resizeMyPlayer(player, 'fullsize');
- }
- }.bind(player), false);
- }
- return obj;
- }
-
- function getMyElement (obj, type, from, value, child, content) {
- var getObj, chObj, coObj;
- var pObj = (!obj) ? page.doc : obj;
- if (type == 'body') getObj = pObj.body;
- else {
- if (from == 'id') getObj = pObj.getElementById(value);
- else if (from == 'class') getObj = pObj.getElementsByClassName(value);
- else if (from == 'tag') getObj = pObj.getElementsByTagName(type);
- else if (from == 'ns') getObj = pObj.getElementsByTagNameNS(value, type);
- }
- chObj = (child >= 0) ? getObj[child] : getObj;
- if (content && chObj) {
- if (type == 'html' || type == 'body' || type == 'div' || type == 'option') coObj = chObj.innerHTML;
- else if (type == 'object') coObj = chObj.data;
- else if (type == 'img' || type == 'video' || type == 'embed') coObj = chObj.src;
- else coObj = chObj.textContent;
- return coObj;
- }
- else {
- return chObj;
- }
- }
-
- function modifyMyElement (obj, type, content, clear, hide) {
- if (content) {
- if (type == 'div') obj.innerHTML = content;
- else if (type == 'option') {
- obj.value = content;
- obj.innerHTML = content;
- }
- else if (type == 'object') obj.data = content;
- else if (type == 'img' || type == 'video' || type == 'embed') obj.src = content;
- }
- if (clear) {
- if (obj.hasChildNodes()) {
- while (obj.childNodes.length >= 1) {
- obj.removeChild(obj.firstChild);
- }
- }
- }
- if (hide) {
- for(var i = 0; i < obj.children.length; i++) {
- styleMyElement(obj.children[i], {display: 'none'});
- }
- }
- }
-
- function cleanMyElement (element, hide) {
- var elEmbed, elVideo;
- if (hide) styleMyElement (element, {display: 'none'});
- elEmbed = getMyElement (element, 'embed', 'tag', '', 0, false) || getMyElement (element, 'object', 'tag', '', 0, false);
- if (elEmbed && elEmbed.parentNode) {
- removeMyElement (elEmbed.parentNode, elEmbed);
- if (!hide) return;
- }
- elVideo = getMyElement (element, 'video', 'tag', '', 0, false);
- if (elVideo && elVideo.src && elVideo.currentSrc) {
- modifyMyElement (elVideo, 'video', 'none', true);
- if (!hide && elVideo.parentNode) removeMyElement (elVideo.parentNode, elVideo);
- if (elVideo.parentNode) try {elVideo.pause()} catch(e) {};
- }
- var elWait = 50;
- var elRemove = page.win.setInterval (function () {
- if (!elVideo) {
- elVideo = getMyElement (element, 'video', 'tag', '', 0, false);
- if (!elVideo) {
- elEmbed = getMyElement (element, 'embed', 'tag', '', 0, false) || getMyElement (element, 'object', 'tag', '', 0, false);
- if (elEmbed && elEmbed.id != 'vtVideo' && elEmbed.parentNode) {
- removeMyElement (elEmbed.parentNode, elEmbed);
- page.win.clearInterval (elRemove);
- }
- }
- }
- if (elVideo && elVideo.id != 'vtVideo' && elVideo.currentSrc && elVideo.currentSrc.indexOf('none') == -1) {
- modifyMyElement (elVideo, 'video', 'none', true);
- if (elVideo.parentNode) try {elVideo.pause()} catch(e) {};
- if (!hide && elVideo.parentNode) removeMyElement (elVideo.parentNode, elVideo);
- }
- if (elWait > 0) elWait--;
- else page.win.clearInterval (elRemove);
- }, 500);
- }
-
- function styleMyElement (obj, styles) {
- for (var property in styles) {
- if (styles.hasOwnProperty(property)) obj.style[property] = styles[property];
- }
- }
-
- function appendMyElement (parent, child) {
- parent.appendChild(child);
- }
-
- function removeMyElement (parent, child) {
- parent.removeChild(child);
- }
-
- function replaceMyElement (parent, orphan, child) {
- parent.replaceChild(orphan, child);
- }
-
- function createHiddenElem(tag, id) {
- var elem=document.createElement(tag);
- elem.setAttribute('id', id);
- elem.setAttribute('style', 'display:none;');
- page.doc.body.appendChild(elem);
- return elem;
- }
-
- function injectScript(code) {
- var script=document.createElement('script');
- script.type='application/javascript';
- script.textContent=code;
- page.doc.body.appendChild(script);
- page.doc.body.removeChild(script);
- }
-
- function createMyPlayer (player) {
- /* Get My Options */
- getMyOptions ();
-
- /* Player Settings */
- player['panelHeight'] = 18;
- player['panelPadding'] = 2;
-
- /* The Panel */
- var panelWidth = player['playerWidth'] - player['panelPadding'] * 2;
- player['playerPanel'] = createMyElement ('div', '', '', '', '', player);
- styleMyElement (player['playerPanel'], {width: panelWidth + 'px', height: player['panelHeight'] + 'px', padding: player['panelPadding'] + 'px', backgroundColor: '#F4F4F4', textAlign: 'center'});
- appendMyElement (player['playerWindow'], player['playerPanel']);
-
- /* Panel Items */
- var panelItemBorder = 1;
- var panelItemHeight = player['panelHeight'] - panelItemBorder * 2;
- /* Panel Logo */
- player['panelLogo'] = createMyElement ('div', userscript + ':', 'click', 'logo', '', player);
- player['panelLogo'].title = '{ViewTube: click to visit the script web page}';
- styleMyElement (player['panelLogo'], {height: panelItemHeight + 'px', border: '1px solid #F4F4F4', borderRadius: '3px', padding: '0px', display: 'inline', color: '#336699', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
- appendMyElement (player['playerPanel'], player['panelLogo']);
-
- /* Panel Video Menu */
- player['videoMenu'] = createMyElement ('select', '', 'change', '', 'video', player);
- player['videoMenu'].title = '{Videos: select the video format for playback}';
- styleMyElement (player['videoMenu'], {width: '200px', height: panelItemHeight + 'px', border: '1px solid #F4F4F4', borderRadius: '3px', padding: '0px', display: 'inline', backgroundColor: '#F4F4F4', color: '#336699', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', verticalAlign: 'baseline', cursor: 'pointer'});
- appendMyElement (player['playerPanel'], player['videoMenu'] );
- for (var videoCode in player['videoList']) {
- player['videoItem'] = createMyElement ('option', videoCode, '', '', '', player);
- styleMyElement (player['videoItem'], {padding: '0px', display: 'block', backgroundColor: '#F4F4F4', color: '#336699', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
- appendMyElement (player['videoMenu'], player['videoItem']);
- }
-
- /* Panel Plugin Menu */
- player['pluginMenu'] = createMyElement ('select', '', 'change', '', 'plugin', player);
- player['pluginMenu'].title = '{Plugins: select the video plugin for playback}';
- styleMyElement (player['pluginMenu'], {width: '70px', height: panelItemHeight + 'px', border: '1px solid #F4F4F4', borderRadius: '3px', padding: '0px', display: 'inline', backgroundColor: '#F4F4F4', color: '#336699', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', verticalAlign: 'baseline', cursor: 'pointer'});
- appendMyElement (player['playerPanel'], player['pluginMenu'] );
- for (var p = 0; p < plugins.length; p++) {
- player['pluginItem'] = createMyElement ('option', plugins[p], '', '', '', player);
- styleMyElement (player['pluginItem'], {padding: '0px', display: 'block', backgroundColor: '#F4F4F4', color: '#336699', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
- appendMyElement (player['pluginMenu'], player['pluginItem']);
- }
- player['pluginMenu'].value = option['plugin'];
-
- /* Panel Play Button */
- player['buttonPlay'] = createMyElement ('div', 'Play', 'click', 'play', '', player);
- player['buttonPlay'].title = '{Play/Stop: click to start/stop video playback}';
- styleMyElement (player['buttonPlay'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 3px', display: 'inline', color: '#37B704', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
- // if (option['autoplay']) styleMyElement (player['buttonPlay'], {display: 'none'});
- appendMyElement (player['playerPanel'], player['buttonPlay']);
-
- /* Panel Get Button */
- player['buttonGet'] = createMyElement ('div', 'Get', 'click', 'get', '', player);
- player['buttonGet'].title = '{Get: click to download the selected video format}';
- styleMyElement (player['buttonGet'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#C000C0', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
- appendMyElement (player['playerPanel'], player['buttonGet']);
-
- /* Panel Autoplay Button */
- if (feature['autoplay']) {
- var bAutoPlay = (player['playerWidth'] > 600) ? 'Autoplay' : 'AP';
- player['buttonAutoplay'] = createMyElement ('div', bAutoPlay, 'click', 'autoplay', '', player);
- player['buttonAutoplay'].title = '{Autoplay: click to enable/disable auto playback on page load}';
- styleMyElement (player['buttonAutoplay'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#CCCCCC', fontSize: '12px', cursor: 'pointer'});
- if (option['autoplay']) styleMyElement (player['buttonAutoplay'], {color: '#008080', textShadow: '0px 1px 1px #CCCCCC'});
- appendMyElement (player['playerPanel'], player['buttonAutoplay']);
- }
-
- /* Panel Definition Button */
- if (feature['definition']) {
- player['buttonDefinition'] = createMyElement ('div', option['definition'], 'click', 'definition', '', player);
- player['buttonDefinition'].title = '{Definition: click to change the preferred video definition}';
- styleMyElement (player['buttonDefinition'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#008000', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
- appendMyElement (player['playerPanel'], player['buttonDefinition']);
- }
-
- /* Panel Container Button */
- if (feature['container']) {
- player['buttonContainer'] = createMyElement ('div', option['container'], 'click', 'container', '', player);
- player['buttonContainer'].title = '{Container: click to change the preferred video container}';
- styleMyElement (player['buttonContainer'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#008000', fontSize: '12px', textShadow: '0px 1px 1px #CCCCCC', cursor: 'pointer'});
- appendMyElement (player['playerPanel'], player['buttonContainer']);
- }
-
- /* Panel Widesize Button */
- if (feature['widesize']) {
- if (option['widesize']) player['buttonWidesize'] = createMyElement ('div', '<', 'click', 'widesize', '', player);
- else player['buttonWidesize'] = createMyElement ('div', '>', 'click', 'widesize', '', player);
- player['buttonWidesize'].title = '{Widesize: click to enter player widesize or return to normal size}';
- styleMyElement (player['buttonWidesize'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#C05800', fontSize: '12px', textShadow: '1px 1px 2px #CCCCCC', cursor: 'pointer'});
- appendMyElement (player['playerPanel'], player['buttonWidesize']);
- }
-
- /* Panel Fullsize Button */
- if (feature['fullsize']) {
- if (option['fullsize']) player['buttonFullsize'] = createMyElement ('div', '-', 'click', 'fullsize', '', player);
- else player['buttonFullsize'] = createMyElement ('div', '+', 'click', 'fullsize', '', player);
- player['buttonFullsize'].title = '{Fullsize: click to enter player fullsize or return to normal size}';
- styleMyElement (player['buttonFullsize'], {height: panelItemHeight + 'px', border: '1px solid #CCCCCC', borderRadius: '3px', padding: '0px 5px', display: 'inline', color: '#C05800', fontSize: '12px', textShadow: '1px 1px 2px #CCCCCC', cursor: 'pointer'});
- appendMyElement (player['playerPanel'], player['buttonFullsize']);
- }
-
- /* The Content */
- player['contentWidth'] = player['playerWidth'];
- player['contentHeight'] = player['playerHeight'] - player['panelHeight'] - player['panelPadding'] * 2;
- player['playerContent'] = createMyElement ('div', '', '', '', '');
- // styleMyElement (player['playerContent'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px', backgroundColor: '#F4F4F4', color: '#AD0000', fontSize: '14px', textAlign: 'center'});
- styleMyElement (player['playerContent'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px', backgroundColor: '#000', color: '#AD0000', fontSize: '14px', textAlign: 'center', position: 'relative'});
- appendMyElement (player['playerWindow'], player['playerContent']);
-
- /* The Video Thumbnail */
- if (player['videoThumb']) {
- player['contentImage'] = createMyElement ('img', player['videoThumb'], 'click', 'play', '', player);
- player['contentImage'].title = '{Click to start video playback}';
- // styleMyElement (player['contentImage'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px', border: '0px', cursor: 'pointer'});
- styleMyElement (player['contentImage'], {maxWidth: '100%', maxHeight: '100%', position: 'absolute', top: '0px', bottom: '0px', left: '0px', right: '0px', margin: 'auto', border: '0px', cursor: 'pointer'});
-
- // make sure small thumbnails will fill up the content area
- player['contentImage'].addEventListener('load', function () {
- // if image is wider than content area, scale its width, otherwise its height
- if (this.width/this.height >= player['contentWidth']/player['contentHeight']) {
- this.style.width = '1920px';
- }
- else {
- this.style.height = '1080px';
- }
- });
- }
-
- /* Disabled Features */
- if (!feature['autoplay']) option['autoplay'] = false;
- if (!feature['widesize']) option['widesize'] = false;
- if (!feature['fullsize']) option['fullsize'] = false;
-
- /* Resize My Player */
- if (option['widesize']) resizeMyPlayer(player, 'widesize');
- if (option['fullsize']) resizeMyPlayer(player, 'fullsize');
-
- /* Select My Video */
- if (feature['definition'] || feature['container']) selectMyVideo (player);
-
- /* Play My Video */
- playMyVideo (player, option['autoplay']);
- }
-
- function selectMyVideo (player) {
- var vdoCont = (option['container'] != 'Any') ? [option['container']] : option['containers'];
- var vdoDef = option['definitions'];
- var vdoList = {};
- for (var vC = 0; vC < vdoCont.length; vC++) {
- if (vdoCont[vC] != 'Any') {
- for (var vD = 0; vD < vdoDef.length; vD++) {
- var format = vdoDef[vD] + ' ' + vdoCont[vC];
- if (!vdoList[vdoDef[vD]]) {
- for (var vL in player['videoList']) {
- if (vL == format) {
- vdoList[vdoDef[vD]] = vL;
- break;
- }
- }
- }
- }
- }
- }
- if (option['definition'] == 'UHD') {
- if (vdoList['Ultra High Definition']) player['videoPlay'] = vdoList['Ultra High Definition'];
- else if (vdoList['Full High Definition']) player['videoPlay'] = vdoList['Full High Definition'];
- else if (vdoList['High Definition']) player['videoPlay'] = vdoList['High Definition'];
- else if (vdoList['Standard Definition']) player['videoPlay'] = vdoList['Standard Definition'];
- else if (vdoList['Low Definition']) player['videoPlay'] = vdoList['Low Definition'];
- else if (vdoList['Very Low Definition']) player['videoPlay'] = vdoList['Very Low Definition'];
- }
- else if (option['definition'] == 'FHD') {
- if (vdoList['Full High Definition']) player['videoPlay'] = vdoList['Full High Definition'];
- else if (vdoList['High Definition']) player['videoPlay'] = vdoList['High Definition'];
- else if (vdoList['Standard Definition']) player['videoPlay'] = vdoList['Standard Definition'];
- else if (vdoList['Low Definition']) player['videoPlay'] = vdoList['Low Definition'];
- else if (vdoList['Very Low Definition']) player['videoPlay'] = vdoList['Very Low Definition'];
- }
- else if (option['definition'] == 'HD') {
- if (vdoList['High Definition']) player['videoPlay'] = vdoList['High Definition'];
- else if (vdoList['Standard Definition']) player['videoPlay'] = vdoList['Standard Definition'];
- else if (vdoList['Low Definition']) player['videoPlay'] = vdoList['Low Definition'];
- else if (vdoList['Very Low Definition']) player['videoPlay'] = vdoList['Very Low Definition'];
- }
- else if (option['definition'] == 'SD') {
- if (vdoList['Standard Definition']) player['videoPlay'] = vdoList['Standard Definition'];
- else if (vdoList['Low Definition']) player['videoPlay'] = vdoList['Low Definition'];
- else if (vdoList['Very Low Definition']) player['videoPlay'] = vdoList['Very Low Definition'];
- }
- else if (option['definition'] == 'LD') {
- if (vdoList['Low Definition']) player['videoPlay'] = vdoList['Low Definition'];
- else if (vdoList['Very Low Definition']) player['videoPlay'] = vdoList['Very Low Definition'];
- }
- else if (option['definition'] == 'VLD') {
- if (vdoList['Very Low Definition']) player['videoPlay'] = vdoList['Very Low Definition'];
- else if (vdoList['Low Definition']) player['videoPlay'] = vdoList['Low Definition'];
- }
- player['videoMenu'].value = player['videoPlay'];
- }
-
- function playMyVideo (player, play) {
- if (play) {
- player['isPlaying'] = true;
- modifyMyElement (player['buttonPlay'], 'div', 'Stop', false);
- styleMyElement (player['buttonPlay'], {color: '#AD0000'});
- if (option['plugin'] == 'HTML5') {
- if (player['videoPlay'] == 'DASH MP4') {
- player['contentVideo'] = createVideoElement ('video', 'DASH', player);
- }
- else player['contentVideo'] = createVideoElement ('video', player['videoList'][player['videoPlay']], player);
- }
- else if (navigator.appName == 'Netscape') player['contentVideo'] = createVideoElement ('embed', player['videoList'][player['videoPlay']], player);
- else createVideoElement ('object', player['videoList'][player['videoPlay']], player);
- }
- else {
- player['isPlaying'] = false;
- modifyMyElement (player['buttonPlay'], 'div', 'Play', false);
- styleMyElement (player['buttonPlay'], {color: '#37B704'});
- modifyMyElement (player['playerContent'], 'div', '', true);
- if (player['videoDuration']) {
- var hours = Math.floor(player['videoDuration'] / 3600);
- var minutes = Math.floor((player['videoDuration'] % 3600) / 60);
- var seconds = (player['videoDuration'] % 3600) % 60;
- var duration = (hours > 0 ? (hours + ':' + (minutes > 9 ? minutes : '0' + minutes)) : minutes) + ':' + (seconds > 9 ? seconds : '0' + seconds);
- player['durationElem'] = createMyElement ('div',duration , '', '', '', player);
- styleMyElement (player['durationElem'], {position: 'absolute', backgroundColor: '#000000', color: '#FFFFFF', fontSize: '14px',fontWeight: 'bold', textAlign: 'right',
- right: '5px', bottom: '10px',paddingLeft: '2px', paddingRight: '2px', zIndex: '9'});
- appendMyElement (player['playerContent'], player['durationElem']);
- }
-
- if (player['contentImage']) appendMyElement (player['playerContent'], player['contentImage']);
- else showMyMessage ('!thumb');
- }
- }
-
- function getMyVideo (player) {
- var vdoURL = player['videoList'][player['videoPlay']];
- if (player['videoTitle']) {
- var vdoD = ' (' + player['videoPlay'] + ')';
- vdoD = vdoD.replace(/Ultra High Definition/, 'UHD');
- vdoD = vdoD.replace(/Full High Definition/, 'FHD');
- vdoD = vdoD.replace(/High Definition/, 'HD');
- vdoD = vdoD.replace(/Standard Definition/, 'SD');
- vdoD = vdoD.replace(/Very Low Definition/, 'VLD');
- vdoD = vdoD.replace(/Low Definition/, 'LD');
- vdoD = vdoD.replace(/\sFLV|\sMP4|\sWebM|\s3GP/g, '');
- vdoURL = vdoURL + '&title=' + player['videoTitle'] + vdoD;
- }
- if (option['autoget']) page.win.location.href = vdoURL;
- else {
- var vdoLink = 'Get <a href="' + vdoURL + '">Link</a>';
- modifyMyElement (player['buttonGet'] , 'div', vdoLink, false);
- player['isGetting'] = true;
- }
- }
-
- function resizeMyPlayer (player, size) {
- if (size == 'widesize') {
- if (option['widesize']) {
- modifyMyElement (player['buttonWidesize'], 'div', '<', false);
- var playerWidth = player['playerWideWidth'];
- var playerHeight= player['playerWideHeight'];
- var sidebarMargin = player['sidebarMarginWide'];
- }
- else {
- modifyMyElement (player['buttonWidesize'], 'div', '>', false);
- var playerWidth = player['playerWidth'];
- var playerHeight= player['playerHeight'];
- var sidebarMargin = player['sidebarMarginNormal'];
- }
- }
- else if (size == 'fullsize') {
- if (option['fullsize']) {
- var playerPosition = 'fixed';
- var playerWidth = page.win.innerWidth || page.doc.documentElement.clientWidth;
- var playerHeight = page.win.innerHeight || page.doc.documentElement.clientHeight;
- var playerIndex = '2147483647';
- var frames = document.getElementsByTagName('iframe');
- for (var i = 0 ; i <frames.length; i++) styleMyElement(frames[i], {display: 'none'});
- setTimeout(function(){ if (option['fullsize']) {var frames = document.getElementsByTagName('iframe'); for (var i = 0 ; i <frames.length; i++) styleMyElement(frames[i], {display: 'none'});}},3000);
- if (!player['isFullsize']) {
- if (feature['widesize']) styleMyElement (player['buttonWidesize'], {display: 'none'});
- modifyMyElement (player['buttonFullsize'], 'div', '-', false);
- styleMyElement (page.body, {overflow: 'hidden'});
- if (!player['resizeListener']) player['resizeListener'] = function() {resizeMyPlayer(player, 'fullsize')};
- page.win.addEventListener ('resize', player['resizeListener'], false);
- OrgHeadWindowIndex = '';
- if (HeadWindow && HeadWindow.style) {
- OrgHeadWindowIndex = HeadWindow.style['zIndex'];
- styleMyElement(HeadWindow, {zIndex: -10});
- }
- player['isFullsize'] = true;
- }
- }
- else {
- var playerPosition = 'relative';
- var playerWidth = (option['widesize']) ? player['playerWideWidth'] : player['playerWidth'];
- var playerHeight = (option['widesize']) ? player['playerWideHeight'] : player['playerHeight'];
- var playerIndex = 'auto';
- var frames = document.getElementsByTagName('iframe');
- for (var i = 0 ; i <frames.length; i++) styleMyElement(frames[i], {display: ''});
- if (feature['widesize']) styleMyElement (player['buttonWidesize'], {display: 'inline'});
- modifyMyElement (player['buttonFullsize'], 'div', '+', false);
- styleMyElement (page.body, {overflow: 'auto'});
- page.win.removeEventListener ('resize', player['resizeListener'], false);
- if (HeadWindow && HeadWindow.style) styleMyElement(HeadWindow, {zIndex: OrgHeadWindowIndex});
- var frames = document.getElementsByTagName('iframe')
- for (var i = 0 ; i <frames.length; i++) {
- styleMyElement(frames[i], { display: ''});
- }
- player['isFullsize'] = false;
- }
- }
-
- /* Resize The Player */
- if (size == 'widesize') {
- styleMyElement (player['sidebarWindow'], {marginTop: sidebarMargin + 'px'});
- styleMyElement (player['playerWindow'], {width: playerWidth + 'px', height: playerHeight + 'px'});
- }
- else {
- styleMyElement (player['playerWindow'], {position: playerPosition, top: '0px', left: '0px', width: playerWidth + 'px', height: playerHeight + 'px', zIndex: playerIndex});
- }
- /* Resize The Panel */
- var panelWidth = playerWidth - player['panelPadding'] * 2;
- styleMyElement (player['playerPanel'], {width: panelWidth + 'px'});
-
- /* Resize The Content */
- player['contentWidth'] = playerWidth;
- player['contentHeight'] = playerHeight - player['panelHeight'] - player['panelPadding'] * 2;
- styleMyElement (player['playerContent'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px'});
- // if (player['contentImage']) styleMyElement (player['contentImage'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px', border: '0px'});
- if (player['isPlaying']) {
- player['contentVideo'].width = player['contentWidth'];
- player['contentVideo'].height = player['contentHeight'];
- styleMyElement (player['contentVideo'], {width: player['contentWidth'] + 'px', height: player['contentHeight'] + 'px'});
- }
- }
-
- function cleanMyContent (content, unesc) {
- var myNewContent = content;
- if (!content) return myNewContent;
- if (unesc) myNewContent = unescape (myNewContent);
- myNewContent = myNewContent.replace (/\\u0025/g,'%');
- myNewContent = myNewContent.replace (/\\u0026/g,'&');
- myNewContent = myNewContent.replace (/\\/g,'');
- myNewContent = myNewContent.replace (/\n/g,'');
- return myNewContent;
- }
-
- function getMyContent (url, pattern, clean) {
- var myPageContent, myVideosParse, myVideosContent;
- var isIE = (navigator.appName.indexOf('Internet Explorer') != -1) ? true : false;
- var getMethod = (url != page.url || isIE) ? 'XHR' : 'DOM';
- if (getMethod == 'DOM') {
- myPageContent = getMyElement ('', 'html', 'tag', '', 0, true);
- if (!myPageContent) myPageContent = getMyElement ('', 'body', '', '', -1, true);
- if (clean) myPageContent = cleanMyContent (myPageContent, true);
- myVideosParse = myPageContent.match (pattern);
- myVideosContent = (myVideosParse) ? myVideosParse[1] : null;
- if (myVideosContent) return myVideosContent;
- else getMethod = 'XHR';
- }
- if (getMethod == 'XHR') {
- var xmlHTTP = new XMLHttpRequest();
- xmlHTTP.open('GET', url, false);
- xmlHTTP.send();
- if (pattern == 'XML') {
- myVideosContent = xmlHTTP.responseXML;
- }
- else if (pattern == 'TEXT') {
- myVideosContent = xmlHTTP.responseText;
- }
- else {
- myPageContent = xmlHTTP.responseText;
- if (clean) myPageContent = cleanMyContent (myPageContent, true);
- myVideosParse = myPageContent.match (pattern);
- myVideosContent = (myVideosParse) ? myVideosParse[1] : null;
- }
- return myVideosContent;
- }
- }
-
- function setMyOptions (key, value) {
- var key_extended = key + "_" + page.url.match(/https?:\/\/(www\.)?(.*?)\//)[2];
- if (typeof GM_setValue === 'function') {
- GM_setValue(key_extended, value);
- }
- else {
- try {
- localStorage.setItem(key_extended, value);
- }
- catch(e) {
- var date = new Date();
- date.setTime(date.getTime() + (356*24*60*60*1000));
- var expires = '; expires=' + date.toGMTString();
- page.doc.cookie = key_extended + '=' + value + expires + '; path=/';
- }
- }
- }
-
- function getMyOption (key) {
- var key_extended = key + "_" + page.url.match(/https?:\/\/(www\.)?(.*?)\//)[2];
- if ((typeof GM_getValue === 'function') ){
- return GM_getValue(key_extended, null);
- }
- else
- try {
- return localStorage.setItem(key_extended);
- }
- catch(e) {
- var cookies = page.doc.cookie.split(';');
- for (var i=0; i < cookies.length; i++) {
- var cookie = cookies[i];
- while (cookie.charAt(0) == ' ') cookie = cookie.substring(1, cookie.length);
- if (cookie.indexOf(key) == 0) {
- return cookie.substring(key.length + 1, cookie.length);
- }
- }
- }
- }
-
- function getMyOptions () {
- var tmpOption;
- tmpOption = getMyOption('viewtube_plugin');
- if (plugins.indexOf(tmpOption) == -1) tmpOption = plugins[0];
- option['plugin'] = tmpOption ? tmpOption : option['plugin'];
- option['autoplay'] = getMyOption('viewtube_autoplay');
- option['autoplay'] = (option['autoplay'] == 'true' || option['autoplay'] == true) ? true : false;
- tmpOption = getMyOption('viewtube_definition');
- option['definition'] = tmpOption ? tmpOption : option['definition'];
- tmpOption = getMyOption('viewtube_container');
- option['container'] = tmpOption ? tmpOption : option['container'];
- option['widesize'] = getMyOption('viewtube_widesize');
- option['widesize'] = (option['widesize'] == 'true' || option['widesize'] == true) ? true : false;
- option['fullsize'] = false;
- }
-
- function showMyMessage (cause, content) {
- var myScriptLogo = createMyElement ('div', userscript, '', '', '');
- styleMyElement (myScriptLogo, {margin: '0px auto', padding: '10px', color: '#666666', fontSize: '24px', textAlign: 'center', textShadow: '#FFFFFF -1px -1px 2px'});
- var myScriptMess = createMyElement ('div', '', '', '', '');
- styleMyElement (myScriptMess, {border: '1px solid #F4F4F4', margin: '5px auto 5px auto', padding: '10px', backgroundColor: '#FFFFFF', color: '#AD0000', textAlign: 'center'});
- if (cause == '!player') {
- var myScriptAlert = createMyElement ('div', '', '', '', '');
- styleMyElement (myScriptAlert, {position: 'absolute', top: '30%', left: '35%', border: '1px solid #F4F4F4', borderRadius: '3px', padding: '10px', backgroundColor: '#F8F8F8', fontSize: '14px', textAlign: 'center', zIndex: '99999'});
- appendMyElement (myScriptAlert, myScriptLogo);
- var myNoPlayerMess = 'Couldn\'t get the player element. Please report it <a href="' + contact + '">here</a>.';
- modifyMyElement (myScriptMess, 'div', myNoPlayerMess, false);
- appendMyElement (myScriptAlert, myScriptMess);
- var myScriptAlertButton = createMyElement ('div', 'OK', 'click', 'close', myScriptAlert);
- 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'});
- appendMyElement (myScriptAlert, myScriptAlertButton);
- appendMyElement (page.body, myScriptAlert);
- }
- else if (cause == '!thumb') {
- var myNoThumbMess = '<br><br>Couldn\'t get the thumbnail for this video. Please report it <a href="' + contact + '">here</a>.';
- modifyMyElement (player['playerContent'], 'div', myNoThumbMess, false);
- }
- else {
- appendMyElement (myPlayerWindow, myScriptLogo);
- if (cause == '!content') {
- var myNoContentMess = 'Couldn\'t get the videos content. Please report it <a href="' + contact + '">here</a>.';
- modifyMyElement (myScriptMess, 'div', myNoContentMess, false);
- }
- else if (cause == '!videos') {
- var myNoVideosMess = 'Couldn\'t get any video. Please report it <a href="' + contact + '">here</a>.';
- modifyMyElement (myScriptMess, 'div', myNoVideosMess, false);
- }
- else if (cause == '!support') {
- var myNoSupportMess = 'This video uses the RTMP protocol and is not supported.';
- modifyMyElement (myScriptMess, 'div', myNoSupportMess, false);
- }
- else if (cause == 'embed') {
- var myEmbedMess = 'This is an embedded video. You can watch it <a href="' + content + '">here</a>.';
- modifyMyElement (myScriptMess, 'div', myEmbedMess, false);
- }
- appendMyElement (myPlayerWindow, myScriptMess);
- }
- }
-
- function crossXmlHttpRequest(details) { // cross-browser GM_xmlhttpRequest
- if (typeof GM_xmlhttpRequest === 'function') { // Greasemonkey, Tampermonkey, Firefox extension, Chrome script
- GM_xmlhttpRequest(details);
- } else if (typeof window.opera !== 'undefined' && window.opera && typeof opera.extension !== 'undefined' &&
- typeof opera.extension.postMessage !== 'undefined') { // Opera 12 extension
- opera.extension.postMessage({'action':'xhr', 'url':details.url});
- opera.extension.onmessage = function(event) {
- if (event.data.action === 'xhr-response' && event.data.error === false) {
- if (details['onload']) {
- details['onload']({responseText:event.data.response, readyState:4, status:200});
- }
- }
- }
- } else if (typeof window.opera === 'undefined' && typeof XMLHttpRequest === 'function') { // Opera 15+ extension
- var xhr=new XMLHttpRequest();
- xhr.onreadystatechange = function() {
- if (xhr.readyState == 4) {
- if (details['onload'] && xhr.status >= 200 && xhr.status < 300) {
- details['onload']({responseText:xhr.responseText, readyState:xhr.readyState, status:xhr.status});
- }
- }
- }
- xhr.open(details.method, details.url, true);
- xhr.send();
- }
- }
-
- function getMyContentGM(url, pattern, clean, callback) {
- var myPageContent, myVideosParse, myVideosContent;
- crossXmlHttpRequest({
- method: 'GET',
- url: url,
- onload: function(response) {
- if (pattern == 'TEXT') {
- myVideosContent = response.responseText;
- }
- else {
- myPageContent = response.responseText;
- if (clean) myPageContent = cleanMyContent (myPageContent, true);
- myVideosParse = myPageContent.match (pattern);
- myVideosContent = (myVideosParse) ? myVideosParse[1] : null;
- }
- callback(myVideosContent);
- }
- });
- }
-
- // ==========Websites========== //
-
- // Fixes
- var blockObject = null;
- var blockInterval = 50;
-
- page.win.setInterval(function() {
- // Block videos
- if (blockObject && blockInterval > 0) {
- var elEmbeds = getMyElement (blockObject, 'embed', 'tag', '', -1, false) || getMyElement (blockObject, 'object', 'tag', '', -1, false);
- if (elEmbeds.length > 0) {
- for (var e = 0; e < elEmbeds.length; e++) {
- var elEmbed = elEmbeds[e];
- if (elEmbed && elEmbed.id != 'vtVideo' && elEmbed.parentNode) {
- removeMyElement (elEmbed.parentNode, elEmbed);
- }
- }
- }
- var elVideos = getMyElement (blockObject, 'video', 'tag', '', -1, false);
- if (elVideos.length > 0) {
- for (var v = 0; v < elVideos.length; v++) {
- var elVideo = elVideos[v];
- if (elVideo && elVideo.id != 'vtVideo' && elVideo.currentSrc) {
- modifyMyElement (elVideo, 'video', 'none', true);
- }
- }
- }
- if (blockInterval > 0) blockInterval--;
- }
- }, 500);
-
- // =====YouTube===== //
- if (page.url.indexOf('/www.youtube.com/') != -1) {
- var decodeArray=[];
- var searchstring;
- ytPlayerResize = function () {return null;};
-
- function findSignatureCode(sourceCode) {
- var arr=[];
- var functionName = sourceCode.match(/\.signature\s*=\s*((\$|_|\w)+)\(\w+\)/);
- if (!functionName) functionName = sourceCode.match(/"signature"\s*,\s*(.*?)\(/);
- if (functionName==null) return;
- functionName = functionName[1];
- if (functionName.indexOf('$') == 0) functionName = "\\" + functionName;
- var regCode=new RegExp('function '+functionName+'\\s*\\(\\w+\\)\\s*{\\w+=\\w+\\.split\\(""\\);(.+);return \\w+\\.join');
- var functionCode=sourceCode.match('function '+functionName+'\\s*\\(\\w+\\)\\s*{\\w+=\\w+\\.split\\(""\\);(.+);return \\w+\\.join');
- if (!functionCode) functionCode=sourceCode.match(functionName+'=function+\\s*\\(\\w+\\)\\s*{\\w+=\\w+\\.split\\(""\\);(.+);return \\w+\\.join');
- if (functionCode==null) return;
- functionCode = functionCode[1];
- var functionCodePieces=functionCode.split(';');
- var decodevariable = functionCodePieces[0].match(/(\w+=)?(.*?)\./)[2];
- var decodefunctions = sourceCode.match('var\\s+'+decodevariable+'=\\{.*?\\}\\}');
- if (decodefunctions) {
- var freverse = decodefunctions[0].match(decodevariable +'=.*(\\{|,)(.*?)\\:function.*?reverse\\(.*\\)\\}')[2];
- var fslice = decodefunctions[0].match(decodevariable +'=.*(\\{|,)(.*?)\\:function.*?sp?lice\\(.*\\)\\}')[2];
- var fswap = decodefunctions[0].match(decodevariable +'=.*(\\{|,)(.*?)\\:function.*?length];.*\\}')[2];
- } else return;
- for (var i=0; i<functionCodePieces.length; i++) {
- functionCodePieces[i]=functionCodePieces[i].trim();
- if (functionCodePieces[i].length>0)
- if (functionCodePieces[i].indexOf(fslice) >= 0) { // slice
- var slice=functionCodePieces[i].match(fslice+'\\s*\\(\\s*\\w*\\s*,(.+)\\s*\\)')[1];
- slice=parseInt(slice, 10);
- if (typeof slice === 'number') {
- arr.push(-slice);
- } else return;
- } else if (functionCodePieces[i].indexOf(freverse) >= 0) {
- arr.push(0);
- } else if (functionCodePieces[i].indexOf(fswap) >= 0) {
- var inline=functionCodePieces[i].match(fswap+'\\s*\\(\\s*\\w*\\s*,(.+)\\s*\\)')[1];
- inline=parseInt(inline, 10);
- if (typeof inline === 'number') {
- arr.push(inline);
- } else return;
- } else if (functionCodePieces[i].indexOf(',') >= 0) {
- var swap=functionCodePieces[i].match(regSwap)[1];
- swap=parseInt(swap, 10);
- if (typeof swap === 'number') {
- arr.push(swap);
- } else return;
- } else return;
- }
- return arr;
- }
-
- function decryptSignature(sig) {
- function swap(a,b){var c=a[0];a[0]=a[b%a.length];a[b]=c;return a};
- function decode(sig, arr) { // encoded decryption
- if (typeof sig !== 'string') return null;
- var sigA=sig.split('');
- for (var i=0;i<arr.length;i++) {
- var act=parseInt(arr[i]);
- if (typeof act !== 'number') return null;
- sigA=(act>0)?swap(sigA, act):((act==0)?sigA.reverse():sigA.slice(-act));
- }
- return sigA.join('');
- }
- if (sig==null) return '';
- if (decodeArray) {
- var sig2=decode(sig, decodeArray);
- if (sig2 && sig2.length == 81) return sig2;
- }
- return sig;
- }
-
- /* Player Size */
- var ytSidebarMarginNormal = 382;
- var ytSidebarWindow = getMyElement ('', 'div', 'id', 'watch7-sidebar', -1, false);
- var ytSidebarWindowStyle = ytSidebarWindow.currentStyle || window.getComputedStyle(ytSidebarWindow);
- if (ytSidebarWindow && ytSidebarWindowStyle) {
- ytSidebarMarginNormal = parseInt(ytSidebarWindowStyle.marginTop.replace('px', ''));
- styleMyElement (ytSidebarWindow, {marginTop: ytSidebarMarginNormal + 'px'});
- }
- var ytPlayerWidth, ytPlayerHeight;
- var ytPlayerWideWidth, ytPlayerWideHeight;
- var ytSidebarMarginWide;
- var ytScreenWidth, ytScreenHeight;
- function ytSizes() {
- ytScreenWidth = page.win.innerWidth || page.doc.documentElement.clientWidth;
- ytScreenHeight = page.win.innerHeight || page.doc.documentElement.clientHeight;
- if (ytScreenWidth >= 1720 && ytScreenHeight >= 980) {
- ytPlayerWidth = 1280;
- ytPlayerHeight = 742;
- ytPlayerWideWidth = 1706;
- ytPlayerWideHeight = 982;
- }
- else if (ytScreenWidth >= 1294 && ytScreenHeight >= 630) {
- ytPlayerWidth = 854;
- ytPlayerHeight = 502;
- ytPlayerWideWidth = 1280;
- ytPlayerWideHeight = 742;
- }
- else {
- ytPlayerWidth = 640;
- ytPlayerHeight = 390;
- ytPlayerWideWidth = 1066;
- ytPlayerWideHeight = 622;
- }
- ytSidebarMarginWide = ytPlayerHeight + ytSidebarMarginNormal;
- }
-
- function yt_run(isMutation) {
- page = {win: window, doc: document, body: document.body, url: window.location.href}
- /* Get Player Window */
- var ytPlayerBgColor = '#FFFFFF';
- var ytPlayerWindow = getMyElement ('', 'div', 'id', 'player', -1, false);
- if (!ytPlayerWindow) {
- ytPlayerWindow = getMyElement ('', 'div', 'id', 'p', -1, false);
- ytPlayerBgColor = 'inherit';
- feature['widesize'] = false; }
- if (!ytPlayerWindow) {
- showMyMessage ('!player');
- }
- else {
- var ytVideoID = null;
- var ytVideosContent = null;
- var ytVideosEncodedFmts = null;
- var ytVideosAdaptiveFmts = null;
- var ytVideosDashmpd;
-
- /* Clean Player Window */
- var ytWatchPlayer = getMyElement ('', 'div', 'id', 'player-api', -1, false);
- if (ytWatchPlayer) styleMyElement (ytWatchPlayer, {display: 'none'});
-
- // Stop playlist Autoplay
- var ytNavControl = getMyElement ('', 'div', 'class', 'playlist-nav-controls', 0, false);
- if (ytNavControl) {
- 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;}};}}');
- }
-
- /* Get Video Thumbnail */
- ytVideoID = page.url.match (/(\?|&)v=(.*?)(&|$)/);
- ytVideoID = (ytVideoID) ? ytVideoID[2] : null;
-
- var ytVideoThumb = getMyContent (page.url, 'link\\s+itemprop="thumbnailUrl"\\s+href="(.*?)"', false);
- if (!ytVideoThumb) ytVideoThumb = getMyContent (page.url, 'meta\\s+property="og:image"\\s+content="(.*?)"', false);
- if (!ytVideoThumb) {
- if (ytVideoID) ytVideoThumb = page.win.location.protocol + '//img.youtube.com/vi/' + ytVideoID + '/0.jpg';
- }
-
- /* Get Video Title */
- var ytVideoTitle = getMyContent (page.url, 'meta\\s+itemprop="name"\\s+content="(.*?)"', false);
- if (!ytVideoTitle) ytVideoTitle = getMyContent (page.url, 'meta\\s+property="og:title"\\s+content="(.*?)"', false);
- if (!ytVideoTitle) ytVideoTitle = page.doc.title;
- if (ytVideoTitle) {
- ytVideoTitle = ytVideoTitle.replace(/"/g, '\'').replace(/"/g, '\'').replace(/"/g, '\'');
- ytVideoTitle = ytVideoTitle.replace(/'/g, '\'').replace(/'|’/g, '\'');
- ytVideoTitle = ytVideoTitle.replace(/&/g, '&');
- // ytVideoTitle = ytVideoTitle.replace(/\?/g, '').replace(/[#:\*]/g, '-').replace(/\//g, '-');
- ytVideoTitle = ytVideoTitle.replace(/^\s+|\s+$/, '').replace(/\.+$/g, '');
- ytVideoTitle = ytVideoTitle.replace(/^YouTube\s-\s/, '').replace(/\s-\sYouTube$/, '');
- }
- var ytVideoDuration = getMyContent (page.url, 'meta\\s+itemprop="duration"\\s+content="(.*?)"', false);
- if (ytVideoDuration) {
- 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);
- }
- var ytVideoAvailable = getMyElement ('', 'div', 'id', 'player-unavailable', -1, false);
- if (ytVideoAvailable && ytVideoAvailable.className.indexOf('hid') == -1) styleMyElement (ytVideoAvailable, {display: 'inline'});
- myPlayerWindow = getMyElement ('', 'div', 'id', 'MyytWindow', -1, false);
- if (myPlayerWindow) removeMyElement(myPlayerWindow.parentNode,myPlayerWindow);
-
- /* Get Videos Content */
- var ytScriptURL;
- if (ytVideoAvailable && (ytVideoAvailable.className.indexOf('hid') != -1 || getMyElement ('', 'div', 'id', 'watch7-player-age-gate-content', -1, false))) {
- if (isMutation) {
- var injectedElement = document.getElementById('download-youtube-video-debug-info9');
- if (injectedElement==null) {
- injectedElement = createHiddenElem('pre', 'download-youtube-video-debug-info9');
- }
- 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+\'"\'));');
- var code = getMyElement('','pre','id','download-youtube-video-debug-info9',-1,false).innerHTML;
- if (code) {
- if (ytVideoID == code.match(/\"video_id\":\s*\"([^\"]+)\"/)[1]) {
- ytVideosEncodedFmts=code.match(/\"url_encoded_fmt_stream_map\":\s*\"([^\"]+)\"/)[1].replace(/&/g,'\\u0026');
- if (ytVideosEncodedFmts == 'undefined') ytVideosEncodedFmts = null;
- if (ytVideosEncodedFmts) ytVideosEncodedFmts = cleanMyContent(ytVideosEncodedFmts, false);
- ytVideosAdaptiveFmts=code.match(/\"adaptive_fmts\":\s*\"([^\"]+)\"/)[1].replace(/&/g,'\\u0026');
- if (ytVideosAdaptiveFmts == 'undefined') ytVideosAdaptiveFmts = null;
- if (ytVideosAdaptiveFmts) ytVideosAdaptiveFmts = cleanMyContent(ytVideosAdaptiveFmts, false);
- ytVideosDashmpd=code.match(/\"dashmpd\":\s*\"([^\"]+)\"/)[1].replace(/&/g,'\\u0026');
- ytScriptURL=code.match(/\"js\":\s*\"([^\"]+)\"/)[1];
- if (!ytScriptURL) ytScriptURL = getMyContent(page.url.replace(/watch.*?v=/, 'embed/').replace(/&.*$/, ''), '"js":\\s*"(.*?)"', true);
- }
- removeMyElement(injectedElement.parentNode, injectedElement);
- }
- }
- else if (!ytVideosEncodedFmts && !ytVideosAdaptiveFmts) {
- ytVideosEncodedFmts = getMyContent(page.url, '"url_encoded_fmt_stream_map":\\s*"(.*?)"', false);
- if (ytVideosEncodedFmts) ytVideosEncodedFmts = cleanMyContent(ytVideosEncodedFmts, false);
- ytVideosAdaptiveFmts = getMyContent(page.url, '"adaptive_fmts":\\s*"(.*?)"', false);
- if (ytVideosAdaptiveFmts) ytVideosAdaptiveFmts = cleanMyContent(ytVideosAdaptiveFmts, false);
- ytVideosDashmpd = getMyContent(page.url, '"dashmpd":\\s+"(.*?)"', false);
- if (ytVideosDashmpd) ytVideosDashmpd = cleanMyContent(ytVideosDashmpd, false);
- if (!ytVideosEncodedFmts && !ytVideosAdaptiveFmts) {
- var ytVideoSts = getMyContent(page.url.replace(/watch.*?v=/, 'embed/').replace(/&.*$/, ''), '"sts"\\s*:\\s*(\\d+)', false);
- var ytVideosInfoURL = 'https://www.youtube.com/get_video_info?video_id=' + ytVideoID + '&eurl=https://youtube.googleapis.com/v/' + ytVideoID + '&sts=' + ytVideoSts;
- var ytVideosInfo = getMyContent(ytVideosInfoURL, 'TEXT', false);
- if (ytVideosInfo) {
- ytVideosEncodedFmts = ytVideosInfo.match(/url_encoded_fmt_stream_map=(.*?)&/);
- ytVideosEncodedFmts = (ytVideosEncodedFmts) ? ytVideosEncodedFmts[1] : null;
- if (ytVideosEncodedFmts) {
- ytVideosEncodedFmts = cleanMyContent(ytVideosEncodedFmts, true);
- ytVideosContent = ytVideosEncodedFmts;
- }
- if (!ytVideosAdaptiveFmts) {
- ytVideosAdaptiveFmts = ytVideosInfo.match(/adaptive_fmts=(.*?)&/);
- ytVideosAdaptiveFmts = (ytVideosAdaptiveFmts) ? ytVideosAdaptiveFmts[1] : null;
- if (ytVideosAdaptiveFmts) ytVideosAdaptiveFmts = cleanMyContent(ytVideosAdaptiveFmts, true);
- }
- if (!ytVideosDashmpd) {
- ytVideosDashmpd = ytVideosInfo.match(/dashmpd=(.*?)&/);
- ytVideosDashmpd = (ytVideosDashmpd) ? ytVideosDashmpd[1] : null;
- if (ytVideosDashmpd) ytVideosDashmpd = cleanMyContent(ytVideosDashmpd, true);
- }
- }
- }
- }
- if (ytVideosEncodedFmts || ytVideosAdaptiveFmts) styleMyElement(ytVideoAvailable, {display: 'none'});
- }
- if (ytVideosEncodedFmts) {
- ytVideosContent = ytVideosEncodedFmts;
- }
- if (ytVideosAdaptiveFmts) {
- ytVideosAdaptiveFmts = ytVideosAdaptiveFmts.replace(/clen=\d+&/g, '');
- ytVideosAdaptiveFmts = ytVideosAdaptiveFmts.replace(/lmt=\d+&/g, '');
- if (ytVideosContent) ytVideosContent += ',' + ytVideosAdaptiveFmts;
- else ytVideosContent = ytVideosAdaptiveFmts;
- }
-
- /* Get HLS Content */
- if (!ytVideosContent) {
- var ytHLSVideos, ytHLSContent;
- ytHLSVideos = getMyContent(page.url, '"hlsvp":\\s*"(.*?)"', false);
- if (ytHLSVideos) ytHLSVideos = cleanMyContent(ytHLSVideos, false);
- }
-
- function getYoutubeVideos(ytVideosContent, yturl) {
- if (yturl != page.url) return;
-
- /* Parse HLS */
- function ytHLS(ytHLSVideos) {
- var ytHLSFormats = {
- '92': 'Very Low Definition MP4',
- '93': 'Low Definition MP4',
- '94': 'Standard Definition MP4',
- '95': 'High Definition MP4'
- };
- ytVideoList["Any Definition MP4"] = ytHLSVideos;
- if (ytHLSContent) {
- var ytHLSMatcher = new RegExp('(http.*?m3u8)', 'g');
- ytHLSVideos = ytHLSContent.match(ytHLSMatcher);
- var ytHLSVideo, ytVideoCodeParse, ytVideoCode, myVideoCode;
- if (ytHLSVideos) {
- for (var i = 0; i < ytHLSVideos.length; i++) {
- ytHLSVideo = ytHLSVideos[i];
- ytVideoCodeParse = ytHLSVideo.match(/\/itag\/(\d{1,3})\//);
- ytVideoCode = (ytVideoCodeParse) ? ytVideoCodeParse[1] : null;
- if (ytVideoCode) {
- myVideoCode = ytHLSFormats[ytVideoCode];
- if (myVideoCode && ytHLSVideo) {
- ytVideoList[myVideoCode] = ytHLSVideo;
- }
- }
- }
- }
- }
- ytVideoTitle = null;
- ytPlayer (yturl);
- }
-
- function ytPlayer (yturl) {
- if (yturl != page.url) return;
- window.removeEventListener('resize', ytPlayerResize, false);
-
- /* Create Player */
- var ytDefaultVideo = 'Low Definition MP4';
- var player = {
- 'playerSocket': ytPlayerWindow,
- 'playerWindow': myPlayerWindow,
- 'videoList': ytVideoList,
- 'videoPlay': ytDefaultVideo,
- 'videoThumb': ytVideoThumb,
- 'videoDuration': ytVideoDuration,
- 'playerWidth': ytPlayerWidth,
- 'playerHeight': ytPlayerHeight,
- 'playerWideWidth': ytPlayerWideWidth,
- 'playerWideHeight': ytPlayerWideHeight,
- 'sidebarWindow': ytSidebarWindow,
- 'sidebarMarginNormal': ytSidebarMarginNormal,
- 'sidebarMarginWide': ytSidebarMarginWide
- };
-
- ytPlayerResize = function () {
- ytSizes();
- var ytWatchAppBar = getMyElement ('', 'div', 'id', 'watch-appbar-playlist', -1, false);
- if (ytWatchAppBar) styleMyElement (ytWatchAppBar, {height: + ytPlayerHeight + 'px'});
- player['playerWidth'] = ytPlayerWidth;
- player['playerHeight'] = ytPlayerHeight;
- player['playerWideWidth'] = ytPlayerWideWidth;
- player['playerWideHeight'] = ytPlayerWideHeight;
- player['sidebarMarginWide'] = ytSidebarMarginWide;
- resizeMyPlayer(player, 'widesize');
- }
-
- option['definitions'] = ['Ultra High Definition', 'Full High Definition', 'High Definition', 'Standard Definition', 'Low Definition', 'Very Low Definition'];
- option['containers'] = ['MP4', 'WebM', 'FLV', '3GP', 'Any'];
- createMyPlayer (player);
- var ytWatchAppBar = getMyElement ('', 'div', 'id', 'watch-appbar-playlist', -1, false);
- if (ytWatchAppBar) styleMyElement (ytWatchAppBar, {height: + ytPlayerHeight + 'px'});
-
- /* Update Sizes */
- window.addEventListener('resize', ytPlayerResize,false);
- }
-
- /* Get Sizes */
- ytSizes();
-
- /* Hide Player Window */
- var ytPlaceholderPlayer = getMyElement ('', 'div', 'id', 'placeholder-player', -1, false);
- if (ytPlaceholderPlayer) styleMyElement (ytPlaceholderPlayer, {display: 'none'});
-
- /* My Player Window */
- myPlayerWindow = createMyElement ('div', '', '', '', '');
- myPlayerWindow.id = 'MyytWindow';
- styleMyElement (myPlayerWindow, {position: 'relative', width: ytPlayerWidth + 'px', height: ytPlayerHeight +'px', backgroundColor: ytPlayerBgColor, zIndex: '99999'});
- appendMyElement(ytPlayerWindow, myPlayerWindow);
- blockObject = ytPlayerWindow;
- blockInterval = 20;
-
- /* Get Videos */
- var ytVideoAvailable = getMyElement ('', 'div', 'id', 'player-unavailable', -1, false);
- if (ytVideosContent && !ytVideosContent.match(/"statusCode":[^0]/)) {
- var ytVideoList = {};
- var ytVideoFound = false;
- var veVideoFound = false;
- if (ytVideosContent.match(/VevoImages/)) {
- var veVideoFormats = {
- 'High': 'Standard Definition MP4'
- ,'Med': 'Low Definition MP4'
- ,'Low': 'Ultra Low Definition MP4'
- ,'HTTP Live Streaming': 'HTTP Live Streaming'
- ,'564000': 'Very Low Definition MP4'
- ,'864000': 'Low Definition MP4'
- ,'1328000':'Standard Definition MP4'
- ,'1728000':'Standard Definition HBR MP4'
- ,'2528000':'High Definition MP4'
- ,'3328000':'High Definition HBR MP4'
- ,'4392000':'Full High Definition MP4'
- ,'5392000':'Full High Definition HBR MP4'
- }
- var veVideosJSON = JSON.parse(ytVideosContent);
- if (veVideosJSON) {
- if (ytVideoAvailable) styleMyElement (ytVideoAvailable, {display: 'none'});
- var veVideo, veVideoVersion;
- for (var i = 0; i < veVideosJSON.video.videoVersions.length - 1; i++) {
- if (veVideosJSON.video.videoVersions[i].sourceType == 2) {
- if (veVideosJSON.video.videoVersions[i].version in {3:1,4:1}) {
- for (var veVideoFormat in veVideoFormats) {
- veVideo = veVideosJSON.video.videoVersions[i].data.match('rendition name="' + veVideoFormat + '" url="(.*?)"');
- if (veVideo) {
- if (!ytVideoFound) ytVideoFound = true;
- if (!veVideoFound) veVideoFound = true;
- ytVideoList[veVideoFormats[veVideoFormat]] = veVideo[1];
- }
- }
- }
- }
- if (veVideoFound) break;
- }
- veVideoFound = false;
- for (var i = 0; i < veVideosJSON.video.videoVersions.length - 1; i++) {
- if (veVideosJSON.video.videoVersions[i].sourceType == 3) {
- for (var veVideoFormat in veVideoFormats) {
- veVideo = veVideosJSON.video.videoVersions[i].data.match('rendition name="' + veVideoFormat + '" url="(.*?)"');
- if (veVideo) {
- if (!ytVideoFound) ytVideoFound = true;
- if (!veVideoFound) veVideoFound = true;
- ytVideoList[veVideoFormats[veVideoFormat] + ' MP4'] = veVideo[1];
- }
- }
- }
- if (veVideoFound) break;
- }
- veVideoFound = false;
- for (var i = 0; i < veVideosJSON.video.videoVersions.length - 1; i++) {
- if (veVideosJSON.video.videoVersions[i].sourceType == 4) {
- for (var veVideoFormat in veVideoFormats) {
- veVideo = veVideosJSON.video.videoVersions[i].data.match('rendition name="' + veVideoFormat + '" url="(.*?)"');
- if (veVideo) {
- if (!ytVideoFound) ytVideoFound = true;
- if (!veVideoFound) veVideoFound = true;
- ytVideoList[veVideoFormats[veVideoFormat] + ' HD MP4'] = veVideo[1];
- }
- }
- }
- if (veVideoFound) break;
- }
- veVideoFound = false;
- for (var i = 0; i < veVideosJSON.video.videoVersions.length - 1; i++) {
- if (veVideosJSON.video.videoVersions[i].sourceType == 5 && veVideosJSON.video.videoVersions[i].version == 1) {
- veVideo = veVideosJSON.video.videoVersions[i].data.match('rendition name="HTTP Level3" url="(.*?)"');
- if (!veVideo) veVideo = veVideosJSON.video.videoVersions[i].data.match('rendition name="HTTPLevel3" url="(.*?)"');
- if (veVideo) veVideoFound = true;
- if (veVideo) getMyContentGM(veVideo[1],'TEXT',false, function (vesmilfile) {
- var veurl = yturl;
- for (veVideoFormat in veVideoFormats) {
- if (vesmilfile.match(veVideoFormat)) {
- ytVideoList[veVideoFormats[veVideoFormat]] = "http://smil.lvl3.vevo.com" + vesmilfile.match('video src="mp4:(.*?)" system-bitrate="' + veVideoFormat + '"')[1];
- }
- }
- ytPlayer(veurl);
- });
- }
- }
- if (!veVideoFound) if (ytVideoFound) ytPlayer(yturl); else showMyMessage ('!videos');
- }
- } else {
- var ytVideoFormats = {
- '5': 'Very Low Definition FLV',
- '17': 'Very Low Definition 3GP',
- '18': 'Low Definition MP4',
- '22': 'High Definition MP4',
- '34': 'Low Definition FLV',
- '35': 'Standard Definition FLV',
- '36': 'Low Definition 3GP',
- '37': 'Full High Definition MP4',
- '38': 'Ultra High Definition MP4',
- '43': 'Low Definition WebM',
- '44': 'Standard Definition WebM',
- '45': 'High Definition WebM',
- '46': 'Full High Definition WebM',
- '82': 'Low Definition 3D MP4',
- '83': 'Standard Definition 3D MP4',
- '84': 'High Definition 3D MP4',
- '85': 'Full High Definition 3D MP4',
- '100': 'Low Definition 3D WebM',
- '101': 'Standard Definition 3D WebM',
- '102': 'High Definition 3D WebM',
- '135': 'Standard Definition Video MP4',
- '136': 'High Definition Video MP4',
- '137': 'Full High Definition Video MP4',
- '138': 'Ultra High Definition Video MP4',
- '139': 'Low Bitrate Audio MP4',
- '140': 'Medium Bitrate Audio MP4',
- '141': 'High Bitrate Audio MP4',
- '171': 'Medium Bitrate Audio WebM',
- '172': 'High Bitrate Audio WebM',
- '244': 'Standard Definition Video WebM',
- '247': 'High Definition Video WebM',
- '248': 'Full High Definition Video WebM',
- '249': 'Low Bitrate Audio Opus',
- '250': 'Medium Bitrate Audio Opus',
- '251': 'High Bitrate Audio Opus',
- '266': 'Ultra High Definition Video MP4',
- '272': 'Ultra High Definition Video WebM',
- '298': 'High Definition Video MP4',
- '299': 'Full High Definition Video MP4',
- '302': 'High Definition Video WebM',
- '303': 'Full High Definition Video WebM',
- '313': 'Ultra High Definition Video WebM'
- };
- var ytVideos = ytVideosContent.split(',');
- var ytVideoParse, ytVideoCodeParse, ytVideoCode, myVideoCode, ytVideo;
- for (var i = 0; i < ytVideos.length; i++) {
- if (!ytVideos[i].match(/^url/)) {
- ytVideoParse = ytVideos[i].match(/(.*)(url=.*$)/);
- if (ytVideoParse) ytVideos[i] = ytVideoParse[2] + '&' + ytVideoParse[1];
- }
- ytVideoCodeParse = ytVideos[i].match (/itag=(\d{1,3})/);
- ytVideoCode = (ytVideoCodeParse) ? ytVideoCodeParse[1] : null;
- if (ytVideoCode) {
- myVideoCode = ytVideoFormats[ytVideoCode];
- if (myVideoCode) {
- ytVideo = ytVideos[i].replace (/url=/, '').replace(/&$/, '').replace(/&itag=\d{1,3}/, '');
- if (ytVideo.match(/type=(video|audio).*?&/)) ytVideo = ytVideo.replace(/type=(video|audio).*?&/, '');
- else ytVideo = ytVideo.replace(/&type=(video|audio).*$/, '');
- if (ytVideo.match(/&sig=/)) ytVideo = ytVideo.replace (/&sig=/, '&signature=');
- else if (ytVideo.match(/&s=/)) {
- var ytSig = ytVideo.match(/&s=(.*?)(&|$)/);
- if (ytSig) {
- var s = decryptSignature(ytSig[1]);
- ytVideo = ytVideo.replace(/&s=.*?(&|$)/, '&signature=' + s + '$1');
- }
- else ytVideo = '';
- }
- ytVideo = cleanMyContent (ytVideo, true);
- if (ytVideo && ytVideo.indexOf('http') == 0) {
- if (!ytVideoFound) ytVideoFound = true;
- ytVideoList[myVideoCode] = ytVideo;
- }
- }
- }
- }
- if (ytVideosDashmpd) {
- if (ytVideosDashmpd.match(/\/signature\//)) ytVideoList['DASH MP4'] = ytVideosDashmpd;
- else if (ytVideosDashmpd.match(/\/s\//)) {
- var ytSig = ytVideosDashmpd.match(/\/s\/(.*?)\//);
- if (ytSig) {
- var s = decryptSignature(ytSig[1]);
- ytVideoList['DASH MP4'] = ytVideosDashmpd.replace(/\/s\/.*?(\/.*$)/, '\/signature\/' + s + '$1');
- }
- }
- }
- if (ytVideoFound) {
- ytPlayer(yturl);
- }
- else {
- if (ytVideosContent.indexOf('conn=rtmp') != -1) showMyMessage ('!support');
- else showMyMessage ('!videos');
- } /* End Create Player */
- }
- }
- else {
- if (ytHLSVideos) {
- ytHLSContent = getMyContent(ytHLSVideos, 'TEXT', false);
- ytHLS(ytHLSVideos);
- }
- else {
- if (ytVideoAvailable && ytVideoAvailable.className.indexOf('hid') == -1) removeMyElement(ytPlayerWindow, myPlayerWindow)
- else showMyMessage ('!content');
- }
- }
- }
- /* Get Script URL */
- if (!ytScriptURL) ytScriptURL = getMyContent(page.url, '"js":\\s*"(.*?)"', true);
- if (!ytScriptURL) ytScriptURL = getMyContent(page.url.replace(/watch.*?v=/, 'embed/').replace(/&.*$/, ''), '"js":\\s*"(.*?)"', true);
- ytScriptURL = page.win.location.protocol + ytScriptURL;
- //+ unescape(escape(ytScriptURL).replace(/%5C/g, ''));
- var DECODEARRDAT = 'decodeArrayData';
- decodeArray = getMyOption(DECODEARRDAT);
- if (decodeArray) decodeArray = decodeArray.split(',');
- if (!ytVideosContent) {
- // try getting the video from VEVO directly if content is blocked due to geolocation filtering
- var searchitem = ytVideoTitle.replace(/\ -\ .*/g,'/').replace(/\ |\./g,'-').replace(/--/g,'-').replace(/-$/,'').replace(/\'|\)|\(|\[|\]/g,'').toLowerCase();
- searchitem = searchitem.replace(/é|è|ê|ë/g,'e').replace(/á|à|â|ä|å|æ/g,'a').replace(/ó|ò|ô|ö|ø/g,'o').replace(/í|ì|î|ï/g,'i').replace(/ú|ù|û|ü/g,'u').replace(/ç/g,'c').replace(/ý|ÿ/g,'y');
- searchitem = searchitem + ytVideoTitle.replace(/.*?\ -\ /,'').replace(/\ |\./g,'-').replace(/--/g,'').replace(/-$/,'').replace(/\'|,|:|\)|\(|\[|\]/g,'').toLowerCase();
- if (ytVideoTitle.indexOf('\ -\ ') !=-1) {
- searchstring = ytVideoTitle.replace(/\ -\ .*/g,' ').replace(/\ official\ ((music)|(video)).*|(\ ft.*)|$/i,'') + ytVideoTitle.replace(/.*?\ -\ /,'').replace(/\ official\ ((music)|(video)).*|(\ ft.*)|$/i,'');
- }
- else {
- searchstring = ytVideoTitle.replace(/\ official\ ((music)|(video)).*|(\ ft.*)|$/i,'');
- }
- var xmlHTTP = new XMLHttpRequest();
- xmlHTTP.open('POST', 'https://www.vevo.com/auth', false);
- xmlHTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
- xmlHTTP.send();
- var vevotoken = xmlHTTP.responseText.match(/"refresh_token":"(.*?)"/);
- var vevosearch = "https://apiv2.vevo.com/search?max=10&q=" + escape(searchstring.replace(/\'|\)|\(|\[|\]/g,'').replace(/\ /g,'+')) + "&token=" + vevotoken[1];
- getMyContentGM(vevosearch,'TEXT', false, function(textVevo) {
- var docurl = page.url;
- var vevoJson1 = JSON.parse(textVevo);
- var vevomatch = false;
-
- function findVevoItem (vevoJson) {
- if ((vevoJson.success === true && vevoJson.total > 0) || (vevoJson.videos && vevoJson.videos.length > 0)) {
- var veVideoID, vevoDuration, vevotitle, artistsMain, artistsFeatured;
- var searchitem = '';
- var searchartist = '';
- if (ytVideoTitle.indexOf('\ -\ ') !=-1) {
- searchartist = ytVideoTitle.replace(/\ -\ .*/g,'').replace(/\ /g,'-').replace(/--/g,'-').replace(/-$/,'').replace(/\.|\'|\)|\(|\[|\]/g,'').toLowerCase();
- // searchartist = searchartist.replace(/é|è|ê|ë/g,'e').replace(/á|à|â|ä|å|æ/g,'a').replace(/ó|ò|ô|ö|ø/g,'o').replace(/í|ì|î|ï/g,'i').replace(/ú|ù|û|ü/g,'u').replace(/ç/g,'c').replace(/ý|ÿ/g,'y');
- searchitem = '/' + searchartist;
- }
- var searchtitle = ytVideoTitle.replace(/.*?\ -\ /,'').replace(/\ /g,'-').replace(/--/g,'').replace(/-$/,'').replace(/\.|\'|,|:|\)|\(|\[|\]/g,'').toLowerCase();
- if (!vevoJson.result) vevoJson.result = vevoJson.videos;
- for (var i = 0; i < vevoJson.result.length; i++) {
- artistsMain = '';
- artistsFeatured = '';
- veVideoID = vevoJson.result[i].isrc;
- vevotitle = vevoJson.result[i].title.substring(0, 87).replace(/’/g,'\'').replace(/"/g, '\'').trim();
- if (vevoJson.result[i].artists_main) {
- for (var j = 0; j < vevoJson.result[i].artists_main.length; j++) {
- if (artistsMain.length > 0 ) artistsMain += ', ';
- artistsMain += vevoJson.result[i].artists_main[j].name;
- artistsMain = artistsMain.replace(/,?Vevo/,'');
- }
- }
- if (vevoJson.result[i].primaryArtists) {
- for (var j = 0; j < vevoJson.result[i].primaryArtists.length; j++) {
- if (artistsMain.length > 0 ) artistsMain += ', ';
- artistsMain += vevoJson.result[i].primaryArtists[j].name;
- artistsMain = artistsMain.replace(/,?Vevo/,'');
- }
- }
- if (vevoJson.result[i].artists_featured) {
- for (var j = 0; j < vevoJson.result[i].artists_featured.length; j++) {
- if (artistsFeatured.length > 0 ) artistsFeatured += ', ';
- artistsFeatured += vevoJson.result[i].artists_featured[j].name;
- }
- }
- if (vevoJson.result[i].featuredArtists) {
- for (var j = 0; j < vevoJson.result[i].featuredArtists.length; j++) {
- if (artistsFeatured.length > 0 ) artistsFeatured += ', ';
- artistsFeatured += vevoJson.result[i].featuredArtists[j].name;
- }
- }
- if (artistsMain.length > 0) searchitem = artistsMain + " - " + vevotitle;
- else searchitem = vevotitle;
- if (artistsFeatured.length > 0) searchitem = searchitem + " ft. " + artistsFeatured;
- searchitem = searchitem.replace(/’/g,'\'').replace(/"/g, '\'');
- if ((artistsMain + " - " + vevotitle) == ytVideoTitle || vevotitle == ytVideoTitle || searchitem == ytVideoTitle) {
- vevomatch = true;
- break;
- }
- }
- if (!vevomatch) for (var i = 0; i < vevoJson.result.length; i++) {
- veVideoID = vevoJson.result[i].isrc;
- if (vevoJson.result[i].duration_in_seconds && (ytVideoDuration == (vevoJson.result[i].duration_in_seconds) || ytVideoDuration == (vevoJson.result[i].duration_in_seconds + 1))) {
- vevomatch = true;
- break;
- }
- }
- if (vevomatch && veVideoID) {
- var veVideoURL = 'http://videoplayer.vevo.com/VideoService/AuthenticateVideo?isrc=' + veVideoID;
- getMyContentGM(veVideoURL,'TEXT',false,function (text){
- ytVideosContent = text;
- getYoutubeVideos(ytVideosContent, docurl);
- });
- } else {
- ytVideosContent = null;
- }
- }
- }
-
- if (vevoJson1) findVevoItem (vevoJson1);
- if (!vevomatch) { // if not found, try mobile api
- var vevosearch = "http://api.vevo.com/mobile/v1/search/videos.json?max=10&q=" + escape(searchstring.replace(/\'|\)|\(|\[|\]/g,'').replace(/\ /g,'+'));
- getMyContentGM(vevosearch,'TEXT', false, function(textVevo) {
- var vevoJson2 = JSON.parse(textVevo);
- if (vevoJson2) findVevoItem (vevoJson2);
- });
- }
- });
- }
- else if (ytScriptURL && ytVideosContent && ytVideosContent.match(/&s=/) && (!decodeArray || decodeArray.length==0)) {
- try {
- crossXmlHttpRequest({
- method:'GET',
- url:ytScriptURL,
- onload:function(response) {
- if (response.readyState === 4 && response.status === 200) {
- decodeArray = findSignatureCode(response.responseText);
- setMyOptions(DECODEARRDAT, decodeArray.toString());
- getYoutubeVideos(ytVideosContent, page.url);
- }
- }
- });
- } catch(e) { }
- } else {
- getYoutubeVideos(ytVideosContent, page.url);
- try {
- crossXmlHttpRequest({
- method:'GET',
- url:ytScriptURL,
- onload:function(response) {
- if (response.readyState === 4 && response.status === 200) {
- var retArray = findSignatureCode(response.responseText);
- if (retArray && (retArray.toString() != decodeArray.toString()) && ytVideosContent.match(/&s=/)) {
- decodeArray = retArray;
- setMyOptions(DECODEARRDAT, decodeArray.toString());
- myPlayerWindow = getMyElement ('', 'div', 'id', 'MyytWindow', -1, false);
- if (myPlayerWindow) removeMyElement(myPlayerWindow.parentNode,myPlayerWindow);
- getYoutubeVideos(ytVideosContent, page.url);
- }
- }
- }
- });
- } catch(e) { }
- }
- }
- }
-
- function onNodeInserted(e) {
- if (page.url != window.location.href) {
- myPlayerWindow = getMyElement ('', 'div', 'id', 'MyytWindow', -1, false);
- if (myPlayerWindow) removeMyElement(myPlayerWindow.parentNode,myPlayerWindow);
- }
- if (e && e.target && e.target.id=='watch7-main-container') {
- setTimeout(function() { yt_run("NodeInserted"); }, 0);
- }
- }
- if (page.url.indexOf('youtube.com/watch\?v=') != -1) yt_run();
- var content=document.getElementById('content');
- if (content) {
- var mo=window.MutationObserver||window.MozMutationObserver||window.WebKitMutationObserver;
- if(typeof mo!=='undefined') {
- var observer=new mo(function(mutations) {
- mutations.forEach(function(mutation) {
- if(mutation.addedNodes!==null) {
- for (var i=0; i<mutation.addedNodes.length; i++) {
- if (mutation.addedNodes[i].id=='watch7-main-container') {
- yt_run("Mutation");
- break;
- }
- }
- }
- });
- if (page.url != window.location.href) {
- myPlayerWindow = getMyElement ('', 'div', 'id', 'MyytWindow', -1, false);
- if (myPlayerWindow) removeMyElement(myPlayerWindow.parentNode,myPlayerWindow);
- }
- });
- observer.observe(content, {childList: true, subtree: true});
- } else { // MutationObserver fallback for old browsers
- if (document.implementation.hasFeature('MutationEvents','2.0')) {
- pagecontainer.addEventListener('DOMNodeInserted', onNodeInserted, false);
- } else {
- page.win.setInterval(function() {
- nurl = window.location.href;
- if (page.url != nurl) window.location.href = nurl;
- }, 500)
- }
- }
- }
- }
-
- // =====DailyMotion===== //
-
- else if (page.url.indexOf('dailymotion.com/video') != -1 || page.url.indexOf('dailymotion.com/playlist') != -1) {
- //setTimeout(function() {
- /* Get Player Window */
- var dmPlayerWindow = getMyElement ('', 'div', 'id', 'player_container', -1, false);
- if (!dmPlayerWindow) {
- showMyMessage ('!player');
- }
- else {
- /* Get Video Thumbnail */
- var dmVideoThumb = getMyContent (page.url, 'meta\\s+property="og:image"\\s+content="(.*?)"', false);
- var dmVideoDuration = getMyContent (page.url, 'meta\\s+property="video:duration"\\s+content="(.*?)"', false);
- if (dmVideoDuration) dmVideoDuration = parseInt(dmVideoDuration);
-
- /* Get Videos Content */
- var dmEmbed;
- if (page.url.indexOf('dailymotion.com/video') != -1) dmEmbed = page.url.replace(/\/video\//, "/embed/video/");
- else {
- var dmVideoID = getMyContent(page.url,'data-playable="(.*?)"',false)
- dmEmbed = page.url.replace(/playlist.*=/, "embed/video/");
- if (dmEmbed.indexOf("embed/video/") == -1) dmEmbed = page.url.replace(/playlist.*$/, "embed/video/"+dmVideoID);
- }
- dmVideosContent = getMyContent (dmEmbed, 'info\\s+=\\s+\\{(.*)\\}', false);
- if (!dmVideosContent) dmVideosContent = getMyContent (dmEmbed, '"qualities":\\{(.*?)\\]\\},', false);
-
- /* Player Size */
- var dmPlayerWidth, dmPlayerHeight;
- var dmPlayerWideWidth, dmPlayerWideHeight;
- var dmSidebarMarginWide;
- function dmGetSizes() {
- dmPlayerWidth = dmPlayerWindow.clientWidth;
- dmPlayerHeight = Math.ceil(dmPlayerWidth / (16 / 9)) + 22;
- dmPlayerWideWidth = dmPlayerWidth + 320;
- dmPlayerWideHeight = Math.ceil(dmPlayerWideWidth / (16 / 9)) + 22;
- dmSidebarMarginWide = dmPlayerWideHeight + 30
- }
- function dmUpdateSizes() {
- setTimeout(function() {
- dmGetSizes();
- player['playerWidth'] = dmPlayerWidth;
- player['playerHeight'] = dmPlayerHeight;
- player['playerWideWidth'] = dmPlayerWideWidth;
- player['playerWideHeight'] = dmPlayerWideHeight;
- player['sidebarMarginWide'] = dmSidebarMarginWide;
- resizeMyPlayer(player, 'widesize');
- styleMyElement (dmPlayerWindow, {overflow: 'visible', height: '100%'});
- },350);
- }
- dmGetSizes();
-
- /* My Player Window */
- var myPlayerWindow = createMyElement ('div', '', '', '', '');
- styleMyElement (myPlayerWindow, {position: 'relative',width: dmPlayerWidth + 'px', height: dmPlayerHeight + 'px', backgroundColor: '#F4F4F4', zIndex: '99999'});
- modifyMyElement (dmPlayerWindow, 'div', '', false, true);
- // styleMyElement (dmPlayerWindow, {overflow: 'visible', height: '100%'});
- appendMyElement (dmPlayerWindow, myPlayerWindow);
- blockObject = dmPlayerWindow;
-
- /* Fix Visibility & Height */
- var dmPlayerJSBox = getMyElement ('', 'div', 'class', 'js-player-box', 0, false);
- if (dmPlayerJSBox) styleMyElement(dmPlayerJSBox, {overflow: 'visible', height: '100%', backgroundColor: '#F4F4F4'});
- else styleMyElement(dmPlayerWindow.parentNode, {overflow: 'visible', height: '100%', backgroundColor: '#F4F4F4'});
- page.win.setTimeout(function() {styleMyElement (dmPlayerWindow, {overflow: 'visible', height: '100%'});}, 2000);
-
- /* Fix Video Info Position */
- var dmPlayerInfos = getMyElement ('', 'div', 'class', 'pl_video_infos', 0, false);
- if (dmPlayerInfos) styleMyElement(dmPlayerInfos, {marginTop: '10px'});
-
- /* Hide Top Ads */
- var dmMcTop = getMyElement ('', 'div', 'id', 'mc_Top', -1, false);
- if (dmMcTop) styleMyElement(dmMcTop, {display: 'none'});
-
- /* Get Videos */
- if (dmVideosContent) {
- var dmVideoFormats = {'240': 'Very Low Definition MP4', '380': 'Low Definition MP4', '480': 'Standard Definition MP4',
- '720': 'High Definition MP4', '1080': 'Full High Definition MP4', '.*?x-mpegURL': 'HTTP Live Streaming M3U8'};
- var dmVideoList = {};
- var dmVideoFound = false;
- var dmVideoParser, dmVideoParse, myVideoCode, dmVideo;
- for (var dmVideoCode in dmVideoFormats) {
- dmVideoParser = '"' + dmVideoCode + '(":.*?"url)?":"(.*?)"';
- dmVideoParse = dmVideosContent.match (dmVideoParser);
- dmVideo = (dmVideoParse) ? dmVideoParse[2] : null;
- if (dmVideo) {
- if (!dmVideoFound) dmVideoFound = true;
- dmVideo = cleanMyContent(dmVideo, true);
- myVideoCode = dmVideoFormats[dmVideoCode];
- if (!dmVideoList[myVideoCode]) dmVideoList[myVideoCode] = dmVideo;
- }
- }
-
- if (dmVideoFound) {
- /* Get Watch Sidebar */
- var dmSidebarWindow = getMyElement ('', 'div', 'class', 'col-3', 0, false);
- if (!dmSidebarWindow) {
- dmSidebarWindow = getMyElement ('', 'div', 'class', 'col-4', 0, false);
- if (dmSidebarWindow) styleMyElement (dmSidebarWindow, {marginLeft: '40px'});
- }
-
- /* Create Player */
- var dmDefaultVideo = 'Low Definition MP4';
- var player = {
- 'playerSocket': dmPlayerWindow,
- 'playerWindow': myPlayerWindow,
- 'videoList': dmVideoList,
- 'videoPlay': dmDefaultVideo,
- 'videoThumb': dmVideoThumb,
- 'videoDuration': dmVideoDuration,
- 'playerWidth': dmPlayerWidth,
- 'playerHeight': dmPlayerHeight,
- 'playerWideWidth': dmPlayerWideWidth,
- 'playerWideHeight': dmPlayerWideHeight,
- 'sidebarWindow': dmSidebarWindow,
- 'sidebarMarginNormal': 0,
- 'sidebarMarginWide': dmSidebarMarginWide
- };
- feature['container'] = false;
- option['definitions'] = ['Full High Definition', 'High Definition', 'Standard Definition', 'Low Definition', 'Very Low Definition'];
- option['containers'] = ['MP4'];
- createMyPlayer (player);
-
- /* Resize Event */
- page.win.addEventListener('resize', dmUpdateSizes, false);
-
- /* Fix Right Ad Issue */
- var dmMcRight = getMyElement ('', 'div', 'id', 'mc_Right', -1, false);
- if (dmMcRight) {
- var dmWaitForAdTime = 20;
- var dmPlayerWidthPrev = dmPlayerWidth;
- var dmWaitForAdFunc = page.win.setInterval(function() {
- if(dmMcRight.clientWidth) {
- if (dmPlayerWidth != dmPlayerWindow.clientWidth) {
- dmUpdateSizes();
- clearInterval(dmWaitForAdFunc);
- }
- }
- dmWaitForAdTime--;
- if (dmWaitForAdTime == 0) clearInterval(dmWaitForAdFunc);
- }, 500);
- }
-
- /* Fix panel */
- styleMyElement(player['playerContent'], {marginTop: '7px'});
-
- } else {
- showMyMessage ('!videos');
- }
- } else {
- showMyMessage ('!content');
- }
- }
- //}, 0);
-
- }
-
- // =====Vimeo===== //
-
- else if (page.url.match(/https?:\/\/(www\.)?vimeo.com\//)) {
-
- function vimeo_run(viPlayerId) {
- if (viPlayerId && page.url == window.location.href) return;
- page = {win: window, doc: document, body: document.body, url: window.location.href};
-
- var PlayerHeight, PlayerWidth, viVideo, myVideoCode;
- var viVideoID = null;
- var viVideoSignature = null;
- var viVideoTimestamp = null;
- var viPlayerWindow = null;
- var viVideoRegex;
- var viVideoFormats = {'hd': 'High Definition MP4', 'sd': 'Low Definition MP4', 'mobile': 'Very Low Definition MP4'};
-
- /* Get Player Window */
- for (i=0; i<getMyElement ('', 'div', 'class', 'player_container', -1, false).length; i++) {
-
- viPlayerWindow = getMyElement ('', 'div', 'class', 'player_container', i, false);
- PlayerHeight = viPlayerWindow.clientHeight + 22;
- PlayerWidth = viPlayerWindow.clientWidth;
- if (!viPlayerWindow) {
- showMyMessage ('!player');
- }
- else {
- {
- /* Get Videos Content */
- // viVideoRegex = 'data-fallback-url=".*\\/(\\d{1,10})\\/.*"';
- viVideoRegex = 'data-fallback-url=".*?(\\d{6,10})\\/.*?"';
- viVideoID = page.body.innerHTML.match(RegExp(viVideoRegex,'g'))[i];
- if (viVideoID) viVideoID = viVideoID.match(RegExp(viVideoRegex))[1];
- viVideoURL = page.win.location.protocol + "//vimeo.com/" + viVideoID;
- crossXmlHttpRequest({
- method:'GET',
- url: viVideoURL,
- onload:function(response) {
- var viVideoSource = response.responseText.match('data-config-url="(.*?)"')[1].replace(/&/g, '&');
- crossXmlHttpRequest({
- method:'GET',
- url: viVideoSource,
- onload:function(response) { //asynchronous
- if (response.readyState === 4 && response.status === 200) {
- /* Get Videos */
- var viVideosContent = JSON.parse(response.responseText);
- var viVideoList = {};
- var viVideoFound = false;
- if (viVideosContent) {
- var viVideoID = viVideosContent.video.id;
- var viVideoThumb = viVideosContent.video.thumbs['960'];
- if (!viVideoThumb) viVideoThumb = viVideosContent.video.thumbs['1280'];
- if (!viVideoThumb) viVideoThumb = viVideosContent.video.thumbs['640'];
- var viVideoDuration = viVideosContent.video.duration;
- }
- else {
- showMyMessage ('!content');
- }
- }
- /* My Player Window */
- myPlayerWindow = createMyElement ('div', '', '', '', '');
- styleMyElement (myPlayerWindow, {position: 'relative', width: PlayerWidth + 'px', height: PlayerHeight + 'px', backgroundColor: '#F4F4F4', zIndex: '99999'});
- var viPlayerWindow = getMyElement ('', 'div', 'class', 'player_container', -1, false);
- // var viVideoRegex = 'data-fallback-url=".*\\/(\\d{1,10})\\/.*"';
- var viVideoRegex = 'data-fallback-url=".*?(\\d{6,10})\\/.*?"';
- for (i=0;i<viPlayerWindow.length;i++) {
- if (viPlayerWindow[i].innerHTML.match(viVideoRegex) && viPlayerWindow[i].innerHTML.match(viVideoRegex)[1] == viVideoID) {
- viPlayerWindow = viPlayerWindow[i];
- break;
- }
- }
- var viPlayerElement = getMyElement (viPlayerWindow, 'div', 'class', 'player', 0, false);
- cleanMyElement (viPlayerElement, true);
- modifyMyElement (viPlayerElement, 'div', '', true);
- styleMyElement (viPlayerWindow, {height: '100%'});
- appendMyElement (viPlayerWindow, myPlayerWindow);
- var viVideoCodec = viVideosContent.request.files.codecs[0];
- if (viVideosContent) {
- for (var viVideoCode in viVideoFormats) {
- if (viVideosContent.request.files[viVideoCodec]) {
- myVideoCode = viVideoFormats[viVideoCode];
- if (viVideosContent.request.files[viVideoCodec][viVideoCode]) {
- viVideoFound = true;
- viVideoList[myVideoCode] = viVideosContent.request.files[viVideoCodec][viVideoCode].url;
- }
- }
- }
- }
-
- if (viVideoFound) {
- /* Create Player */
- var viDefaultVideo = 'Low Definition MP4';
- var player = {
- 'playerSocket': viPlayerWindow,
- 'playerWindow': myPlayerWindow,
- 'videoList': viVideoList,
- 'videoPlay': viDefaultVideo,
- 'videoThumb': viVideoThumb,
- 'videoDuration': viVideoDuration,
- 'playerWidth': PlayerWidth,
- 'playerHeight': PlayerHeight
- };
- feature['container'] = false;
- feature['widesize'] = false;
- option['definitions'] = ['High Definition', 'Low Definition', 'Very Low Definition'];
- option['containers'] = ['MP4'];
- createMyPlayer (player);
- }
- else {
- showMyMessage ('!videos');
- }
-
- }
- });
- }
- });
- }
- }
- }
- }
-
- function onNodeInserted(e) {
- if (e && e.target && (typeof e.target.className !== 'undefined') && e.target.className.className == 'video-wrapper') {
- setTimeout(function() { vimeo_run(); }, 0);
- }
- }
-
- var pagecontainer = getMyElement ('', 'div', 'class', 'player_container', 0, false);
- vimeo_run();
- var content=document.getElementById('content');
- window.addEventListener("hashchange", onNodeInserted(), false)
- if (content) {
- var mo=window.MutationObserver||window.MozMutationObserver||window.WebKitMutationObserver;
- if(typeof mo!=='undefined') {
- var observer=new mo(function(mutations) {
- mutations.forEach(function(mutation) {
- if(mutation.addedNodes!==null && mutation.addedNodes.length > 0) {
- for (var i=0; i<mutation.addedNodes.length; i++) {
- if (typeof mutation.addedNodes[i].className !== 'undefined') if (mutation.addedNodes[i].className == 'video-wrapper') {
- vimeo_run(mutation.addedNodes);
- break;
- }
- }
- }
- });
- });
- observer.observe(content, {childList: true, subtree: true});
- } else {
- page.win.setInterval(function() {
- nurl = window.location.href;
- if (page.url != nurl) window.location.href = nurl;
- }, 500)
- }
- }
-
- }
-
- // VEVO
- else if (page.url.match(/https?:\/\/(www\.)?vevo.com\//)) {
- var oldurl;
- var vePlayerWindow
-
- function vevo_run(vePlayerId) {
- if (oldurl == page.url) return;
- oldurl = page.url;
- function createMyvePlayer() {
- var veDefaultVideo = 'Standard Definition MP4';
- var player = {
- 'playerSocket': vePlayerWindow,
- 'playerWindow': myPlayerWindow,
- 'videoList': veVideoList,
- 'videoPlay': veDefaultVideo,
- 'videoThumb': veVideoThumb,
- 'videoDuration': veVideoDuration,
- 'playerWidth': PlayerWidth,
- 'playerHeight': PlayerHeight
- };
- feature['container'] = false;
- feature['widesize'] = false;
- feature['fullsize'] = true;
- option['definitions'] = ['Ultra High Definition', 'Full High Definition', 'High Definition', 'Standard Definition', 'Low Definition', 'Very Low Definition'];
- option['containers'] = ['MP4'];
- HeadWindow = getMyElement('', 'div', 'class', 'site ng-scope', 0, false);
- createMyPlayer (player);
- }
-
- var PlayerHeight, PlayerWidth, veVideo, myVideoCode;
- var veVideoFormats = {
- 'High': 'High Definition MP4'
- ,'Med': 'Standard Definition MP4'
- ,'Low': 'Ultra Low Definition MP4'
- ,'564000': 'Very Low Definition MP4'
- ,'864000': 'Low Definition MP4'
- ,'1328000':'Standard Definition MP4'
- ,'1728000':'Standard Definition HBR MP4'
- ,'2528000':'High Definition MP4'
- ,'3328000':'High Definition HBR MP4'
- ,'4392000':'Full High Definition MP4'
- ,'5392000':'Full High Definition HBR MP4'
- };
- var veVideoList = {};
- var veVideoFound1 = false;
- var veVideoFound2 = false;
- /* Get Player Window */
- vePlayerWindow = getMyElement ('', 'div', 'class', 'player', 0, false);
- var vePlayer = getMyElement(vePlayerWindow, 'div', 'class', 'flash-player', 0, false);
- PlayerHeight = vePlayer.clientHeight;
- PlayerWidth = vePlayer.clientWidth;
- if (!vePlayerWindow) {
- showMyMessage ('!player');
- }
- else {
- {
- /* Get Videos Content */
- var veVideoID = page.url.match(/((https?:\/\/(www\.)?vevo.com\/watch.*\/)|(vevo:))(\w{10,12})(\?|$)/);
- veVideoID = veVideoID ? veVideoID[5] : null;
- if (!veVideoID) veVideoID = getMyContent(page.url,'playerType=.*videoId=(.*?)\&',false);
- var veVideoPlayer = getMyContent(page.url, 'meta\\s+property="og:video"\\s+content="(.*?)"', false);
- var veVideoURL = 'https://svideoplayer.vevo.com/VideoService/AuthenticateVideo?isrc=' + veVideoID;
- var veVideosContent = getMyContent(veVideoURL, 'TEXT', false);
- if (veVideosContent) {
- var veVideosJSON = JSON.parse(veVideosContent);
- var veVideoThumb = veVideosContent.match('"imageUrl":"(.*?)"');
- if (veVideoThumb) veVideoThumb = veVideoThumb[1];
- }
- else {
- showMyMessage ('!content');
- }
- cleanMyElement (vePlayerWindow, false);
-
- /* My Player Window */
- myPlayerWindow = createMyElement ('div', '', '', '', '');
- styleMyElement (myPlayerWindow, {position: 'relative', width: PlayerWidth + 'px', height: PlayerHeight + 'px', backgroundColor: '#F4F4F4', zIndex: '18',fontFamily: '"Arial","Helvetica","sans-serif"'});
- styleMyElement (vePlayer, {display: 'none'});
- appendMyElement (vePlayerWindow, myPlayerWindow);
-
- var veInfoWindow = getMyElement ('', 'div', 'class', 'watch-info', 0, false);
- styleMyElement (veInfoWindow, {position: 'absolute', top: '0px', left: Math.floor(PlayerWidth + 1) + 'px'});
-
- if (veVideosJSON) {
- var veVideo, veVideoVersion;
- for (var i = 0; i < veVideosJSON.video.videoVersions.length - 1; i++) {
- if (veVideosJSON.video.videoVersions[i].sourceType == 2) {
- if (veVideosJSON.video.videoVersions[i].version in {3:1,4:1}) {
- for (var veVideoFormat in veVideoFormats) {
- veVideo = veVideosJSON.video.videoVersions[i].data.match('rendition name="' + veVideoFormat + '" url="(.*?)"');
- if (veVideo) {
- if (!veVideoFound1) veVideoFound1 = true;
- if (!veVideoFound2) veVideoFound2 = true;
- veVideoList[veVideoFormats[veVideoFormat]] = veVideo[1];
- }
- }
- }
- }
- if (veVideoFound) break;
- }
- veVideoFound = false;
- for (var i = 0; i < veVideosJSON.video.videoVersions.length - 1; i++) {
- if (veVideosJSON.video.videoVersions[i].sourceType == 3) {
- for (var veVideoFormat in veVideoFormats) {
- veVideo = veVideosJSON.video.videoVersions[i].data.match('rendition name="' + veVideoFormat + '" url="(.*?)"');
- if (veVideo) {
- if (!veVideoFound1) veVideoFound1 = true;
- if (!veVideoFound2) veVideoFound2 = true;
- veVideoList[veVideoFormats[veVideoFormat] + ' MP4'] = veVideo[1];
- }
- }
- }
- if (veVideoFound) break;
- }
- veVideoFound = false;
- for (var i = 0; i < veVideosJSON.video.videoVersions.length - 1; i++) {
- if (veVideosJSON.video.videoVersions[i].sourceType == 4) {
- for (var veVideoFormat in veVideoFormats) {
- veVideo = veVideosJSON.video.videoVersions[i].data.match('rendition name="' + veVideoFormat + '" url="(.*?)"');
- if (veVideo) {
- if (!veVideoFound1) veVideoFound1 = true;
- if (!veVideoFound2) veVideoFound2 = true;
- veVideoList[veVideoFormats[veVideoFormat] + ' HD MP4'] = veVideo[1];
- }
- }
- }
- if (veVideoFound2) break;
- }
- veVideoFound2 = false;
- for (var i = 0; i < veVideosJSON.video.videoVersions.length - 1; i++) {
- if (veVideosJSON.video.videoVersions[i].sourceType == 5 && veVideosJSON.video.videoVersions[i].version == 1) {
- veVideo = veVideosJSON.video.videoVersions[i].data.match('rendition name="HTTP Level3" url="(.*?)"');
- if (!veVideo) veVideo = veVideosJSON.video.videoVersions[i].data.match('rendition name="HTTP Level3" url="(.*?)"');
- if (veVideo) veVideoFound2 = true;
- if (veVideo) getMyContentGM(veVideo[1],'TEXT',false, function (vesmilfile) {
- for (veVideoFormat in veVideoFormats) {
- if (vesmilfile.match(veVideoFormat)) {
- veVideoList[veVideoFormats[veVideoFormat]] = "http://smil.lvl3.vevo.com" + vesmilfile.match('video src="mp4:(.*?)" system-bitrate="' + veVideoFormat + '"')[1];
- }
- }
- createMyvePlayer();
- });
- }
- }
- if (!veVideoFound2) if (veVideoFound1) createMyvePlayer(); else showMyMessage ('!videos');
- }
- }
- }
- }
-
- function start_vevo() {
- var elWait = 50;
- page = {win: window, doc: document, body: document.body, url: window.location.href}
- var refreshIntervalId = page.win.setInterval(function() {
- if (getMyElement ('', 'div', 'class', 'flash-player', 0, false) && getMyContent(page.url,'playerType=.*videoId=(.*?)\&',false)) {
- page.win.clearInterval(refreshIntervalId);
- vevo_run();
- } else if (elWait > 0) {
- elWait--;
- } else page.win.clearInterval(refreshIntervalId);
- }, 500);
- }
-
- start_vevo();
-
- page.win.setInterval(function() {
- nurl = window.location.href;
- if (page.url != nurl) {
- // window.location.href = nurl;
- page.url = nurl;
- console.log(page.url);
- start_vevo();
- }
- }, 500)
- }
-
- // =====MetaCafe===== //
-
- else if (page.url.indexOf('metacafe.com/watch') != -1) {
- /* Get Player Window */
- var mcPlayerWindow = getMyElement ('', 'div', 'id', 'FlashWrap', -1, false);
- if (!mcPlayerWindow) mcPlayerWindow = getMyElement ('', 'div', 'id', 'ItemContainer', -1, false);
- if (!mcPlayerWindow) {
- showMyMessage ('!player');
- }
- else {
- /* Check Video Availability */
- if (mcPlayerWindow.innerHTML.indexOf('This Video cannot be played on this device.') != -1) return;
-
- /* Get Video Thumbnail */
- var mcVideoThumb = getMyContent (page.url, 'meta\\s+property="og:image"\\s+content="(.*?)"', false);
- var mcVideoDuration = getMyContent (page.url, 'meta\\s+property="video:duration"\\s+content="(.*?)"', false);
- if (mcVideoDuration) mcVideoDuration = parseInt(mcVideoDuration);
-
- /* Get Videos Content */
- var mcVideosContent, mcVideo;
- var mcFlashVideo = getMyElement (mcPlayerWindow, 'embed', 'tag', '', 0, false) || getMyElement (mcPlayerWindow, 'object', 'tag', '', 0, false);
- if (mcFlashVideo) {
- mcVideosContent = getMyContent (page.url, '"mediaData":"(.*?)"', false);
- if (!mcVideosContent) {
- var anyClipId = page.url.match(/\/an-(.*?)\//);
- if (anyClipId && anyClipId[1]) {
- mcVideo = 'http://vid2.anyclip.com/' + anyClipId[1];
- }
- }
- }
- else mcVideo = getMyContent (page.url, 'video\\s+src="(.*?)"', false);
-
- /* My Player Window */
- myPlayerWindow = createMyElement ('div', '', '', '', '');
- var PlayerHeight = mcPlayerWindow.clientHeight + 22;
- var PlayerWidth = mcPlayerWindow.clientWidth;
- styleMyElement (myPlayerWindow, {position: 'relative', width: PlayerWidth + 'px', height: PlayerHeight + 'px', backgroundColor: '#F4F4F4', zIndex: '99999'});
- styleMyElement (mcPlayerWindow, {height: '100%'});
- cleanMyElement (mcPlayerWindow, false);
- if (mcPlayerWindow.children[0] && mcPlayerWindow.children[0].href == "http://get.adobe.com/flashplayer") removeMyElement(mcPlayerWindow, mcPlayerWindow.children[0]);
- appendMyElement (mcPlayerWindow, myPlayerWindow);
- blockObject = mcPlayerWindow;
-
- /* Get Videos */
- if (mcVideosContent || mcVideo) {
- var mcVideoList = {};
- var mcVideoFound = false;
- if (mcVideosContent) {
- mcVideosContent = cleanMyContent(mcVideosContent, true);
- var mcVideoFormats = {'highDefinitionMP4': 'High Definition MP4', 'MP4': 'Low Definition MP4', 'flv': 'Low Definition FLV'};
- var mcVideoParser, mcVideoParse, myVideoCode, mcVideoPath, mcVideoKey, mcVideo;
- for (var mcVideoCode in mcVideoFormats) {
- mcVideoParser = '"' + mcVideoCode + '":\\{.*?"mediaURL":"(.*?)","access":\\[\\{"key":"(.*?)","value":"(.*?)"\\}\\]\\}';
- mcVideoParse = mcVideosContent.match (mcVideoParser);
- mcVideoPath = (mcVideoParse) ? mcVideoParse[1] : null;
- mcVideoKeyName = (mcVideoParse) ? mcVideoParse[2] : null;
- mcVideoKeyValue = (mcVideoParse) ? mcVideoParse[3] : null;
- if (mcVideoPath && mcVideoKeyName && mcVideoKeyValue) {
- if (!mcVideoFound) mcVideoFound = true;
- myVideoCode = mcVideoFormats[mcVideoCode];
- mcVideo = mcVideoPath + '?' + mcVideoKeyName + '=' + mcVideoKeyValue;
- mcVideoList[myVideoCode] = mcVideo;
- }
- }
- }
- else {
- mcVideoList['Low Definition MP4'] = mcVideo;
- mcVideoFound = true;
- feature['definition'] = false;
- feature['container'] = false;
- }
-
- if (mcVideoFound) {
- /* Get Watch Sidebar */
- var mcSidebarWindow = getMyElement ('', 'div', 'id', 'Sidebar', -1, false);
-
- /* Create Player */
- var mcDefaultVideo = (mcVideoList['Low Definition MP4']) ? 'Low Definition MP4' : 'Low Definition FLV';
- var player = {
- 'playerSocket': mcPlayerWindow,
- 'playerWindow': myPlayerWindow,
- 'videoList': mcVideoList,
- 'videoPlay': mcDefaultVideo,
- 'videoThumb': mcVideoThumb,
- 'videoDuration': mcVideoDuration,
- 'playerWidth': PlayerWidth,
- 'playerHeight': PlayerHeight,
- 'playerWideWidth': 960,
- 'playerWideHeight': 562,
- 'sidebarWindow': mcSidebarWindow,
- 'sidebarMarginNormal': 0,
- 'sidebarMarginWide': 576
- };
- option['definitions'] = ['High Definition', 'Low Definition'];
- option['containers'] = ['MP4', 'FLV', 'Any'];
- HeadWindow = getMyElement ('', 'div', 'id', 'HeaderContainer', -1, false);
- createMyPlayer (player);
- }
- else {
- showMyMessage ('!videos');
- }
- }
- else {
- var ytVideoId = page.url.match (/\/yt-(.*?)\//);
- if (ytVideoId && ytVideoId[1]) {
- var ytVideoLink = 'http://youtube.com/watch?v=' + ytVideoId[1];
- showMyMessage ('embed', ytVideoLink);
- }
- else {
- showMyMessage ('!content');
- }
- }
- }
-
- }
-
- // =====Break===== //
-
- else if (page.url.indexOf('break.com/video') != -1) {
-
- /* Get Player Window */
- var brPlayerWindow = getMyElement ('', 'div', 'id', 'video-player', -1, false);
- if (!brPlayerWindow) {
- showMyMessage ('!player');
- }
- else {
- /* Get Video ID */
- var brVideoID = getMyContent(page.url, 'id="js-video-player-iframe".*?src="/embed/(\\d+)(\\?|")',false);
- if (!brVideoID) brVideoID = getMyContent (page.url, 'meta\\s+name="embed_video_url"\\s+content=".*/(\\d+)/"', false);
- if (!brVideoID) {
- brVideoID = page.url.match(/(\d+)$/);
- brVideoID = (brVideoID) ? brVideoID[1] : null;
- }
-
- /* Get Videos Content */
- var brSource = page.win.location.protocol + '//' + page.win.location.hostname + '/embed/' + brVideoID;
- var brVideosContent = getMyContent (brSource, 'TEXT', false);
-
- /* My Player Window */
- myPlayerWindow = createMyElement ('div', '', '', '', '');
- styleMyElement (myPlayerWindow, {position: 'relative', width: '592px', height: '356px', backgroundColor: '#F4F4F4'});
- modifyMyElement (brPlayerWindow, 'div', '', true);
- styleMyElement (brPlayerWindow, {height: '100%', overflow: 'visible'});
- appendMyElement (brPlayerWindow, myPlayerWindow);
-
- /* Get Videos */
- if (brVideosContent) {
- var brVideoList = {};
- var brVideoFormats = {};
- var brVideoFound = false;
- 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'};
- var brVideoPath, brVideoToken, brVideoThumb, brVideo, myVideoCode;
- // brVideoPath = brVideosContent.match (/"videoUri":\s"(.*?)"/);
- brVideoPath = brVideosContent.match (/"videoUri":\s"(.*?)496_kbps/);
- brVideoPath = (brVideoPath) ? brVideoPath[1] : null;
- brVideoToken = brVideosContent.match (/"AuthToken":\s"(.*?)"/);
- brVideoToken = (brVideoToken) ? brVideoToken[1] : null;
- brVideoThumb = brVideosContent.match (/"thumbUri":\s"(.*?)"/);
- brVideoThumb = (brVideoThumb) ? brVideoThumb[1] : null;
- if (brVideoPath && brVideoToken) {
- for (var brVideoCode in brVideoFormats) {
- if (brVideosContent.match(brVideoPath + brVideoCode)) {
- if (!brVideoFound) brVideoFound = true;
- myVideoCode = brVideoFormats[brVideoCode];
- brVideo = brVideoPath + brVideoCode + '?' + brVideoToken;
- brVideoList[myVideoCode] = brVideo;
- }
- }
- }
-
- if (brVideoFound) {
- /* Get Watch Sidebar */
- var brSidebarWindow = getMyElement ('', 'aside', 'class', 'sidebar', 0, false);
-
- /* Create Player */
- var brDefaultVideo = 'Low Definition MP4';
- var brWindowWidth = page.win.innerWidth || page.doc.documentElement.clientWidth;
- var brPlayerWidth, brPlayerHeight;
- if (brWindowWidth > 1400) {
- brPlayerWidth = 832;
- brPlayerHeight = 490;
- }
- else {
- brPlayerWidth = 592;
- brPlayerHeight = 356;
- }
- var player = {
- 'playerSocket': brPlayerWindow,
- 'playerWindow': myPlayerWindow,
- 'videoList': brVideoList,
- 'videoPlay': brDefaultVideo,
- 'videoThumb': brVideoThumb,
- 'playerWidth': brPlayerWidth,
- 'playerHeight': brPlayerHeight,
- 'playerWideWidth': 910,
- 'playerWideHeight': 534,
- 'sidebarWindow': brSidebarWindow,
- 'sidebarMarginNormal': 10,
- 'sidebarMarginWide': 720
- };
- if (brWindowWidth > 1400) feature['widesize'] = false;
- option['definitions'] = ['Very Low Definition', 'Low Definition', 'Standard Definition', 'High Definition'];
- option['containers'] = ['MP4', 'FLV', 'Any'];
- createMyPlayer (player);
- }
- else {
- var ytVideoId = brVideosContent.match (/"youtubeId":\s"(.*?)"/);
- if (ytVideoId && ytVideoId[1]) {
- var ytVideoLink = 'http://youtube.com/watch?v=' + ytVideoId[1];
- showMyMessage ('embed', ytVideoLink);
- }
- else {
- showMyMessage ('!videos');
- }
- }
- }
- else {
- showMyMessage ('!content');
- }
- }
-
- }
-
- // =====FunnyOrDie===== //
- else if (page.url.match(/https?:\/\/(www\.)?funnyordie.com\/videos\/[0-9a-z]{3,10}\//)) {
-
- function fod_run(viPlayerId) {
- /* Get Player Window */
- var fodPlayerWindow = getMyElement ('', 'div', 'id', 'player-container', -1, false);
- if (!fodPlayerWindow) {
- showMyMessage ('!player');
- }
- else {
- /* Get Video Thumbnail */
- var fodVideoThumb = getMyContent (page.url, 'meta\\s+property="og:image"\\s+content="(.*?)"', false);
- if (fodVideoThumb) fodVideoThumb = fodVideoThumb.replace (/large/, 'fullsize');
-
- /* Get Videos Content */
- var fodVideosContent = getMyContent (page.url, '<video([\\s\\S]*?)video>', false);
-
- /* Clean Player Window */
- var fodPlayerContainer = getMyElement ('', 'div', 'id', 'videoContainer', -1, false);
- var PlayerHeight = fodPlayerContainer.clientHeight + 22;
- var PlayerWidth = fodPlayerContainer.clientWidth;
- if (fodPlayerContainer) styleMyElement (fodPlayerContainer, {display: 'none'});
- blockObject = fodPlayerContainer;
-
- /* My Player Window */
- myPlayerWindow = createMyElement ('div', '', '', '', '');
- styleMyElement (myPlayerWindow, {position: 'relative', width: PlayerWidth + 'px', height: PlayerHeight + 'px', backgroundColor: '#F4F4F4', margin: '0px auto'});
- styleMyElement (fodPlayerWindow, {height: '100%', overflow: 'visible'});
- fodPlayerContainer.parentNode.insertBefore (myPlayerWindow, fodPlayerContainer);
-
- /* Get Videos */
- if (fodVideosContent) {
- 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'};
- var fodVideoList = {};
- var fodVideoFound = false;
- var fodVideoPath, fodVideoCodes, fodVideo, myVideoCode;
- fodVideoPath = fodVideosContent.match(/src="(.*?)v\d+.*?\.mp4"/);
- fodVideoPath = (fodVideoPath) ? fodVideoPath[1] : null;
- fodVideoCodes = fodVideosContent.match (/src=".*?\/v,(.*?),\./);
- if (!fodVideoCodes) fodVideoCodes = fodVideosContent.match (/src=".*?\/v(\d{3,4})\./);
- fodVideoCodes = (fodVideoCodes) ? fodVideoCodes[1] : '';
- if (fodVideoPath && fodVideoCodes) {
- for (var fodVideoCode in fodVideoFormats) {
- if (fodVideoCodes.indexOf(fodVideoCode.replace(/v/, '').replace(/\..*/, "")) != -1) {
- if (!fodVideoFound) fodVideoFound = true;
- fodVideo = fodVideoPath + fodVideoCode;
- myVideoCode = fodVideoFormats[fodVideoCode];
- fodVideoList[myVideoCode] = fodVideo;
- }
- }
- }
- else {
- fodVideoPath = fodVideosContent.match(/href="(.*?)v\d+.mp4"/);
- fodVideoPath = (fodVideoPath) ? fodVideoPath[1] : null;
- if (fodVideoPath) {
- if (!fodVideoFound) fodVideoFound = true;
- for (var fodVideoCode in fodVideoFormats) {
- fodVideo = fodVideoPath + fodVideoCode;
- myVideoCode = fodVideoFormats[fodVideoCode];
- fodVideoList[myVideoCode] = fodVideo;
- }
- }
- }
-
- if (fodVideoFound) {
- /* Create Player */
- fodDefaultVideo = 'Low Definition MP4';
- var player = {
- 'playerSocket': fodPlayerWindow,
- 'playerWindow': myPlayerWindow,
- 'videoList': fodVideoList,
- 'videoPlay': fodDefaultVideo,
- 'videoThumb': fodVideoThumb,
- 'playerWidth': PlayerWidth,
- 'playerHeight': PlayerHeight
- };
- feature['container'] = false;
- feature['widesize'] = false;
- option['definitions'] = ['High Definition', 'Low Definition'];
- option['containers'] = ['MP4'];
- createMyPlayer (player);
- styleMyElement (player['playerPanel'], {height: '24px'});
- }
- else {
- showMyMessage ('!videos');
- }
- }
- else {
- showMyMessage ('!content');
- }
- }
- }
-
- function onNodeInserted(e) {
- if (e && e.target && e.target.textContent == "10") {
- nurl = window.location.href;
- if (page.url != nurl) window.location.href = nurl;
- }
- }
-
- fod_run();
- var pagecontainer = getMyElement ('', 'div', 'id', 'player-container', -1, false)
- if (pagecontainer) {
- var mo=window.MutationObserver||window.MozMutationObserver||window.WebKitMutationObserver;
- if(typeof mo!=='undefined') {
- var observer=new mo(function(mutations) {
- mutations.forEach(function(mutation) {
- if(mutation.addedNodes!==null && mutation.addedNodes.length > 0) {
- for (var i=0; i<mutation.addedNodes.length; i++) {
- if (mutation.addedNodes[0].textContent == "10") {
- nurl = window.location.href;
- if (page.url != nurl) window.location.href = nurl;
- break;
- }
- }
- }
- });
- });
- observer.observe(pagecontainer, {childList: true, subtree: true});
- } else { // MutationObserver fallback for old browsers
- pagecontainer.parentNode.addEventListener('DOMNodeInserted', onNodeInserted, false);
- }
- }
- }
-
- // =====Videojug===== //
- else if (page.url.indexOf('videojug.com') != -1) {
-
- /* Get Player Window */
- var vjPlayerWindow;
- var vjPlayerWidth = 640;
- var vjPlayerHeight = 384;
- var vjPlayerWide = true;
- if (page.url.indexOf("videojug.com/film") != -1) vjPlayerWindow = getMyElement ('', 'div', 'class', 'top-border-only', 0, false);
- else if (page.url.indexOf("videojug.com/series") != -1) {
- vjPlayerWindow = getMyElement ('', 'div', 'class', 'largePlayer', 0, false);
- vjPlayerWidth = 954;
- vjPlayerHeight = 562;
- vjPlayerWide = false;
- }
- else return;
- if (!vjPlayerWindow) {
- showMyMessage ('!player');
- }
- else {
- /* Get Videos Content */
- var vjVideoID = getMyContent (page.url, 'data-videoid="(.*?)"', true);
- var vjVideoTitle = getMyContent (page.url, 'data-filenameprefix="(.*?)"', true);
- var vjVideoDuration = getMyContent (page.url, 'meta\\s+itemprop="duration"\\s+content="(.*?)"', false);
- if (vjVideoDuration) {
- 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);
- }
-
- /* My Player Window */
- myPlayerWindow = createMyElement ('div', '', '', '', '');
- styleMyElement (myPlayerWindow, {position: 'relative', width: vjPlayerWidth + 'px', height: vjPlayerHeight + 'px', backgroundColor: '#F4F4F4', zIndex: '99999'});
- modifyMyElement (vjPlayerWindow, 'div', '', true);
- styleMyElement (vjPlayerWindow, {height: '100%', backgroundColor: '#FFFFFF', border: 'none', boxShadow: 'none'});
- if (page.url.indexOf("videojug.com/series") != -1) styleMyElement (getMyElement ('', 'div', 'class', 'content-container', 0, false), {height: '988px'});
- if (!vjPlayerWide) styleMyElement (vjPlayerWindow, {width: vjPlayerWidth + 'px'});
- appendMyElement (vjPlayerWindow, myPlayerWindow);
-
- /* Get Videos */
- if (vjVideoID && vjVideoTitle) {
- var vjVideoID2 = vjVideoID.substring(0,2);
- var vjVideoProtocol = page.win.location.protocol;
- var vjVideoSource = vjVideoProtocol + '//' + page.win.location.hostname + '/views/film/playlist.aspx?id=' + vjVideoID;
- var vjVideoShapes = getMyContent(vjVideoSource, '<Shapes>(.*?)<\/Shapes>', false);
- 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'};
- var vjVideoList = {};
- var vjVideoFound = false;
- var vjVideoPart, myVideoCode, vjVideo, vjVideoThumb, vjVideoCodePart, vjVideoPattern, vjVideoLocation;
- if (vjVideoShapes) {
- vjVideoPart = vjVideoID2 + '/' + vjVideoID + '/' + vjVideoTitle;
- for (var vjVideoCode in vjVideoFormats) {
- if (vjVideoCode.indexOf('VJ') != -1) vjVideoCodePart = vjVideoCode.substring(0, 6);
- else vjVideoCodePart = vjVideoCode.substring(0, 3);
- vjVideoPattern = 'Code="' + vjVideoCodePart + '"\\s+Locations="(.*?),';
- vjVideoLocation = vjVideoShapes.match(vjVideoPattern);
- vjVideoLocation = (vjVideoLocation) ? vjVideoProtocol + '//' + vjVideoLocation[1] : null;
- if (vjVideoLocation) {
- if (!vjVideoFound) vjVideoFound = true;
- vjVideo = vjVideoLocation + '/' + vjVideoPart + '__' + vjVideoCode;
- myVideoCode = vjVideoFormats[vjVideoCode];
- vjVideoList[myVideoCode] = vjVideo;
- }
- }
- vjVideoThumb = 'http://content5.videojug.com/' + vjVideoPart + '.WidePlayer.jpg';
- }
-
- if (vjVideoFound) {
- /* Get Watch Sidebar */
- var vjSidebarWindow = getMyElement ('', 'aside', 'id', 'side-bar', -1, false);
-
- /* Create Player */
- var vjDefaultVideo = 'Low Definition MP4';
- var player = {
- 'playerSocket': vjPlayerWindow,
- 'playerWindow': myPlayerWindow,
- 'videoList': vjVideoList,
- 'videoPlay': vjDefaultVideo,
- 'videoThumb': vjVideoThumb,
- 'videoDuration': vjVideoDuration,
- 'playerWidth': vjPlayerWidth,
- 'playerHeight': vjPlayerHeight,
- 'playerWideWidth': 954,
- 'playerWideHeight': 562,
- 'sidebarWindow': vjSidebarWindow,
- 'sidebarMarginNormal': 5,
- 'sidebarMarginWide': 580
- };
- feature['widesize'] = vjPlayerWide;
- option['definition'] = 'SD';
- option['definitions'] = ['Standard Definition', 'Low Definition', 'Very Low Definition'];
- option['containers'] = ['MP4', 'FLV', 'Any'];
- HeadWindow = getMyElement('', 'header', 'tag', '', 0, false);
- createMyPlayer (player);
- }
- else {
- showMyMessage ('!videos');
- }
- }
- else {
- showMyMessage ('!content');
- }
- }
-
- }
-
- // =====Blip===== //
- else if (page.url.indexOf('blip.tv') != -1) {
-
- /* Get Page Type */
- var blipPageType = getMyContent (page.url, 'meta\\s+property="video:tag"\\s+content="(.*?)"', false);
- if (!blipPageType || blipPageType.indexOf('episode') == -1) return;
-
- /* Get Player Window */
- var blipPlayerWidth, blipPlayerHeight;
- var blipPlayerWindow = getMyElement ('', 'div', 'class', 'EpisodePlayer', 0, false) || getMyElement ('', 'div', 'id', 'ErrorWrap', -1, false);
- if (!blipPlayerWindow) {
- blipPlayerWindow = getMyElement ('', 'div', 'id', 'PlayerEmbed', -1, false);
- blipPlayerWidth = 596;
- blipPlayerHeight = 334;
- }
- else {
- blipPlayerWidth = 960;
- blipPlayerHeight = 565;
- }
- if (!blipPlayerWindow) {
- showMyMessage ('!player');
- }
- else {
- /* Get Video Info */
- var blipVideoInfo = getMyContent(page.url + '?skin=json', 'TEXT', false);
-
- /* Get Video Thumbnail */
- var blipVideoThumb = (blipVideoInfo) ? blipVideoInfo.match(/"thumbnailUrl":"(.*?)"/) : null;
- blipVideoThumb = (blipVideoThumb) ? blipVideoThumb[1] : null;
- var blipVideoDuration = getMyContent (page.url, 'meta\\s+property="video:duration"\\s+content="(.*?)"', false);
- if (blipVideoDuration) blipVideoDuration = parseInt(blipVideoDuration);
-
- /* Get Videos Content */
- var blipVideosContent = (blipVideoInfo) ? blipVideoInfo.match(/"additionalMedia":\[(.*?)\]/) : null;
- blipVideosContent = (blipVideosContent) ? blipVideosContent[1] : null;
-
- /* My Player Window */
- var myPlayerWindow = createMyElement ('div', '', '', '', '');
- styleMyElement (myPlayerWindow, {position: 'relative', width: blipPlayerWidth + 'px', height: blipPlayerHeight + 'px', backgroundColor: '#F4F4F4'});
- modifyMyElement (blipPlayerWindow, 'div', '', true);
- styleMyElement (blipPlayerWindow, {paddingTop: '0px'});
- appendMyElement (blipPlayerWindow, myPlayerWindow);
- var blipHeader = getMyElement ('', 'div', 'id', 'Header', -1, false);
- styleMyElement (blipHeader , {zIndex: '0'});
-
- /* Get Videos */
- if (blipVideosContent) {
- var blipVideoList = {};
- var blipVideoFound = false;
- var blipMimeTypes = {'video/x-m4v': 'M4V', 'video/quicktime': 'MOV', 'video/mp4': 'MP4', 'video/x-flv': 'FLV'};
- var blipVideos = blipVideosContent.split(',{');
- var blipVideoURL, blipVideoMime, blipVideoHeight, blipVideoRole, blipVideoDef, blipVideoCode;
- var blipDefaultVideo = 'Low Definition MP4';
- for (var blipV = 0; blipV < blipVideos.length; blipV++) {
- blipVideoMime = blipVideos[blipV].match(/"primary_mime_type":"(.*?)"/);
- blipVideoMime = (blipVideoMime) ? blipVideoMime[1] : null;
- if (blipMimeTypes[blipVideoMime]) {
- blipVideoURL = blipVideos[blipV].match(/"url":"(.*?)"/);
- blipVideoURL = (blipVideoURL) ? blipVideoURL[1] : null;
- blipVideoHeight = blipVideos[blipV].match(/"media_height":"(.*?)"/);
- blipVideoHeight = (blipVideoHeight) ? blipVideoHeight[1] : null;
- blipVideoRole = blipVideos[blipV].match(/"role":"(.*?)"/);
- blipVideoRole = (blipVideoRole) ? blipVideoRole[1] : null;
- if (blipVideoURL && blipVideoHeight && blipVideoRole) {
- if (!blipVideoFound) blipVideoFound = true;
- if (blipVideoHeight >= 200 && blipVideoHeight < 400) blipVideoDef = 'Low Definition';
- else if (blipVideoHeight >= 400 && blipVideoHeight < 700) blipVideoDef = 'Standard Definition';
- else if (blipVideoHeight >= 700) blipVideoDef = 'High Definition';
- blipVideoCode = blipVideoDef + ' ' + blipMimeTypes[blipVideoMime];
- blipVideoList[blipVideoCode] = blipVideoURL;
- if (blipVideoRole == 'Source') blipDefaultVideo = blipVideoCode;
- }
- }
- }
-
- if (blipVideoFound) {
- /* Create Player */
- var player = {
- 'playerSocket': blipPlayerWindow,
- 'playerWindow': myPlayerWindow,
- 'videoList': blipVideoList,
- 'videoPlay': blipDefaultVideo,
- 'videoThumb': blipVideoThumb,
- 'videoDuration': blipVideoDuration,
- 'playerWidth': blipPlayerWidth,
- 'playerHeight': blipPlayerHeight
- };
- feature['widesize'] = false;
- option['definitions'] = ['High Definition', 'Standard Definition', 'Low Definition'];
- option['containers'] = ['MP4', 'M4V', 'MOV', 'FLV', 'Any'];
- createMyPlayer (player);
- }
- else {
- showMyMessage ('!videos');
- }
- }
- else {
- showMyMessage ('!content');
- }
- }
-
- }
-
- // =====Veoh===== //
- else if (page.url.indexOf('veoh.com/watch') != -1) {
-
- /* Get Video Availability */
- if (getMyElement ('', 'div', 'class', 'veoh-video-player-error', 0, false)) return;
-
- /* Get Player Window */
- var vePlayerWindow = getMyElement ('', 'div', 'id', 'videoPlayerContainer', -1, false);
- if (!vePlayerWindow) {
- showMyMessage ('!player');
- }
- else {
- /* Get Videos Content */
- var veVideosContent = getMyContent (page.url, '__watch.videoDetailsJSON = \'\\{(.*?)\\}\'', false);
- veVideosContent = cleanMyContent (veVideosContent, true);
-
- /* Get Video Thumbnail */
- var veVideoThumbGet = veVideosContent.match (/"highResImage":"(.*?)"/);
- var veVideoThumb = (veVideoThumbGet) ? veVideoThumbGet[1] : null;
- var veVideoDuration = getMyContent (page.url, 'meta\\s+name="item-duration"\\s+content="(.*?)"', false);
- if (veVideoDuration) veVideoDuration = parseInt(veVideoDuration);
-
- /* My Player Window */
- var myPlayerWindow = createMyElement ('div', '', '', '', '');
- styleMyElement (myPlayerWindow, {position: 'relative', width: '640px', height: '382px', backgroundColor: '#F4F4F4', zIndex: '99999'});
- modifyMyElement (vePlayerWindow, 'div', '', true);
- styleMyElement (vePlayerWindow, {height: '100%'});
- appendMyElement (vePlayerWindow, myPlayerWindow);
-
- /* Get Videos */
- if (veVideosContent) {
- var veVideoFormats = {'fullPreviewHashLowPath': 'Very Low Definition MP4', 'fullPreviewHashHighPath': 'Low Definition MP4'};
- var veVideoList = {};
- var veVideoFound = false;
- var veVideoParser, veVideoParse, veVideo, myVideoCode;
- for (var veVideoCode in veVideoFormats) {
- veVideoParser = veVideoCode + '":"(.*?)"';
- veVideoParse = veVideosContent.match (veVideoParser);
- veVideo = (veVideoParse) ? veVideoParse[1] : null;
- if (veVideo) {
- if (!veVideoFound) veVideoFound = true;
- myVideoCode = veVideoFormats[veVideoCode];
- veVideoList[myVideoCode] = veVideo;
- }
- }
-
- if (veVideoFound) {
- /* Get Watch Sidebar */
- var veSidebarWindow = getMyElement ('', 'div', 'id', 'videoToolsContainer', -1, false);
- if (veSidebarWindow) styleMyElement(veSidebarWindow, {marginTop: '-380px'});
-
- /* Create Player */
- var veDefaultVideo = 'Low Definition MP4';
- var player = {
- 'playerSocket': vePlayerWindow,
- 'playerWindow': myPlayerWindow,
- 'videoList': veVideoList,
- 'videoPlay': veDefaultVideo,
- 'videoThumb': veVideoThumb,
- 'videoDuration': veVideoDuration,
- 'playerWidth': 640,
- 'playerHeight': 382,
- 'playerWideWidth': 970,
- 'playerWideHeight': 568,
- 'sidebarWindow': veSidebarWindow,
- 'sidebarMarginNormal': -380,
- 'sidebarMarginWide': 20
- };
- feature['container'] = false;
- option['definition'] = 'LD';
- option['definitions'] = ['Low Definition', 'Very Low Definition'];
- option['containers'] = ['MP4'];
- createMyPlayer (player);
- }
- else {
- var veVideoSource = getMyContent(page.url, '"videoContentSource":"(.*?)"', false);
- if (veVideoSource == 'YouTube') var ytVideoId = getMyContent(page.url, '"videoId":"yapi-(.*?)"', false);
- if (ytVideoId) {
- var ytVideoLink = 'http://youtube.com/watch?v=' + ytVideoId;
- showMyMessage ('embed', ytVideoLink);
- }
- else {
- showMyMessage ('!videos');
- }
- }
- }
- else {
- showMyMessage ('!content');
- }
- }
-
- }
-
- // =====Viki===== //
- else if (page.url.indexOf('viki.com/videos') != -1) {
-
- /* Get Player Window */
- var vkPlayerWindow = getMyElement ('', 'div', 'id', 'viki-player', -1, false);
- if (!vkPlayerWindow) {
- showMyMessage ('!player');
- }
- else {
- /* Get Video ID */
- var vkVideoID = page.url.match(/videos\/(.*?)v/);
- vkVideoID = (vkVideoID) ? vkVideoID[1] : null;
-
- /* Get Videos Content */
- var vkVideosContent;
- if (vkVideoID) vkVideosContent = getMyContent (page.win.location.protocol + '//' + page.win.location.host + '/player5_fragment/' + vkVideoID + 'v.json', 'TEXT', false);
- var vkVideoDuration = getMyContent(page.url, '"duration":(.*?),', false);
-
- /* My Player Window */
- var myPlayerWindow = createMyElement ('div', '', '', '', '');
- styleMyElement (myPlayerWindow, {position: 'relative', width: '950px', height: '556px', backgroundColor: '#F4F4F4'});
- modifyMyElement (vkPlayerWindow, 'div', '',false, true);
- appendMyElement (vkPlayerWindow, myPlayerWindow);
- blockObject = vkPlayerWindow;
- blockInterval = 20;
-
- /* Get Videos */
- if (vkVideosContent) {
- var vkVideoList = {};
- var vkVideo = vkVideosContent.match(/"video_url":"(.*?)"/);
- vkVideo = (vkVideo) ? vkVideo[1] : null;
- var vkVideoThumb = vkVideosContent.match(/"image_url":"(.*?)"/);
- vkVideoThumb = (vkVideoThumb) ? vkVideoThumb[1] : null;
-
- /* Create Player */
- if (vkVideo) {
- var vkDefaultVideo = 'Low Definition MP4';
- vkVideoList[vkDefaultVideo] = vkVideo
- var player = {
- 'playerSocket': vkPlayerWindow,
- 'playerWindow': myPlayerWindow,
- 'videoList': vkVideoList,
- 'videoPlay': vkDefaultVideo,
- 'videoDuration': vkVideoDuration,
- 'videoThumb': vkVideoThumb,
- 'playerWidth': 950,
- 'playerHeight': 556
- };
- feature['definition'] = false;
- feature['container'] = false;
- feature['widesize'] = false;
- option['definition'] = 'LD';
- option['definitions'] = ['Low Definition'];
- option['containers'] = ['MP4'];
- createMyPlayer (player);
- }
- else {
- showMyMessage ('!videos');
- }
- }
- else {
- showMyMessage ('!content');
- }
- }
-
- }
-
- // =====IMDB===== //
- /* Redirect To imdb.com */
- else if (page.url.indexOf('imdb.org') !== -1) window.location.href = page.win.location.href.replace(/imdb\.org/, 'imdb.com');
- else if (page.url.indexOf('imdb.com/video') != -1) {
-
- function imdb_run(imdb_PlayerId) {
- /* Get Player Window */
- var imdbPlayerWindow = getMyElement ('', 'div', 'id', 'player-article', -1, false);
- if (imdbPlayerWindow) {
- var imdbPlayerWidth = 670;
- var imdbPlayerHeight = 398;
- } else {
- imdbPlayerWindow = getMyElement ('', 'div', 'class', 'video-player vp-full', 0, false);
- var imdbPlayerWidth = 854;
- var imdbPlayerHeight = 480;
- }
- if (!imdbPlayerWindow) {
- return
- // showMyMessage ('!player');
- }
- else {
- var imdbVideoID = page.url.match(/vi\d{5,}/);
- if (imdbVideoID) imdbVideoID = imdbVideoID[0]; else imdbVideoID = getMyContent (page.url, '"viconst":"(.*?)"', true);
-
- /* My Player Window */
- var myPlayerWindow = createMyElement ('div', '', '', '', '');
- var imdbPlayerElement = getMyElement ('', 'div', 'id', 'imdb-video', -1, false)
- if (imdbPlayerElement) cleanMyElement(imdbPlayerElement, true);
- styleMyElement (myPlayerWindow, {position: 'relative', width: imdbPlayerWidth + 'px', height: imdbPlayerHeight + 'px', backgroundColor: '#F4F4F4'});
- modifyMyElement (imdbPlayerWindow, 'div', '', true);
- appendMyElement (imdbPlayerWindow, myPlayerWindow);
-
- /* Get Videos Content */
- var imdbVideoList = {};
- var imdbVideoFormats = {'1': 'Low Definition MP4', '2': 'Standard Definition MP4', '3': 'High Definition MP4'};
- var imdbVideoThumb, imdbDefaultVideo, imdbURL, imdbVideo, myVideoCode;
- var imdbVideoFound = false;
- var imdbVideoRTMP = false;
- for (var imdbVideoCode in imdbVideoFormats) {
- imdbURL = page.win.location.protocol + '//' + page.win.location.hostname + '/video/imdb/' + imdbVideoID + '/player?uff=' + imdbVideoCode;
- imdbVideo = getMyContent (imdbURL, 'so.addVariable\\("file",\\s+"(.*?)"\\);', true);
- if (!imdbVideoThumb) imdbVideoThumb = getMyContent (imdbURL, 'so.addVariable\\("image",\\s+"(.*?)"\\);', true);
- if (imdbVideo) {
- if (imdbVideo.indexOf('rtmp') != -1) {
- if (!imdbVideoRTMP) imdbVideoRTMP = true;
- } else {
- if (!imdbVideoFound) imdbVideoFound = true;
- myVideoCode = imdbVideoFormats[imdbVideoCode];
- imdbVideoList[myVideoCode] = imdbVideo;
- if (!imdbDefaultVideo) imdbDefaultVideo = myVideoCode;
- }
- }
- }
-
- if (imdbVideoFound) {
- /* Get Watch Sidebar */
- var imdbSidebarWindow = getMyElement ('', 'div', 'id', 'sidebar', -1, false);
- if (imdbSidebarWindow) styleMyElement (imdbSidebarWindow, {marginTop: '-400px'});
-
- /* Create Player */
- var player = {
- 'playerSocket': imdbPlayerWindow,
- 'playerWindow': myPlayerWindow,
- 'videoList': imdbVideoList,
- 'videoPlay': imdbDefaultVideo,
- 'videoThumb': imdbVideoThumb,
- 'playerWidth': imdbPlayerWidth,
- 'playerHeight': imdbPlayerHeight,
- 'playerWideWidth': 1010,
- 'playerWideHeight': 592,
- 'sidebarWindow': imdbSidebarWindow,
- 'sidebarMarginNormal': -400,
- 'sidebarMarginWide': 0
- };
- feature['container'] = false;
- option['definitions'] = ['High Definition', 'Standard Definition', 'Low Definition'];
- option['containers'] = ['MP4'];
- createMyPlayer (player);
- }
- else {
- if (imdbVideoRTMP) showMyMessage ('!support');
- else showMyMessage ('!videos');
- }
- }
- }
-
- function onNodeInserted(e) {
- if (e && e.target && (typeof e.target.id !== 'undefined') && e.target.id == 'imdb-video-player') {
- setTimeout(function() { imdb_run(); }, 0);
- }
- }
-
- if (page.url.indexOf('video/playlist') == -1) imdb_run();
- else {
- var content = getMyElement ('', 'body', '', '', -1, false);
- if (content) {
- var mo=window.MutationObserver||window.MozMutationObserver||window.WebKitMutationObserver;
- if(typeof mo!=='undefined') {
- var observer=new mo(function(mutations) {
- mutations.forEach(function(mutation) {
- if(mutation.addedNodes!==null && mutation.addedNodes.length > 0) {
- for (var i=0; i<mutation.addedNodes.length; i++) {
- if ((typeof mutation.addedNodes[i].id !== 'undefined') && (mutation.addedNodes[i].id == 'imdb-video-player')) {
- imdb_run(mutation.addedNodes);
- break;
- }
- }
- }
- });
- });
- observer.observe(content, {childList: true, subtree: true, characterData:true});
- } else { // MutationObserver fallback for old browsers
- content.parentNode.addEventListener('DOMNodeInserted', onNodeInserted, true);
- }
- }
- }
-
- }
-
- // =====Crackle===== //
- else if (page.url.indexOf('crackle.com/') != -1) {
-
- /* Get Page Type */
- var crPageType = getMyContent (page.url, 'meta\\s+property="og:type"\\s+content="(.*?)"', false);
- if (!crPageType || crPageType.indexOf('video') == -1) return;
-
- /* Get Player Window */
- var crPlayerWindow = getMyElement ('', 'div', 'id', 'main', -1, false);
- if (!crPlayerWindow) {
- showMyMessage ('!player');
- }
- else {
- /* Get Videos Content */
- var crVideoPath = getMyContent (page.url, 'images-us-am.crackle.com\/(.*?_)tnl', false);
- if (!crVideoPath) {
- var crVideoID = getMyContent (page.url, 'mediaId:\\s*(.*?),', false);
- if (crVideoID) {
- var crVidWallCache = page.win.location.protocol + '//' + page.win.location.hostname + '/app/vidwallcache.aspx?flags=-1&fm=' + crVideoID + '&partner=20';
- crVideoPath = getMyContent (crVidWallCache, '\\sp="(.*?)"', false);
- }
- }
-
- var crVideoDuration = parseInt(getMyContent (page.url, 'endTime:(.*?),', false));
-
- /* My Player Window */
- var myPlayerWindow = createMyElement ('div', '', '', '', '');
- styleMyElement (myPlayerWindow, {position: 'relative', width: '970px', height: '570px', backgroundColor: '#F4F4F4'});
- modifyMyElement (crPlayerWindow, 'div', '', true);
- styleMyElement (crPlayerWindow, {width: '970px', height: '600px', backgroundColor: '#FFFFFF'});
- appendMyElement (crPlayerWindow, myPlayerWindow);
-
- /* Get Videos */
- if (crVideoPath) {
- var crVideoList = {};
- var crVideoFormats = {'360p.mp4': 'Low Definition MP4', '480p.mp4': 'Standard Definition MP4'};
- var crVideoThumb, crVideo, myVideoCode;
- for (var crVideoCode in crVideoFormats) {
- crVideo = 'http://media-us-am.crackle.com/' + crVideoPath + crVideoCode;
- myVideoCode = crVideoFormats[crVideoCode];
- crVideoList[myVideoCode] = crVideo;
- }
- crVideoThumb = 'http://images-us-am.crackle.com/' + crVideoPath + 'tnl.jpg';
-
- /* Create Player */
- var crDefaultVideo = 'Low Definition MP4';
- var player = {
- 'playerSocket': crPlayerWindow,
- 'playerWindow': myPlayerWindow,
- 'videoList': crVideoList,
- 'videoPlay': crDefaultVideo,
- 'videoThumb': crVideoThumb,
- 'videoDuration': crVideoDuration,
- 'playerWidth': 970,
- 'playerHeight': 570
- };
- feature['container'] = false;
- feature['widesize'] = false;
- option['definition'] = 'SD';
- option['definitions'] = ['Standard Definition', 'Low Definition'];
- option['containers'] = ['MP4'];
- createMyPlayer (player);
-
- /* Fix Thumbnails */
- var crThumbs = getMyElement('', 'div', 'class', 'thumbnail', -1, false);
- for (var crT = 0; crT < crThumbs.length; crT++) {
- if (crThumbs[crT].innerHTML.indexOf('AddObjectToQueue') != -1) {
- var crLink = crThumbs[crT].innerHTML.match(/,\s+\d+,\s+'(.*?)'/);
- crLink = (crLink) ? crLink[1] : null;
- var crImg = crThumbs[crT].innerHTML.match(/src="(.*?)"/);
- crImg = (crImg) ? crImg[1] : null;
- crThumbs[crT].innerHTML = '<img src="' + crImg + '" onclick="window.location.href=\'' + crLink + '\'" style="cursor:pointer">';
- }
- }
- }
- else {
- showMyMessage ('!videos');
- }
- }
-
- }
-
- // =====Facebook===== //
- else if (page.url.match('facebook.com/(video.php|.*/videos/)')) {
-
- /* Get Player Window */
- var fbPlayerWindow = getMyElement ('', 'div', 'class', 'stageWrapper', 0, false);
- if (!fbPlayerWindow) {
- showMyMessage ('!player');
- }
- else {
- /* Get Videos Content */
- var fbVideosContent = getMyContent(page.url, '"params","(.*?)"', false);
- var fbPattern = /\\u([\d\w]{4})/gi;
- fbVideosContent = fbVideosContent.replace(fbPattern, function (match, group) {
- return String.fromCharCode(parseInt(group, 16));
- });
- fbVideosContent = unescape(fbVideosContent);
-
- /* My Player Window */
- var myPlayerWindow = createMyElement ('div', '', '', '', '');
- styleMyElement (myPlayerWindow, {position: 'relative', width: '720px', height: '428px', backgroundColor: '#F4F4F4'});
- modifyMyElement (fbPlayerWindow, 'div', '', true);
- appendMyElement (fbPlayerWindow, myPlayerWindow);
-
- /* Get Videos */
- if (fbVideosContent) {
- var fbVideoDuration = fbVideosContent.match(/duration":(.*?),/);
- if (fbVideoDuration) fbVideoDuration = parseInt(fbVideoDuration[1]);
- var fbVideoList = {};
- var fbVideoFormats = {'sd_src': 'Low Definition MP4', 'hd_src': 'High Definition MP4'};
- var fbVideoFound = false;
- var fbVideoPattern, fbVideo, myVideoCode, fbVideoThumb, fbDefaultVideo;
- for (var fbVideoCode in fbVideoFormats) {
- fbVideoPattern = '"' + fbVideoCode + '":"(.*?)"';
- fbVideo = fbVideosContent.match(fbVideoPattern);
- fbVideo = (fbVideo) ? fbVideo[1] : null;
- if (fbVideo) {
- fbVideo = cleanMyContent(fbVideo, false);
- if (!fbVideoFound) fbVideoFound = true;
- myVideoCode = fbVideoFormats[fbVideoCode];
- if (fbVideo.indexOf('.flv') != -1) myVideoCode = myVideoCode.replace('MP4', 'FLV');
- fbVideoList[myVideoCode] = fbVideo;
- if (!fbDefaultVideo) fbDefaultVideo = myVideoCode;
- }
- fbVideoThumb = fbVideosContent.match(/"thumbnail_src":"(.*?)"/);
- fbVideoThumb = (fbVideoThumb) ? fbVideoThumb[1] : null;
- if (fbVideoThumb) fbVideoThumb = cleanMyContent(fbVideoThumb, false);
- else fbVideoThumb = 'https://www.facebook.com/images/fb_icon_325x325.png';
- }
-
- if (fbVideoFound) {
- /* Create Player */
- var player = {
- 'playerSocket': fbPlayerWindow,
- 'playerWindow': myPlayerWindow,
- 'videoList': fbVideoList,
- 'videoPlay': fbDefaultVideo,
- 'videoThumb': fbVideoThumb,
- 'videoDuration': fbVideoDuration,
- 'playerWidth': 720,
- 'playerHeight': 428
- };
- feature['widesize'] = false;
- option['definitions'] = ['High Definition', 'Low Definition'];
- option['containers'] = ['MP4', 'FLV', 'Any'];
- HeadWindow = getMyElement('', 'div', 'id', 'blueBarNAXAnchor', -1, false);
- createMyPlayer (player);
- }
- else {
- showMyMessage ('!videos');
- }
- }
- else {
- showMyMessage ('!content');
- }
- }
- }
-
- // =====YahooScreen===== //
- else if (page.url.indexOf('screen.yahoo.com') != -1) {
- /* Get Player Window */
- var ysPlayerWindow = getMyElement ('', 'div', 'id', 'ym-player', -1, false);
- if (ysPlayerWindow) ysPlayerWindow = ysPlayerWindow.parentNode;
- if (!ysPlayerWindow) {
- showMyMessage ('!player');
- }
- else {
- /* Get Videos Content */
- var ysVideosContent;
- var ysVideoID = getMyContent (page.url, '"data":{"sapi":{"id":"(.*?)"', false);
- if (!ysVideoID) ysVideoID = getMyContent (page.url, '"first_videoid":"(.*?)"', false);
-
- if (ysVideoID) ysVideosContent = getMyContent('https://video.media.yql.yahoo.com/v1/video/sapi/streams/' + ysVideoID + '?protocol=http®ion=US', '"streams":\\[(.*?)\\]', false);
- /* Get Video Thumbnail */
- var ysVideoThumb = getMyContent(page.url, '"thumbnails":\\[{"tag":"original","url":"(.*?)"', false);
- if (!ysVideoThumb) ysVideoThumb = getMyContent (page.url, 'meta\\s+property="og:image"\\s+content="(.*?)"', false);
- var ysVideoDuration = getMyContent(page.url, '"duration":(.*?),', false);
-
- /* My Player Window */
- var myPlayerWindow = createMyElement ('div', '', '', '', '');
- var ysPlayerWidth = ysPlayerWindow.offsetWidth;
- var ysPlayerHeight = ysPlayerWindow.offsetHeight - 6;
- if (ysPlayerHeight <= 300) { ysPlayerWidth = 604; ysPlayerHeight = 340 }
- styleMyElement (myPlayerWindow, {position: 'relative', width: ysPlayerWidth + 'px', height: ysPlayerHeight+ 'px', backgroundColor: '#F4F4F4', margin: '0px auto'});
- modifyMyElement (ysPlayerWindow, 'div', '', true);
- appendMyElement (ysPlayerWindow, myPlayerWindow);
-
- /* Get Videos */
- if (ysVideosContent) {
- var ysVideoList = {};
- var ysVideoFound = false;
- var ysVideoFormats = {'240': 'Very Low Definition', '360': 'Low Definition', '432': 'Low Definition', '540': 'Standard Definition', '720': 'High Definition', '1080': 'Full High Definition'};
- var ysVideoParts = ysVideosContent.split('},');
- var ysVideoPart, ysVideoPath, ysVideoHost, ysVideoHeight, ysVideoType, myVideoCode;
- for (var i = 0; i < ysVideoParts.length; i++) {
- ysVideoPart = ysVideoParts[i];
- ysVideoPath = ysVideoPart.match(/"path":"(.*?)"/);
- ysVideoPath = (ysVideoPath) ? ysVideoPath[1] : null;
- ysVideoHost = ysVideoPart.match(/"host":"(.*?)"/);
- ysVideoHost = (ysVideoHost) ? ysVideoHost[1] : null;
- ysVideoHeight = ysVideoPart.match(/"height":(\d+),/);
- ysVideoHeight = (ysVideoHeight) ? ysVideoHeight[1].replace('.0','') : null;
- ysVideoType = ysVideoPart.match(/"mime_type":"(.*?)"/);
- ysVideoType = (ysVideoType) ? ysVideoType[1] : null;
- if (ysVideoPath && ysVideoHost && ysVideoHeight && ysVideoType) {
- for (var ysVideoCode in ysVideoFormats) {
- if (ysVideoCode == ysVideoHeight) {
- if (!ysVideoFound) ysVideoFound = true;
- myVideoCode = ysVideoFormats[ysVideoCode]
- if (ysVideoType == 'video/mp4') myVideoCode += ' MP4';
- else if (ysVideoType == 'video/webm') myVideoCode += ' WebM';
- ysVideoList[myVideoCode] = ysVideoHost + ysVideoPath;
- }
- }
- }
- }
-
- if (ysVideoFound) {
- /* Create Player */
- var ysDefaultVideo = 'Low Definition MP4';
- var player = {
- 'playerSocket': ysPlayerWindow,
- 'playerWindow': myPlayerWindow,
- 'videoList': ysVideoList,
- 'videoPlay': ysDefaultVideo,
- 'videoThumb': ysVideoThumb,
- 'videoDuration': ysVideoDuration,
- 'playerWidth': ysPlayerWidth,
- 'playerHeight': ysPlayerHeight
- };
- feature['widesize'] = false;
- option['definitions'] = ['Full High Definition', 'High Definition', 'Standard Definition', 'Low Definition', 'Very Low Definition'];
- option['containers'] = ['MP4', 'WebM', 'Any'];
- HeadWindow = getMyElement ('', 'div', 'id', 'yucsHead', -1, false);
- createMyPlayer (player);
- styleMyElement(player['playerContent'], {marginTop: '5px'});
- }
- else {
- showMyMessage ('!videos');
- }
- }
- else {
- showMyMessage ('!content');
- }
- }
-
- }
-
- })();