// ==SiteScript== // @siteName Муви // @siteUrl http://www.myvi.ru/ // @author mayan // @authorUrl // @scriptUrl // @description // @date 2016/07/17 // @version 0.5.1 // ==/SiteScript== function CravingSiteScript() { this._initialize(); } CravingSiteScript.prototype = { _xhr: null, _initialize: function() {}, _getXmlHttpRequest: function() { if ( this._xhr != null ) { return this._xhr; } var xhr = null; var these = [ function() { return new XMLHttpRequest(); } , function() { return new ActiveXObject( "Msxml2.XMLHTTP" ); } , function() { return new ActiveXObject( "Microsoft.XMLHTTP" ); } , function() { return new ActiveXObject( "Msxml2.XMLHTTP.4.0" ); } ]; for ( var i = 0, length = these.length; i < length; i++ ) { var func = these[ i ]; try { xhr = func(); break; } catch( e ) {} } this._xhr = xhr; return this._xhr; }, _load: function( url, data, method ) { var req = this._getXmlHttpRequest(); var mtd = ( method == null ) ? "GET" : "POST"; req.open( mtd, url, false ); if ( mtd == "POST" ) { req.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" ); } req.send( data ); return req.responseText; }, getResponseText: function( url, data, method ) { return this._load( url, data, method ); }, getResponseJSON: function( url, data, method ) { var text = this._load( url, data, method ); return eval( "("+text+")" ); }, /// Math random: function( limit ) { return Math.floor( Math.random() * limit ); }, /// String decodeHtml: function( str ) { return str.replace( /&(quot|#34);/ig, "\"" ) .replace( /&(amp|#38);/ig, "&" ) .replace( /&(apos|#39);/ig, "'" ) .replace( /&(lt|#60);/ig, "<" ) .replace( /&(gt|#62);/ig, ">" ) .replace( /&(nbsp|#160);/ig, " " ) .replace( /&(frasl|#8260);/ig, "/" ) .replace( /(\d+);/g, function(a,b){return String.fromCharCode(parseInt(b,10));} ) .replace( /([0-9a-f]+);/ig, function(a,b){return String.fromCharCode(parseInt(b,16));} ); } } var _Myvi = {}; _Myvi.Err = []; function isSiteUrl( url ) { if ( url.match( /http:\/\/(?:www\.)?myvi\.ru\/watch\/[^/?]+/i ) ) return true; //if ( url.match( /http:\/\/(?:www\.)?myvi\.ru\/watch\/[^/?]*_[-_0-9A-Za-z]+/i ) ) return true; //if ( url.match( /http:\/\/(?:www\.)?myvi\.ru\/watch\/[-0-9a-f]{32,}/i ) ) return true; if ( url.match( /http:\/\/(?:www\.)?myvi\.ru\/ru\/videodetail\.aspx([?&].+)/i ) && RegExp.$1.match( /[?&]video=[-0-9a-f]+/i ) ) return true; //iframe if ( url.match( /http:\/\/myvi\.ru\/player\/embed\/html\/[-_0-9A-Za-z]+/i ) ) return true; if ( url.match( /http:\/\/myvi\.tv\/embed\/html\/[-_0-9A-Za-z]+/i ) ) return true; //redirect if ( url.match( /http:\/\/myvi\.ru\/player\/redirect\/html\/[-_0-9A-Za-z]+/i ) ) return true; //swf if ( url.match( /http:\/\/myvi.tv\/content\/preloader\.swf(\?.+)/i ) && RegExp.$1.match( /[?&]id=[-_0-9A-Za-z]+/i ) ) return true; if ( url.match( /http:\/\/(?:www\.)?myvi\.ru\/ru\/flash\/player\/[-_0-9A-Za-z]+/i ) ) return true; if ( url.match( /http:\/\/myvi\.ru\/player\/flash\/[-_0-9A-Za-z]+/i ) ) return true; return false; } function getVideoDetail( url ) { if ( typeof _Myvi != "object" ) _Myvi = {}; _Myvi.Err = []; if ( url.match( /http:\/\/(?:www\.)?myvi\.ru\/watch\/([^/?]+)/i ) ) { var tail = RegExp.$1; var videoid = tail.match( /([-0-9a-f]{32,})$/ )? RegExp.$1: ""; if ( !videoid ) var watchid = tail.match( /(?:^|-|_)([-_0-9A-Za-z]{23})$/ )? RegExp.$1: ""; var type = "page"; url = url.replace( /^http:\/\/myvi\.ru\//, "http://www.myvi.ru/" ); } else if ( url.match( /http:\/\/(?:www\.)?myvi\.ru\/ru\/videodetail\.aspx([?&].+)/i ) && RegExp.$1.match( /[?&]video=([-0-9a-f]+)/i ) ) { videoid = RegExp.$1; type = "page"; url = url.replace( /^http:\/\/www\.myvi\.ru\//, "http://myvi.ru/" ); } else if ( url.match( /http:\/\/myvi\.ru\/player\/embed\/html\/([-_0-9A-Za-z]+)/i ) ) { var enccode = RegExp.$1; type = "iframe"; } else if ( url.match( /http:\/\/myvi\.tv\/embed\/html\/([-_0-9A-Za-z]+)/i ) ) { enccode = RegExp.$1; type = "iframe"; } else if ( url.match( /http:\/\/myvi\.ru\/player\/redirect\/html\/([-_0-9A-Za-z]+)/i ) ) { enccode = RegExp.$1; type = "redirect"; } else if ( url.match( /http:\/\/myvi.tv\/content\/preloader\.swf(\?.+)/i ) && RegExp.$1.match( /[?&]id=([-_0-9A-Za-z]+)/i ) ) { enccode = RegExp.$1; type = "swf"; } else if ( url.match( /http:\/\/(?:www\.)?myvi\.ru\/ru\/flash\/player\/([-_0-9A-Za-z]+)/i ) ) { enccode = RegExp.$1; type = "swf"; } else if ( url.match( /http:\/\/myvi\.ru\/player\/flash\/([-_0-9A-Za-z]+)/i ) ) { enccode = RegExp.$1; type = "swf"; } else { _Myvi.Err.push( "URL不適合" ); //return null; type = "unknown"; } var craving = new CravingSiteScript(); if ( type == "page" || type == "unknown" ) { url = url.split( "#" )[0]; try { var text = craving.getResponseText( url ); } catch( e ) { _Myvi.Err.push( e.description ); if ( typeof( e.number ) == "number" ) var errNo = e.number & 0xFFFF; text = ""; } if ( errNo == 5 ) { url = redirect( url ); try { text = craving.getResponseText( url ); } catch( e ) { _Myvi.Err.push( e.description ); text = ""; } } if ( !text ) { _Myvi.Err.push( "url=" + url + "\nページコンテンツ取得失敗" ); return null; } if ( text.match( /]*?property\s*=\s*("|')?og:title\2[^>]*)>/i ) && RegExp.$1.match( /\s+content\s*=\s*("|')(.*?)\1/i ) ) { var title = craving.decodeHtml( RegExp.$2 ); } if ( !title && text.match( /]*?name\s*=\s*("|')title\2[^>]*)>/i ) && RegExp.$1.match( /\s+content\s*=\s*("|')(.*?)\1/i ) ) { title = craving.decodeHtml( RegExp.$2 ); } if ( text.match( /