// ==SiteScript==
// @siteName GotPorn
// @siteUrl https://www.gotporn.com/
// @author Mayan
// @authorUrl
// @scriptUrl
// @description
// @date 2018/07/27
// @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( /https?:\/\/(?:[^\/]+\.)?gotporn\.com\/[^\/?]+\/video-\d+/ ) ) return true;
if ( url.match( /https?:\/\/(?:[^\/]+\.)?gotporn\.com\/video\/\d+/ ) ) return true;//順序注意
if ( url.match( /https?:\/\/(?:[^\/]+\.)?gotporn\.com\/video\/\d+\/embedframe/ ) ) return true;//順序注意
if ( url.match( /https?:\/\/(?:[^\/]+\.)?gotporn\.com\/embed\/\d+/ ) ) return true;
if ( url.match( /https?:\/\/(?:[^\/]+\.)?gotporn\.com\/(?:[^?]+\/)*[^\/?]+\.swf(\?.+)/ ) ) return true;
return false;
}
function getVideoDetail( url ) {
//url = url.replace( /^\s*http:\/\//, "https://" );
//url = url.replace( /^\s*https?:\/\/gotporn\.com\//, "https://www.gotporn.com/" );
var vid = "";
if ( url.match( /https?:\/\/(?:[^\/]+\.)?gotporn\.com\/[^\/?]+\/video-(\d+)/ ) ) {
vid = RegExp.$1;
} else
if ( url.match( /https?:\/\/(?:[^\/]+\.)?gotporn\.com\/(?:video|embed)\/(\d+)/ ) ) {
vid = RegExp.$1;
} else
if ( url.match( /https?:\/\/(?:[^\/]+\.)?gotporn\.com\/(?:[^?]+\/)*[^\/?]+\.swf(\?.+)/ ) ) {
var prm = RegExp.$1;
if ( prm.match( /[?&]videoid=(\d+)/ ) ) vid = RegExp.$1;
var realUrl = getRealUrl_fromPrm( prm );
if ( realUrl ) {
var title = "gotporn_" + ( vid || new Date().getTime() );
return { videoTitle0: title, videoUrl0: realUrl };
}
}
if ( !vid ) return null;
var craving = new CravingSiteScript();
try {
var objHttp = new ActiveXObject( "WinHttp.WinHttpRequest.5.1" );
objHttp.option(12) = true;
} catch ( e ) {
objHttp = null;
}
if ( !objHttp ) return null;
var ret = getVideoDetail_page( vid, craving, objHttp );
if ( ret ) return ret;
ret = getVideoDetail_embedframe( vid, craving, objHttp );
if ( ret ) return ret;
var realUrl = getVideoUrl_swf( vid, craving, objHttp );
if ( realUrl ) {
var title = "gotporn_" + ( vid || new Date().getTime() );
title = title.replace(/[\\\/:*?"<>|]/g, "_");
return { videoTitle0: title, videoUrl0: realUrl };
}
return null;
}
function getVideoDetail_page( vid, craving, objHttp ) {
var pageurl = "https://www.gotporn.com/dummy/video-" + vid;
try {
objHttp.open( "GET", pageurl, false );
objHttp.send();
var text = objHttp.responseText;
var allh = objHttp.getAllResponseHeaders();
} catch ( e ) {
text = "";
}
if ( !text ) return null;
//cookie
var hst_session = "";
if ( allh && allh.match( /\s+laravel_session\s*=\s*([^;]+);/ ) ) {//hst_session->laravel_session
hst_session = RegExp.$1;
}
var title = "";
if ( !title &&
text.match( /
]*?class\s*=\s*("|')?video-title\1[^>]*>\s*(.*?)\s*<\/h1>/im ) ) {
title = craving.decodeHtml( RegExp.$2 );
}
if ( !title &&
text.match( /]*?property\s*=\s*("|')?og:title\2[^>]*?)>/im )
&& RegExp.$1.match( /\s+content\s*=\s*("|')(.*?)\1/im ) ) {
title = craving.decodeHtml( RegExp.$2 ).replace( /\s+on GotPorn\s*$/i, "" );
}
if ( !title &&
text.match( /]*?id\s*=\s*("|')?videoAbout\1[^>]*>\s*
]*itemprop\s*=\s*("|')?name\3[^>]*)>/im )
&& RegExp.$2.match( /\s+content\s*=\s*("|')(.*?)\1/im ) ) {
title = craving.decodeHtml( RegExp.$2 );
}
if ( !title &&
text.match( /
]*)?>\s*(.*?)\s*<\/title\s*>/ ) ) {
title = craving.decodeHtml( RegExp.$1.replace( /\s+on GotPorn\s*$/i, "" ) );
}
if ( !title ) title = "gotporn_" + ( vid || new Date().getTime() );
title = title.replace(/[\\\/:*?"<>|]/g, "_");
var realUrl = "";
if ( text.match( /