// ==SiteScript== // @siteName DirtStyle.tv // @siteUrl http://dirtstyle.tv/ // @author mayan // @authorUrl // @scriptUrl // @description // @date 2013/01/05 // @version 0.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|#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:\/\/(?:www\.)?dirtstyle\.tv\/video\/[0-9A-Za-z]+\// ) ) return true; if ( url.match( /http:\/\/(?:www\.)?dirtstyle\.tv\/nuevo\/player\/embed\.php(\?.+)/ ) && RegExp.$1.match( /[?&]v=\d+/ ) ) return true; return false; } function getVideoDetail( url ) { if ( url.match( /http:\/\/(?:www\.)?dirtstyle\.tv\/video\/([0-9A-Za-z]+)\// ) ) { var uid = RegExp.$1; } else if ( url.match( /http:\/\/(?:www\.)?dirtstyle\.tv\/nuevo\/player\/embed\.php(\?.+)/ ) && RegExp.$1.match( /[?&]v=(\d+)/ ) ) { var vid = RegExp.$1; } else { return null; } var craving = new CravingSiteScript(); if ( !vid ) { url = url.replace( /^http:\/\/www\.dirtstyle\.tv\//, "http://dirtstyle.tv/" ); try { var text = craving.getResponseText( url ); } catch( e ) { text = ""; } if ( text ) { if ( text.match( /]*?name\s*=\s*("|')?movie\2[^>]*)>/im ) && RegExp.$1.match( /\s+value\s*=\s*("|')(.*?)\1/i ) && RegExp.$2.match( /[?&]config=([^&]+)/ ) ) { var configurl = decodeURIComponent( RegExp.$1 ); } if ( !configurl && text.match( /]*?id\s*=\s*("|')?nuevoplayer\2[^>]*)>/im ) && RegExp.$1.match( /\s+src\s*=\s*("|')?(.*?)\1/i ) && RegExp.$2.match( /[?&]config=([^&]+)/ ) ) { configurl = decodeURIComponent( RegExp.$1 ); } if ( configurl && configurl.match( /[?&]v=(\d+)/ ) ) { vid = RegExp.$1; } if ( text.match( /]*?property\s*=\s*("|')?og:title\2[^>]*)>/im ) && RegExp.$1.match( /\s+content\s*=\s*("|')(.*?)\1/i ) ) { var title_p = craving.decodeHtml( RegExp.$2 ); } if ( !title_p && text.match( /]*?class\s*=\s*("|')?video_title\1[^>]*>\s*(.*?)\s*<\/div\s*>/im ) ) { title_p = craving.decodeHtml( RegExp.$2 ); } } } if ( !vid ) return null; if ( !configurl || !configurl.match( /^http/ ) ) { configurl = "http://dirtstyle.tv/nuevo/player/config.php?v=" + vid; } try { var objHttp = craving._getXmlHttpRequest(); objHttp.open( "GET", configurl, false ); objHttp.send(); var objXml = objHttp.responseXML; } catch( e ) { objXml = null; } var n; if ( objXml && typeof objXml == "object" && objXml.xml ) { var playlisturl = (n=objXml.selectSingleNode( "/*/playlist" ))? n.text: ""; } if ( !playlisturl || !playlisturl.match( /^http/ ) ) { playlisturl = "http://dirtstyle.tv/nuevo/player/playlist.php?v=" + vid; } try { var objHttp = craving._getXmlHttpRequest(); objHttp.open( "GET", playlisturl, false ); objHttp.send(); var objXml = objHttp.responseXML; } catch( e ) { objXml = null; } if ( !objXml || typeof objXml != "object" || !objXml.xml ) return null; var objTrk = objXml.selectSingleNode( "/*/trackList/track[mediaid=" + vid + "]" ); if ( !objTrk ) return null; var file = (n=objTrk.selectSingleNode( "file" ))? n.text: ""; var filehd = (n=objTrk.selectSingleNode( "filehd" ))? n.text: ""; //var realUrl = filehd || file;//hd 404 var realUrl = file || filehd; if ( !realUrl ) return null; var title = (n=objTrk.selectSingleNode( "title" ))? n.text: ""; title = title || title_p; if ( !title ) title = "dirtstyle_" + ( uid || vid ); title = title.replace(/[\\\/:*?"<>|]/g, "_"); return { videoTitle0: title, videoUrl0: realUrl }; }