// ==SiteScript== // @siteName QQLive // @siteUrl http://live.qq.com/index.html // @author mayan // @authorUrl // @scriptUrl // @description // @date 2011/02/01 // @version 0.1.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, "/" ); } } function getTot( strId, intMax ){ var intTot = 0; for ( var i = 0; i < strId.length; i++ ){ var intChr = strId.charCodeAt( i ); intTot = intTot * 32 + intTot + intChr; if ( intTot >= intMax ) intTot = intTot % intMax; } return intTot; } function getDefaultFlvUrl( strId ){ var intMax = 4294967295 + 1; var intMaxOF = 10000 * 10000; var intTot = getTot( strId, intMax ) % intMaxOF; return "http://video.store.qq.com/" + intTot + "/" + strId + ".flv"; } function isSiteUrl( url ) { if ( url.match( /http:\/\/live\.qq\.com\/cover\/[^\/]+\/[^\/]+\.html/ ) ) return true; return false; } function getVideoDetail( url ) { if ( !url.match( /http:\/\/live\.qq\.com\/cover\/[^\/]+\/([^\/]+)\.html/ ) ) return null; var listid = RegExp.$1; if ( url.match( /[?&]vid=([^&]+)/ ) ) var uvid = RegExp.$1; var craving = new CravingSiteScript(); var text = craving.getResponseText( url ); if ( !text ) return null; if ( !text.match( /