// ==SiteScript== // @siteName Tangdow.com(糖豆) // @siteUrl http://www.tangdou.com/ // @author mayan // @authorUrl // @scriptUrl // @description c // @date 2013/04/29 // @version 0.2.3 // ==/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|#0*34);/ig, "\"" ) .replace( /&(amp|#0*38);/ig, "&" ) .replace( /&(apos|#0*39);/ig, "'" ) .replace( /&(lt|#0*60);/ig, "<" ) .replace( /&(gt|#0*62);/ig, ">" ) .replace( /&(nbsp|#0*160);/ig, " " ) .replace( /&(frasl|#8260);/ig, "/" ); } } function isSiteUrl( url ) { if ( url.match( /http:\/\/([^\/]+\.)?tangdou\.com\/([^\/]+\/)*\d+\/\d+_\d+\.html/ ) ) return true; if ( url.match( /http:\/\/([^\/]+\.)?tangdou\.com\/html\/playlist\/\d+\/\d+\.html/ ) ) return true; if ( url.match( /http:\/\/([^\/]+\.)?tangdou\.com\/v\d*\/[0-9A-Za-z]+\.html/ ) ) return true; if ( url.match( /http:\/\/v\.bokecc\.com\/tangdou\/html\/[^\/]+\/\d+_\d+\.html/ ) ) return true; if ( url.match( /http:\/\/v\.bokecc\.com\/tangdou\/html\/playlist\/\d+\/\d+\.html/ ) ) return true; if ( url.match( /http:\/\/v\.bokecc\.com\/html\/[^\/]+\/\d+_\d+\.html/ ) ) return true; if ( url.match( /http:\/\/v\.bokecc\.com\/html\/playlist\/\d+\/\d+\.html/ ) ) return true; if ( url.match( /http:\/\/v\.bokecc\.com\/show\/[^\/]+\/\d+\.html/ ) ) return true; //emged if ( url.match( /http:\/\/([^\/]+\.)?tangdou\.com\/api\/play\/[0-9A-F]+_[0-9A-F]+_\d+\/v\.swf/ ) ) return true; if ( url.match( /http:\/\/union\.bokecc\.com\/flash\/[^?]+?\.swf(\?.+)/ ) ) { var prm = RegExp.$1; if ( prm.match( /[?&]siteid=[0-9A-F]+/i ) && prm.match( /[?&]vid=[0-9A-F]+/i ) ) return true; } if ( url.match( /http:\/\/union\.bokecc\.com\/playvideo\.bo(\?.+)/ ) && RegExp.$1.match( /[?&]vid=[0-9A-F]+/i ) ) return true; return false; } function getVideoDetail( url ) { if ( url.match( /http:\/\/(?:[^\/]+\.)?tangdou\.com\/api\/play\/([0-9A-F]+)_([0-9A-F]+)_\d+\/v\.swf/ ) ) { var uid = RegExp.$1; var vid = RegExp.$2; var type = "embed"; } else if ( url.match( /http:\/\/union\.bokecc\.com\/flash\/[^?]+?\.swf(\?.+)/ ) ) { var prm = RegExp.$1; if ( prm.match( /[?&]siteid=([0-9A-F]+)/i ) ) uid = RegExp.$1; if ( prm.match( /[?&]vid=([0-9A-F]+)/i ) ) vid = RegExp.$1; type = "embed"; } else if ( url.match( /http:\/\/union\.bokecc\.com\/playvideo\.bo(\?.+)/ ) && RegExp.$1.match( /[?&]vid=([0-9A-F]+)/i ) ) { vid = RegExp.$1; type = "embed"; } else { type = "page"; } var craving = new CravingSiteScript(); if ( type == "page" ) { try { var text = craving.getResponseText( url ); } catch( e ) { text = ""; } if ( !text ) { try { var objHttp = new ActiveXObject( "WinHttp.WinHttpRequest.5.1" ); var objCnv = new clsCharConvert(); objHttp.open( "GET", url, false ); objHttp.send(); if ( objCnv.isOK && objCnv.convertChar( objHttp.responseBody, "utf-8" ) ) text = objCnv.result; else text = objHttp.responseText; } catch( e ) { text = ""; } } if ( !text ) return null; if ( text.match( /TD\.PlayerFactory\.play\(\s*(\{[^}]*\})\s*\)\s*;/ ) ) { var arg = RegExp.$1; if ( arg.match( /[{,]\s*("|')?vid\1\s*:\s*("|')(.*?)\2\s*[},]/ ) ) vid = RegExp.$3; if ( arg.match( /[{,]\s*("|')?siteid\1\s*:\s*("|')(.*?)\2\s*[},]/ ) ) uid = RegExp.$3; if ( ( !vid || !uid ) && arg.match( /[{,]\s*("|')?video_add\1\s*:\s*("|')(.*?)\2\s*[},]/ ) ) { var swfurl = RegExp.$3; } } if ( !vid || !uid ) { if ( !swfurl && text.match( /