// ==SiteScript==
// @siteName Sex Videos
// @siteUrl http://porn69.org/
// @author mayan
// @authorUrl
// @scriptUrl
// @description
// @date 2014/12/21
// @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\.)?porn69\.org\/[^\/?]*\.[0-9a-z]+\.html/ ) ) return true;
return false;
}
function getVideoDetail( url ) {
url = url.replace( /^http:\/\/www\./, "http://" );
if ( url.match( /http:\/\/(?:www\.)?porn69\.org\/[^\/?]*\.([0-9a-z]+)\.html/ ) ) {
var vid = RegExp.$1;
} else {
//return null;
}
var craving = new CravingSiteScript();
try {
var text = craving.getResponseText( url );
} catch ( e ) {
text = "";
}
if ( !text ) return null;
if ( text.match( /
]*)?>\s*(.*?)\s*<\/title\s*>/im ) ) {
var title = craving.decodeHtml( RegExp.$1 ).replace( /\s*-[^\-]*$/, "" ).replace( /\s*-[^\-]*$/, "" );
}
if ( !title &&
text.match( /]*)?>\s*(.*?)\s*<\/h2\s*>/im ) ) {
title = craving.decodeHtml( RegExp.$1 );
}
if ( !title ) title = "sexvideos_" + ( vid || new Date().getTime() );
title = title.replace(/[\\\/:*?"<>|]/g, "_");
if ( text.match( /loading_player\s*\(\s*('|")(.*?)\1/ ) ) {
var grab_url = RegExp.$2;
}
if ( !grab_url ) return null;
var data = "post_name=player&grab_url=" + encodeURIComponent( grab_url );
var posturl = "http://porn69.org/ajax.php";
try {
text = craving.getResponseText( posturl, data, "POST" );
} catch ( e ) {
text = "";
}
var realUrl = "";
var arrTmp = text.split( "*_*" );
if ( arrTmp[1] ) {
realUrl = arrTmp[1];
if ( arrTmp[2] ) {
realUrl = realUrl + ( ( realUrl.indexOf("?")<0 )? "?":"&" ) + arrTmp[2] + "=0";
}
}
if ( realUrl ) return { videoTitle0: title, videoUrl0: realUrl };
//end
//xvideos
var xvideosurl = base64Decode( grab_url );
var objInc = new clsIncludeSiteScript();
if ( !objInc.isOK ) return null;
var objScript = objInc.includeSiteScript( "xvideos.site.js" );
if ( !objScript ) return null;
if ( !objScript.isSiteUrl( xvideosurl ) ) return null;
var rtn = objScript.getVideoDetail( xvideosurl );
if ( !rtn ) return null;
rtn.videoTitle0 = title;
return rtn;
}
/************************************************************
* Dark Knight さんのサイトスクリプト
* nantokadoga.site.js (var 0.7) より
* base64 encode, decode
************************************************************/
function base64Decode( str ) {
var base64Table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
var result = '';
var p = -8;
var a = 0;
var c;
for ( var i = 0; i < str.length; i++ ) {
if ( ( c = base64Table.indexOf( str.charAt( i ) ) ) < 0 ) {
continue;
}
a = ( a << 6 ) | ( c & 63 );
if ( ( p += 6 ) >= 0 ) {
var d = ( a >> p ) & 255;
if ( c != 64 ) {
result += String.fromCharCode( d );
}
a &= 63;
p -= 8;
}
}
return result;
}
function clsIncludeSiteScript() {
var code1 = "(function(){\n\n";
var code2 = "\n\nreturn {'isSiteUrl':isSiteUrl,'getVideoDetail':getVideoDetail};})()";
var cePath = "\\CravingExplorer\\site-script\\";
this.isOK = false;
//initialize
try {
var appPath = ( new ActiveXObject( "WScript.Shell" ) ).SpecialFolders( "AppData" );
this.isOK = true;
} catch( e ) {
appPath = "";
this.isOK = false;
}
function evalScript( strFullPath, strCharset ) {
try {
var objStream = new ActiveXObject( "ADODB.Stream" );
objStream.Charset = strCharset;
objStream.Open();
objStream.LoadFromFile( strFullPath );
var obj = eval( "(" + code1 + objStream.ReadText() + code2 + ")" );
objStream.Close();
} catch( e ) {
obj = null;
}
if ( !obj || typeof obj != "object" ) return null;
if ( typeof obj.isSiteUrl != "function" ) return null;
if ( typeof obj.getVideoDetail != "function" ) return null;
return obj;
}
this.includeSiteScript = function ( strFileName ) {
if ( !this.isOK ) return null;
var strFullPath = appPath + cePath + strFileName;
var objS = evalScript( strFullPath, "unicode" );
if ( !objS ) objS = evalScript( strFullPath, "utf-8" );
return objS;
};
}