// ==SiteScript==
// @siteName Phim HQ
// @siteUrl http://phimhq.org/
// @author mayan
// @authorUrl
// @scriptUrl
// @description
// @date 2014/04/28
// @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, "/" );
}
}
var _PhimHQ = {};
_PhimHQ.showMsg = true;
function isSiteUrl( url ) {
if ( url.match( /http:\/\/(?:www\.)?phimhq\.org\/xem-phim\/[^?]+?\/\d+\.html?/ ) ) return true;
return false;
}
function getVideoDetail( url ) {
if ( url.match( /http:\/\/(?:www\.)?phimhq\.org\/xem-phim\/[^?]+?\/(\d+)\.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*Xem\s+Phim\s*/i,"" );
}
if ( !title ) title = "phimhq_" + vid;
title = title.replace(/[\\\/:*?"<>|]/g, "_");
if ( text.match( /jwplayer\s*\([^)]*\)\.setup\(([\s\S]*?)\)\s*;/im ) ) {
text = RegExp.$1;
}
if ( text.match( /[{,]\s*("|')?proxy\.link\1\s*:\s*("|')(.*?)\2\s*[{,]/m ) ) {
var pxylnk = RegExp.$3;
if ( pxylnk.match( /^phimhq\*([0-9a-f]+)$/i ) ) pxylnk = ( new clsAES_phimhq() ).decrypt( RegExp.$1 );
}
if ( !pxylnk ) {
text = text.replace( /("|')?logo\1\s*:\s*\{[^}]*}/, "" ).replace( /("|')?tracks\1\s*:\s*\{[^}]*}/, "" );
if ( text.match( /[,{]\s*("|')?file\1\s*:\s*("|')(.*?)\2\s*[,}]/m ) ) {
var m3u8 = RegExp.$3;
}
}
var src = pxylnk || m3u8;
if ( !src ) return null;
var objS = { "src": ( pxylnk || m3u8 ) };
if( !setType( objS ) || !objS.type || objS.type == "unknown" ) {
if ( _PhimHQ.showMsg ) showMsg( src );
return null;
}
var msg = "";
switch ( objS.type ) {
case "clipvn":
case "nhaccuatui":
case "zingvn":
case "dailymotion":
if ( !objS.script ) break;
var objInc = new clsIncludeSiteScript();
if ( !objInc.isOK ) break;
var objScript = objInc.includeSiteScript( objS.script );
if ( !objScript ) {
msg = "script=" + objS.script + "\nスクリプトの読み込みに失敗。";
break;
}
if ( !objScript.isSiteUrl( objS.dummy || objS.src ) ) {
msg = "script=" + objS.script + "\nURL不適合。";
break;
}
rtn = objScript.getVideoDetail( objS.dummy || objS.src );
if ( !rtn ) {
msg = "script=" + objS.script + "\n動画URL取得失敗。";
break;
}
objInc.replaceTitle( rtn, title );
return rtn;
break;
case "picasa":
case "drive_google":
if ( !objS.func ) break;
var objRef = { "url":objS.src, "base":"http://player.phimhq.org/plugins/", "text":"" };
rtn = objS.func( objRef, craving );
if ( !rtn ) {
msg = "動画URL取得失敗。";
break;
}
rtn.videoTitle0 = title;
return rtn;
break;
case "direct":
return { videoTitle0: title, videoUrl0: objS.src };
break;
case "youtube":
if ( _PhimHQ.showMsg ) {
var objBx = new clsMsgBox();
if ( objBx.isOK ) {
var rtn = objBx.MsgBox( "YouTube の埋め込み動画かもしれません。"
+ "\n配信元:" + objS.src
+ "\n\nCraving Explorer へ送ってみますか?"
, "from phimhq.site.js", 3 );
if ( rtn == 6 ) sendCE( objS.src );
}
}
return null;
break;
case "stream":
case "truongxuavn":
case "unknown":
msg = "未対応。";
break;
default:
}
if ( _PhimHQ.showMsg ) showMsg( objS.src, msg );
return null;
}
/* decrypt */
function clsAES_phimhq() {
var keySize = 192;
var blockSize = 128;
var mode = "ECB";
var key = "7a566a4367354b627068696d4851566f624d644b";
var keySizeInByte = keySize / 8;
var objAES = new clsAES( keySize, blockSize );
var arrKey = objAES.hexToByteArray( key );
var diff = keySizeInByte - arrKey.length;
if ( diff < 0 ) arrKey = arrKey.slice( 0, keySizeInByte );
else if ( diff > 0 ) for ( var i = 0; i < diff; i++ ) arrKey.push( 0 );
function decrypt_gk( strHex ) {
var arrTxt = objAES.hexToByteArray( strHex );
try {
var arrRet = objAES.rijndaelDecrypt( arrTxt, arrKey, mode );
} catch( e ) {
arrRet = undefined;
}
if ( !arrRet || !( arrRet instanceof Array ) ) return "";
else return objAES.byteArrayToString( arrRet );
}
this.decrypt = decrypt_gk;
}
function clsAES( intKeySize, intBlockSize ) {
//Fritz Schneider 氏の rijndael.js を使っています。
//Google Closure Compilerを用いて最適化してあります。
/* rijndael.js ここから */
/* rijndael.js Rijndael Reference Implementation
Copyright (c) 2001 Fritz Schneider
This software is provided as-is, without express or implied warranty.
Permission to use, copy, modify, distribute or sell this software, with or
without fee, for any purpose and by any individual or organization, is hereby
granted, provided that the above copyright notice and this paragraph appear
in all copies. Distribution as a part of an application or binary must
include the above copyright notice in the documentation and/or other materials
provided with the application or distribution.
As the above disclaimer notes, you are free to use this code however you
want. However, I would request that you send me an email
(fritz /at/ cs /dot/ ucsd /dot/ edu) to say hi if you find this code useful
or instructional. Seeing that people are using the code acts as
encouragement for me to continue development. If you *really* want to thank
me you can buy the book I wrote with Thomas Powell, _JavaScript:
_The_Complete_Reference_ :)
This code is an UNOPTIMIZED REFERENCE implementation of Rijndael.
If there is sufficient interest I can write an optimized (word-based,
table-driven) version, although you might want to consider using a
compiled language if speed is critical to your application. As it stands,
one run of the monte carlo test (10,000 encryptions) can take up to
several minutes, depending upon your processor. You shouldn't expect more
than a few kilobytes per second in throughput.
Also note that there is very little error checking in these functions.
Doing proper error checking is always a good idea, but the ideal
implementation (using the instanceof operator and exceptions) requires
IE5+/NS6+, and I've chosen to implement this code so that it is compatible
with IE4/NS4.
And finally, because JavaScript doesn't have an explicit byte/char data
type (although JavaScript 2.0 most likely will), when I refer to "byte"
in this code I generally mean "32 bit integer with value in the interval
[0,255]" which I treat as a byte.
See http://www-cse.ucsd.edu/~fritz/rijndael.html for more documentation
of the (very simple) API provided by this code.
Fritz Schneider
fritz at cs.ucsd.edu
*/
var keySizeInBits=128,blockSizeInBits=128,roundsArray=[,,,,[,,,,10,,12,,14],,[,,,,12,,12,,14],,[,,,,14,,14,,14]],shiftOffsets=[,,,,[,1,2,3],,[,1,2,3],,[,1,3,4]],Rcon=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],SBox=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,
178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,
75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],SBoxInverse=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,
80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,
160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125];function cyclicShiftLeft(a,c){var b=a.slice(0,c);return a=a.slice(c).concat(b)}var Nk=keySizeInBits/32,Nb=blockSizeInBits/32,Nr=roundsArray[Nk][Nb];function xtime(a){a<<=1;return a&256?a^283:a}function mult_GF256(a,c){var b,d=0;for(b=1;256>b;b*=2,c=xtime(c))a&b&&(d^=c);return d}
function byteSub(a,c){var b;b="encrypt"==c?SBox:SBoxInverse;for(var d=0;4>d;d++)for(var e=0;eb;b++)a[b]="encrypt"==c?cyclicShiftLeft(a[b],shiftOffsets[Nb][b]):cyclicShiftLeft(a[b],Nb-shiftOffsets[Nb][b])}
function mixColumn(a,c){for(var b=[],d=0;de;e++)b[e]="encrypt"==c?mult_GF256(a[e][d],2)^mult_GF256(a[(e+1)%4][d],3)^a[(e+2)%4][d]^a[(e+3)%4][d]:mult_GF256(a[e][d],14)^mult_GF256(a[(e+1)%4][d],11)^mult_GF256(a[(e+2)%4][d],13)^mult_GF256(a[(e+3)%4][d],9);for(e=0;4>e;e++)a[e][d]=b[e]}}function addRoundKey(a,c){for(var b=0;b>8&255,a[2][b]^=c[b]>>16&255,a[3][b]^=c[b]>>24&255}
function keyExpansion(a){var c=[];Nk=keySizeInBits/32;Nb=blockSizeInBits/32;Nr=roundsArray[Nk][Nb];for(var b=0;b>8&255]|SBox[a>>16&255]<<8|SBox[a>>24&255]<<16|SBox[a&255]<<24)^Rcon[Math.floor(b/Nk)-1]:6>24&255]<<24|SBox[a>>16&255]<<16|SBox[a>>8&255]<<8|SBox[a&255]),c[b]=c[b-Nk]^a;return c}
function Round(a,c){byteSub(a,"encrypt");shiftRow(a,"encrypt");mixColumn(a,"encrypt");addRoundKey(a,c)}function InverseRound(a,c){addRoundKey(a,c);mixColumn(a,"decrypt");shiftRow(a,"decrypt");byteSub(a,"decrypt")}function FinalRound(a,c){byteSub(a,"encrypt");shiftRow(a,"encrypt");addRoundKey(a,c)}function InverseFinalRound(a,c){addRoundKey(a,c);shiftRow(a,"decrypt");byteSub(a,"decrypt")}
function encrypt(a,c){var b;if(a&&8*a.length==blockSizeInBits&&c){a=packBytes(a);addRoundKey(a,c);for(b=1;ba[b]?"0":"")+a[b].toString(16);return c}}function hexToByteArray(a){var c=[];if(!(a.length%2)){if(0==a.indexOf("0x")||0==a.indexOf("0X"))a=a.substring(2);for(var b=0;b objRef.text
var location = objRef.url;
var safe1 = 50;//redirect回数の上限値
var safe2 = 100;//header読み取り行数の上限値
var base = objRef.base || "http://player.phimhq.org/plugins/";
var phpurl = base + "plugins_player.php";
var success = false;
for ( var i = 0; i < safe1; i++ ) {
var data = "ihttpheader=true&iagent=Mozilla%2F5%2E0%20%28Windows%20NT%206%2E1%3B%20WOW64%3B%20rv%3A13%2E0%29%20Gecko%2F20100101%20Firefox%2F13%2E0"
+ "&iheader=true"
+ "&url=" + encodeURIComponent( location );
try {
var text = craving.getResponseText( phpurl, data, "POST" );
} catch( e ) {
text = "";
}
var arrL = text.split( /(\r\n|\n|\r)/ );
if ( arrL[0].match( /^HTTP\/[.\d]+\s+(\d+)/i ) ) var status = parseInt( RegExp.$1,10 );
else status = 0;
if ( 200 <= status && status < 300 ) {
success = true;
break;
}
if ( status < 200 || 400 <= status ) {
success = false;
break;
}
var arrH = [];
for ( var j = 1; j < safe2; j++ ) {
if ( arrL[j].match( /^\s*$/ ) ) break;
var arrF = arrL[j].split( ":" );
var fn = arrF.shift().replace( /^\s+/,"" ).replace( /\s+$/,"" );
if ( !fn ) continue;
fn = fn.toLowerCase();
if ( arrF[0] == "undefined" ) continue;
var fv = arrF.join( ":" ).replace( /^\s+/,"" );
arrH[ fn ] = fv;
}
location = arrH[ "location" ];
if ( !location ) {
success = false;
break;
}
}
if ( success ) objRef.text = text;
else objRef.text = "";
return objRef;
}
function DriveGoogle() {
var _YouTube = {};
_YouTube.HD = {
"name" : "HD",
"38" :170,//mp4, 3072
"37" :160,//mp4, 1080
"46" :150,//webm,1080
"22" :140,//mp4, 720
"45" :130,//webm, 720
"35" :120,//flv, 480
"59" :110,//mp4, 480 ?
"44" :100,//webm, 480
"34" : 90,//flv, 360
"78" : 80,//mp4, 360 ?
"43" : 70,//webm, 360
"18" : 60,//mp4, 360
"6" : 50,//flv, 270
"5" : 40,//flv, 240
"36" : 30,//3gp, 240
"17" : 20,//3gp, 144
"13" : 10 //3gp
};
_YouTube.FmtPriority = _YouTube.HD;
function getVideoDetail_drivegoogle( objRef, craving ) {
//require: getContent()
//objRef.url, base,
if ( !objRef.url || typeof objRef.url != "string" ) return null;
if ( objRef.url.match( /https?:\/\/(?:drive|docs?)\.google\.com\/file\/d\/([0-9A-Za-z]+)/i ) ) {
var vid = RegExp.$1;
} else {
//return null;
}
getContent( objRef, craving );//add text property
if ( !objRef.text ) return null;
//var text = objRef.text;
var stream_map = "";
if ( objRef.text.match( /[{,]\s*("|')?url_encoded_fmt_stream_map\1\s*:\s*("|')(.*?)\2\s*[{,]/m ) && RegExp.$3 ) {
stream_map = decodeDataSC( RegExp.$3 );
}
var arrStm = parseMap( stream_map );
if ( arrStm.length <= 0 &&
objRef.text.match( /[{,]\s*("|')?fmt_stream_map\1\s*:\s*("|')(.*?)\2\s*[{,]/m ) && RegExp.$3 ) {
var stream_map_old = decodeDataSC( RegExp.$3 );
var arrC = stream_map_old.split( "," );
for ( var i = 0; i < arrC.length; i++ ) {
if ( arrC[i].match( /(\d+)\|(http[^|]+)/ ) ) {
var obj = {};
obj.itag = RegExp.$1;
obj.url = RegExp.$2;
arrStm.push( obj );
}
}
}
if ( arrStm.length <= 0 ) return null;
for ( var i = 0; i < arrStm.length; i++ ) {
if ( arrStm[i].sig ) signature = arrStm[i].sig;
else if ( arrStm[i].s ) signature = decrypt( arrStm[i].s );
else signature = "";
if ( arrStm[i].url && signature ) {
arrStm[i].url = arrStm[i].url + ( (arrStm[i].url.indexOf("?")<0)?"?":"&" ) + "signature=" + signature;
}
if ( _YouTube.FmtPriority[ arrStm[i].itag ] != undefined ) {
arrStm[i].priority = _YouTube.FmtPriority[ arrStm[i].itag ];
} else {
arrStm[i].priority = 0;
}
}
arrStm.sort( function(a,b){return b.priority - a.priority;} );
var realUrl = arrStm[0].url;
if ( !realUrl ) return null;
if ( objRef.text.match( /]*?itemprop\s*=\s*("|')?name\2[^>]*)>/im )
&& RegExp.$1.match( /\s+content\s*=\s*("|')(.*?)\1/i ) ) {
var title = craving.decodeHtml( RegExp.$2 );
}
if ( !title &&
objRef.text.match( /]*)?>\s*(.*?)\s*<\/title\s*>/im ) ) {
title = craving.decodeHtml( RegExp.$1 ).replace( /\s*-[^-]*/,"" );
}
if ( !title ) title = "docgoogle_" + ( vid || new Date().getTime() );
return { videoTitle0: title, videoUrl0: realUrl };
}
function decodeDataSC( str ) {
if ( !str || typeof str != "string" ) return "";
return str.replace( /\\\//g, "/" ).replace( /\\u([0-9A-Fa-f]{4})/g, function(a,b){return String.fromCharCode(parseInt(b,16));} );
}
function parseMap( str ) {
var arrRtn = [];
if ( !str || typeof str != "string" ) return arrRtn;
var arrCm = str.split( "," );
for ( var i = 0; i < arrCm.length; i++ ) {
var arrAm = arrCm[i].split( "&" );
var obj = {};
for ( var j = 0; j < arrAm.length; j++ ) {
var arrEq = arrAm[j].split( "=" );
var fn = arrEq.shift();
var fv = arrEq.join( "=" );
if ( fn ) {
obj[fn] = fv? decodeURIComponent( fv.replace(/\+/g," ") ): "";
}
}
arrRtn.push( obj );
}
return arrRtn;
}
/* 140430 */
//http://s.ytimg.com/yts/swfbin/player-vflHoZPOA/watch_as3.swf
//Last-Modified: Tue, 29 Apr 2014 21:29:31 GMT
//public static var TIMESTAMP:Number = 16189;
function decrypt( str ) {
var arr = str.split( "" );
arr = arr.slice( 1 );
arr.reverse();
swap( arr, 26 );
return arr.join( "" );
function swap( arr, index ) {
var tmp = arr[0];
arr[0] = arr[ index % arr.length ];
arr[index] = tmp;
}
}
//( objRef, craving )
return { "getVideoDetail": getVideoDetail_drivegoogle };
}
function getVideoDetail_picasa( objRef, craving ) {
//require: getContent()
//objRef.url, objRef.base
//caution: php return partial text, don't use getContent.
if ( objRef.url.match( /https?:\/\/picasaweb\.google\.com\/(\d+)\/([^\/?]+)/ ) ) {
var usrid = RegExp.$1;
var vid = RegExp.$2;
} else {
//return null;
}
//getContent( objRef, craving );
var base = objRef.base || "http://player.phimhq.org/plugins/";
var data = "isslverify=true&ihttpheader=true&iagent=Mozilla%2F5%2E0%20%28Windows%20NT%206%2E1%3B%20WOW64%3B%20rv%3A13%2E0%29%20Gecko%2F20100101%20Firefox%2F13%2E0"
+ "&url=" + encodeURIComponent( objRef.url );
var phpurl = objRef.base + "plugins_player.php";
try {
objRef.text = craving.getResponseText( phpurl, data, "POST" );
} catch( e ) {
objRef.text = "";
}
if ( !objRef.text ) return null;
var realUrl = "";
//if ( objRef.text.match( /[{,]\s*("|')?content\1\s*:\s*(\[[^>]*?\])\s*[},]/ ) ) {
if ( objRef.text.match( /content("|')?\s*:\s*(\[[^>]*?\])/m ) ) {
var cont = RegExp.$2;
}
if ( !cont ) return null;
try {
var arrCnt = ( new Function( "var a=" + cont + ";return a;" ) )();
} catch( e ) {
arrCnt = undefined;
}
if ( !arrCnt || !( arrCnt instanceof Array ) ) return null;
var arrDat = [];
for ( var i = 0; i < arrCnt.length; i++ ) {
if ( !arrCnt[i] || typeof arrCnt[i] != "object" ) continue;
if ( arrCnt[i].type == "image/jpeg" ) continue;
if ( !arrCnt[i].url ) continue;
if ( typeof arrCnt[i].width != "number" ) arrCnt[i].width = 0;
arrDat.push( arrCnt[i] );
}
if( arrDat.length <= 0 ) return null;
arrDat.reverse();
arrDat.sort( function(a,b){return b.width - a.width;} );//may not necessary
realUrl = arrDat[0].url;
if ( !realUrl ) return null;
if ( objRef.text.match( /]*?name\s*=\s*("|')?title\2[^>]*)>/i )
&& RegExp.$1.match( /\s+content\s*=\s*("|')(.*?)\1/i ) ) {
var title = RegExp.$2;
}
if ( !title ) title = "picase_" + ( vid || (new Date()).getTime() );
title = title.replace(/[\\\/:*?"<>|]/g, "_");
return { videoTitle0: title, videoUrl0: realUrl };
}
/* plugins_player.php end */
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;
};
this.replaceTitle = function ( objRtn, title ) {
var count = 0;
var safe = 300;
while ( count < safe ) {
if ( objRtn[ "videoTitle" + count ] == undefined ) break;
count++;
}
if ( count <= 1 ) {
objRtn.videoTitle0 = title;
} else {
for ( var i = 0; i < count; i++ ) {
objRtn[ "videoTitle" + i ] = title + "_" + ( (i<9)?("0"+(i+1)):(""+(i+1)) );
}
}
return objRtn;
};
}
function showMsg( src, ps ) {
if ( _PhimHQ.showMsg === true ) {
var objBx = new clsMsgBox();
if ( objBx.isOK ) {
objBx.MsgBox( "取得できませんでした。"
+ "\n動画配信元:\n" + src
+ ( ps? ("\n\n" + ps): "" )
, "from phimhq.site.js", 0 );
}
}
}
/* msgbox */
function clsMsgBox(){
//WScript.Shell Popup
this.isOK = false;
this._objShell = null;
this._initialize = function (){
try{
this._objShell = new ActiveXObject( "WScript.Shell" );
this.isOK = true;
} catch( e ) {
this.isOK = false;
}
}
this._initialize();
this.MsgBox = function ( msg, title, btn ){
if ( btn == undefined ) btn = 1;
//btn=1の時ret: OK:1, キャンセル:2
if ( this.isOK )
return this._objShell.Popup( msg, 0, title, btn+64 );
}
}
/* msgbox */
/* send to CravingExplorer */
function sendCE( strUrl ) {
try {
var objCE = new ActiveXObject( "CravingExplorer.Api" );
var ret = objCE.addDownloadItem( strUrl, 'flv', true );
} catch( e ) {
}
return ret;
}
/* send to CravingExplorer end */