Sleazy Fork is available in English.

E-Hentai 中文功能集

E紳士功能中文總集

Pada tanggal 11 Juni 2016. Lihat %(latest_version_link).

// ==UserScript==
// @name         E-Hentai 中文功能集
// @namespace    Tast
// @version      0.06
// @description  E紳士功能中文總集
// @author       Tast
// @include      *://exhentai.org/*
// @include      *://ul.exhentai.org/*
// @include      *://*e-hentai.org/*
// @grant		 GM_getValue
// @grant		 GM_setValue
// @grant		 GM_getResourceURL
// @icon         http://exhentai.org/favicon.ico
// @require      https://code.jquery.com/jquery-2.2.4.min.js
// @require 	 https://code.jquery.com/ui/1.12.0-rc.2/jquery-ui.min.js
// @require 	 https://greasyfork.org/scripts/20286-chinesetr/code/ChineseTR.js
// @resource 	 JQUI	https://code.jquery.com/ui/1.12.0-rc.2/themes/smoothness/jquery-ui.css
// ==/UserScript==
//==============================================變數聲明==============================================
//1 USD = BTC/USD.
//JSON.stringify
document.cookie="nw=1; path=/"; //表站內容物不警告
var url	 		= window.location.href;
//https://jqueryui.com/draggable/#sortable/
//https://jqueryui.com/sortable/#placeholder

//RGB色碼表
//http://www.ifreesite.com/color/
//====================================================================================================
function listCookies() {
	return document.cookie.split(';');
	//aString += i + ' ' + decodeURIComponent(theCookies[i-1]) + "\n";
	/*
    var theCookies = document.cookie.split(';');
    var aString = '';
    for (var i = 1 ; i <= theCookies.length; i++) {
        aString += i + ' ' + theCookies[i-1] + "\n";
    }
    return aString;
	*/
}
//====================================================================================================
//Setting Box
var TagFlagColor = {
	 "0px -1px" :"#E2748B"
	,"0px -18px":"#DF9C73"
	,"0px -35px":"#B2B038"
	,"0px -52px":"#53B73F"
	,"0px -69px":"#3872B1"
	,"0px -86px":"#CB79E5"
	//最愛
	,"0px -2px"	:"#646464"
	,"0px -21px":"#FF6868"
	,"0px -40px":"#FFA561"
	,"0px -59px":"#FFF56B"
	,"0px -78px":"#68FF8B"
	,"0px -97px":"#CDFF84"
	,"0px -116px":"#8AFEFF"
	,"0px -135px":"#7268FF"
	,"0px -154px":"#AC57FE"
	,"0px -173px":"#FE50C8"
}

uconfig();
function uconfig(){ if(!url.match('uconfig.php')) return;
	var JQUI = GM_getResourceURL("JQUI");
	$('head').append('<link rel="stylesheet" href="' + JQUI + '" type="text/css" />');
	
	$(	 "<div id='uConfig' style='border-radius:25px;border: 2px solid blue;padding: 20px; '>"
		+"<div id='uConfigFN'></div>"
		+"<br><div align='center'>"
			+"<input type='button' class='stdbtn' id='uConfigApply' value=' -儲存本框設定- '></div></div><br><br>"
	).insertAfter("#outer h1:eq(0)");
	
	$("#uConfigApply").click(function(){
		//===============================================================
		//TagFlagColor
		var TagFlagColorSet = []
		$("#sortable li").each(function(){
			var BK_Pos = $(this).attr("TagFlagColor");
			TagFlagColorSet.push(BK_Pos)
		})
		GM_setValue("TagFlagColor"	,TagFlagColorSet)
		GM_setValue("TagFlagFly"	,$("#uCTFBKC").prop("checked"))
		//alert(GM_getValue("TagFlagColor"));
		//alert(GM_getValue("TagFlagFly"));
		//===============================================================
		//GalleryAutoRate
		var AutoRateNum = parseInt($("#rating_box").val());
		GM_setValue("AutoRateNum",AutoRateNum);
		//alert(GM_getValue("AutoRateNum"));
		//===============================================================
	})
	
	uConfigTagFlagBKColor();
	uConfigAutoRate();
}

function uConfigTagFlagBKColor(){
	$(	"<style type='text/css'>"
			+"#sortable { list-style-type: none; margin: 0; padding: 0; width: 100%; }"
			+"#sortable li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; height: 1.5em; }"
			+"html>body #sortable li { height: 2.2em; line-height: 1.2em; }"
			+".ui-state-highlight { height: 2.2em; line-height: 1.2em; }"
	+"</style>").appendTo("head");
		
	$("#uConfigFN").append("<br>"
		+"<h2>畫冊列表背景顏色 ( 透過畫冊旗幟 )</h2>"
		+"<p>設定畫冊列表顯示標籤旗幟時設定優先的背景色 ( 拖曳改變順序 )<p>"
		+'<input type="checkbox" name="uCTFBKC" id="uCTFBKC" checked="checked">'
			+'<label for="uCTFBKC">畫冊自動排列到最上方</label><br><br>'
		+'<ul id="sortable"></ul><br>'
		+"<button id='uCTFBKCbutton'>重新預設排列</button>");
	
	$("div[style*='fav.png']").each(function(i){
		var Tags	= $("input[maxlength='20'][name*='favorite_']:eq(" + i + ")").val();
		var BK_Pos 	= $(this).css("background-position");
		var BK_Cor 	= TagFlagColor[BK_Pos];
		if(BK_Cor 	== undefined) BK_Cor = "black";
		
		$("#sortable").append('<li class="ui-state-default"></li>');
		$(this).clone().appendTo("#sortable li:last");
		$("#sortable li:last")
			.css("width","60%")
			.css("background-color",BK_Cor)
			.css("color","black")
			.attr("TagFlagColor",BK_Pos)
			.attr("name","fav-" + i)
			.append('&nbsp;#' + (i+1) + ":" + Tags)
			//.append('&nbsp;畫冊標籤旗幟 - ' + (i + 1));
	})
	
	$("div[style*='tf.png']").each(function(i){
		var Tags	= $("input[style='width:540px'][type='text']:eq(" + i + ")").val();
		var BK_Pos 	= $(this).css("background-position");
		var BK_Cor 	= TagFlagColor[BK_Pos];
		if(BK_Cor 	== undefined) BK_Cor = "black";
		
		$("#sortable").append('<li class="ui-state-default"></li>');
		$(this).clone().appendTo("#sortable li:last");
		$("#sortable li:last")
			.css("color","white")
			.css("background-color",BK_Cor)
			.attr("name","tf-" + i)
			.attr("TagFlagColor",BK_Pos)
			.append('&nbsp;#' + (i+1) + ":" + Tags)
	})
	
	var TagFlagColorI = GM_getValue("TagFlagColor",[]);
	for(var i = 0 ; i < TagFlagColorI.length ; i++){
		$("#sortable li[TagFlagColor='" + TagFlagColorI[i] + "']").appendTo("#sortable");
	}
	
	$( "#sortable" ).sortable({ placeholder: "ui-state-highlight" });
    $( "#sortable" ).disableSelection();
	
	$("#uCTFBKCbutton").click(function(){
		//http://stackoverflow.com/a/13490529
		$("#sortable li[name*='fav']").sort(function(a,b) {
			return $(a).attr("name") > $(b).attr("name")
		}).appendTo('#sortable');
		
		$("#sortable li[name*='tf']").sort(function(a,b) {
			return $(a).attr("name") > $(b).attr("name")
		}).appendTo('#sortable');
	})
}

function uConfigAutoRate(){
	$(	"<style type='text/css'>"
			+'div.ir{width:80px;height:16px;background-repeat:no-repeat;background-image:url(http://ehgt.org/g/rt.png)}'
			+'div.irr{background-image:url(http://ehgt.org/g/rtr.png)}'
			+'div.irb{background-image:url(http://ehgt.org/g/rtb.png)}'
			+'div.irg{background-image:url(http://ehgt.org/g/rtg.png)}'
			+'div.ir img{width:80px;height:16px}'
	+"</style>").appendTo("head");
	
	$("#uConfigFN").append("<br><br>"
		+"<h2>畫冊自動評星 ( 可用當作已讀 )</h2>"
		+"<p>瀏覽畫冊時自動評星,已評星則忽略<p>評星數開關:"
		+'<input type="checkbox" id="rating_box" style="position:relative; top:2px"> - '
		+'<a id="rating_show" style="display:inline;"></a>'
		+'<div id="rating_image" class="ir" style="background-position: 0px -21px;">'
			+'<img src="http://ehgt.org/g/blank.gif" usemap="#rating" alt="">'
		+'</div><div id="rating_map"><map name="rating">'
			+'<area shape="rect" coords="0,0,7,16"   rating="1">'
			+'<area shape="rect" coords="8,0,15,16"  rating="2">'
			+'<area shape="rect" coords="16,0,23,16" rating="3">'
			+'<area shape="rect" coords="24,0,31,16" rating="4">'
			+'<area shape="rect" coords="32,0,39,16" rating="5">'
			+'<area shape="rect" coords="40,0,47,16" rating="6">'
			+'<area shape="rect" coords="48,0,55,16" rating="7">'
			+'<area shape="rect" coords="56,0,63,16" rating="8">'
			+'<area shape="rect" coords="64,0,71,16" rating="9">'
			+'<area shape="rect" coords="72,0,79,16" rating="10">'
		+'</map></div>'
	);
	
	var AutoRateNum = GM_getValue("AutoRateNum",0);
	if(AutoRateNum){
		update_rating_image(AutoRateNum);
		$("#rating_box").prop("checked",true).val(AutoRateNum);
		$("#rating_image").attr("class","ir irb");
		$("#rating_show").html(AutoRateNum);
		
	}
	else update_rating_image(10);
	
	$("#rating_map area").hover(function() {
		$("#rating_image").attr("class","ir irg");
		var b = $(this).attr("rating");
		update_rating_image(b);
		//console.error("update_rating_image" + b);
	},function(){
		var Elclass = $("#rating_image").attr("class");
		if(Elclass == "ir irb") return;
		$("#rating_image").attr("class","ir");
	}).click(function(){
		var b = $(this).attr("rating");
		$("#rating_image").attr("class","ir irb");
		$("#rating_box").prop("checked",true).val(b)
		$("#rating_show").html(b);
	})
	
	$("#rating_box").click(function(){
		if($("#rating_box").prop("checked")) return;
		$("#rating_box").val(0)
		$("#rating_show").html(0);
	})
	
	function update_rating_image(b) {
		b = Math.round(b);
		var a = -80 + Math.ceil(b / 2) * 16;
		var c = b % 2 == 1 ? -21 : -1;
		document.getElementById("rating_image").style.backgroundPosition = a + "px " + c + "px";
	}
}

//====================================================================================================
TagFlagBKColor();
function TagFlagBKColor(){
	var TagFlagFly = GM_getValue("TagFlagFly",false);
	var TagFlagColorI = GM_getValue("TagFlagColor",[]);
	for(var i = 0 ; i < TagFlagColorI.length ; i++){
		//console.error(i);
		//縮圖模式=========================================================
		//標籤
		//$("div.itg:eq(0) div.tft[style*='" + TagFlagColorI[i] + "']").each(function(){
		$("div.tft[style*='" + TagFlagColorI[i] + "']").each(function(){
			var Target = $(this).parent().parent().parent();
			DoFlaged(Target,i)
		})
		//最愛
		//$("div.itg:eq(0) div.i[id*='favicon_'][style*='" + TagFlagColorI[i] + "']").each(function(){
		$("div.i[id*='favicon_'][style*='" + TagFlagColorI[i] + "']").each(function(){
			var Target = $(this).parent().parent().parent().parent()
			DoFlaged(Target,i,1)
			
			$(Target).find("div.id3 img")
				.css("opacity","0.6")
				.css("filter","alpha(opacity=60)")
				.css("border-width","1px")
				.css("border-color","#00E3E3")
				.css("border-style","solid")
				
			$(Target).find("div.id2 a")
				//.css("color","white")
				.css("color","#00E3E3")
			
			$(Target)
				.css("border-width","1px")
				.css("border-color","#00E3E3")
				//.css("border-style","dashed")
				.css("border-style","solid")
		})
		//列表模式=========================================================
		//標籤
		$("div.tfl[style*='" + TagFlagColorI[i] + "']").each(function(){
			var Target = $(this).parent().parent().parent().parent().parent()
			DoFlaged(Target,i)
		})
	}
	
	var Child = -1;
	function DoFlaged(Target,i,type){
		if($(Target).attr("Flaged") == "1") return;
		$(Target).css("background-color",TagFlagColor[TagFlagColorI[i]]);
		$(Target).attr("Flaged","1");
		
		if(TagFlagFly) $(Target).appendTo("div.itg:eq(0)");
		//$(Target).prependTo("div.itg:eq(0)");
	}
	
	if(TagFlagFly){
		$("div.itg:eq(0) div.id1[Flaged!='1']").each(function(){
			$(this).appendTo("div.itg:eq(0)")
		})
		
		$("div.itg:eq(0) div.c").appendTo("div.itg:eq(0)")
		$("div.id1").css("height","335px")
		$("div.id3").css("height","280px")
		//$("div.itg:eq(0) div.id1").css("height","335px")
		//$("div.itg:eq(0) div.id3").css("height","280px")
	}
}
//====================================================================================================
GalleryAutoRate();
function GalleryAutoRate(){ if(!url.match("hentai.org\/g\/")) return;
	var RateIMG = $("#rating_image[class='ir']").length;	if(!RateIMG) 		return;
	var AutoRateNum = GM_getValue("AutoRateNum",0);			if(!AutoRateNum)	return;
	$("#gdr area:eq(" + (AutoRateNum-1) + ")").click();
}

//====================================================================================================
//E[-X]Hentai Helper
//https://greasyfork.org/zh-TW/scripts/12869-e-x-hentai-helper/feedback
//http://stackoverflow.com/questions/179355/clearing-all-cookies-with-javascript
//https://blog.longwin.com.tw/2014/06/javascript-set-cookie-php-read-2014/
//alert(document.cookie);
/*
SadPandaGO();
function SadPandaGO(){ if(getQueryString("success",url) !== "1") return;
	
	
}
*/
/*
SadPanda();
function SadPanda(){ if($("img:eq(0)").attr("src") !== window.location.href) return;
	//alert(document.cookie);
	clearListCookies();
	GM_setValue("LoginCookie","");
	GM_setValue("Login","false");
	
	$("body").html('<iframe id="if_login" src="http://e-hentai.org/?login=1"></iframe><div id="if_div"></div>');
	
	setInterval(function(){
		//console.error('setInterval = ' + GM_getValue("Login","false"))
		if(GM_getValue("Login","false") == "true"){
			document.cookie = "yay" + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
			clearListCookies();
			
			//var cookie = GM_getValue("LoginCookie","");
			alert(document.cookie);
			//document.cookie = cookie;
			//alert(document.cookie);
			//window.location.href = "http://exhentai.org/?success=1"
			window.location = ""; // TO REFRESH THE PAGE
		}
	}, 1000);
}

function clearListCookies(){   
    var cookies = document.cookie.split(";");
	for(var i=0; i < cookies.length; i++) {
		var equals = cookies[i].indexOf("=");
		var name = equals > -1 ? cookies[i].substr(0, equals) : cookies[i];
		document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
	}
	
	clearCookie("yay")
	clearCookie("yay","exhentai.org","/")
	clearCookie("yay",".exhentai.org","/")
}

function clearCookie(name, domain, path){
    var domain = domain || document.domain;
    var path = path || "/";
    document.cookie = name + "=; expires=" + +new Date + "; domain=" + domain + "; path=" + path;
};

SadPandaLogin();
function SadPandaLogin(){ if(getQueryString("login",url) !== "1") return;
	
	var LoginForm = $("form[name='ipb_login_form']:eq(0)").clone();
	$(LoginForm).attr("action",$(LoginForm).attr("action") + "&logined=1");
	$("body").html("").append(LoginForm);
	
}

SadPandaLogined();
function SadPandaLogined(){ if(getQueryString("logined",url) !== "1") return;
	var Checker = $("#redirectwrap p:contains('You are now logged in as:')").length;
	//alert(Checker);
	if(Checker == 1){
		window.stop();
		window.location.href = "http://e-hentai.org/?catchCat=1";
	}
}

SadPandaCatchCat();
function SadPandaCatchCat(){ if(getQueryString("catchCat",url) !== "1") return;
	GM_setValue("LoginCookie",document.cookie);
	GM_setValue("Login","true");
	location.hash = "Logined";
}
*/
//====================================================================================================
LinkToHentai();
function LinkToHentai(){
	//alert(document.body.innerHTML);
	var GoText = "Error";
	var GoHref = "Error";
	
	var GoFilter = []
	
	if(url.match("g.e-hentai.org")){
		GoText = " 裡站"
		//GoHref = url.replace("g.e-hentai.org","exhentai.org")
		GoHref = "http://exhentai.org";
	}
	else {
		GoText = " 表站"
		GoHref = url.replace("exhentai.org","g.e-hentai.org")
	}
	
	$( "#nb img:eq(0)" ).clone().insertAfter( "#nb a:eq(0)");
	$( "#nb a:eq(0)" ).clone().html(GoText).attr("href",GoHref).insertAfter( "#nb img:eq(1)");
	
	//if(document.body.title === "") window.location.href = GoHref;
	//alert(listCookies());
}






//====================================================================================================
//E-Hentai Gallery Overview - How Rich Am I?
//https://greasyfork.org/zh-TW/scripts/6565-e-hentai-gallery-overview-how-rich-am-i
OverView_Money();
function OverView_Money(){ if(!url.match("home.php")) return;
	var exchange = "http://g.e-hentai.org/exchange.php";
	$(	 "<h2><font color='Sienna'>財產金庫</font></h2>"
		+"<div class='homebox'>"
		+"<table style='margin:10px auto'><tbody>"
			+"<tr>"
				+"<td><font color='Teal'>紳士幣</font>:</td>"
				+"<td><p id='FN_OVM_Credits' class='FC_OVM_p'></p></td>"
				+"<td><p class='FC_OVM_te'>Credits</a></td>"
			+"</tr><tr>"
				+"<td><font color='DarkOrchid'>駭斯幣</font>:</td>"
				+"<td><p id='FN_OVM_Hath' class='FC_OVM_p'></p></td>"
				+"<td><p class='FC_OVM_te'>Hath<p></td>"
				+"<td><p class='FC_OVM_te'>平均單價 (<b id='FN_OVM_CH_Rate'></b>)</p></td>"
				+"<td><p class='FC_OVM_te'><font color='Teal'>紳士幣</font></p></td>"
			+"</tr><tr>"
				+"<td><font color='RoyalBlue'>千圖幣</font>:</td>"
				+"<td><p id='FN_OVM_KGP' class='FC_OVM_p'></p></td>"
				+"<td><p class='FC_OVM_te'>kGP<p></td>"
				+"<td><p class='FC_OVM_te'>平均單價 (<b id='FN_OVM_CK_Rate'></b>)</p></td>"
				+"<td><p class='FC_OVM_te'><font color='Teal'>紳士幣</font></p></td>"
			+"</tr>"
		+"</tbody></table></div>"
	).insertAfter("div.homebox:eq(0)");
	$(".FC_OVM_p")	.css("float","right");
	$(".FC_OVM_te")	.css("float","left");
	
	$.get( exchange + "?t=hath", function( data ) {
		var Credits = new RegExp("Available:\\s*([,0-9]*)\\s*Credits"			,'i')	.exec(data)[1];
		var Hath 	= new RegExp("Available:\\s*([,0-9]*)\\s*Hath"				,'i')	.exec(data)[1];
		var CH_AVG	= new RegExp("<strong>Avg</strong>:\\s*([,0-9]*)\\s*Credits",'i')	.exec(data)[1];
		$("#FN_OVM_Credits").html(Credits);
		$("#FN_OVM_Hath")	.html(Hath);
		$("#FN_OVM_CH_Rate").html(CH_AVG);
	});
	$.get( exchange + "?t=gp", function( data ) {
		var kGP 	= new RegExp("Available:\\s*([,0-9]*)\\s*kGP"				,'i')	.exec(data)[1];
		var CK_AVG	= new RegExp("<strong>Avg</strong>:\\s*([,0-9]*)\\s*Credits",'i')	.exec(data)[1];
		$("#FN_OVM_KGP")	.html(kGP);
		$("#FN_OVM_CK_Rate").html(CK_AVG);
	});
}

//====================================================================================================
//Exchange_Hath();
function Exchange_Hath(){ if(!url.match("exchange.php\\?t=hath")) return;
	$("input").css("text-align","center");
	var AvaCredits	= $("div:contains('Available: '):contains(' Credits'):eq(0)")	.html();
	var AvaHath		= $("div:contains('Available: '):contains(' Hath'):eq(0)")		.html();
	var Credits		= new RegExp("Available:\\s*([,0-9]*)\\s*Credits",'i')	.exec(AvaCredits)[1].replace(new RegExp(",","gmi"),"");
	var Hath		= new RegExp("Available:\\s*([,0-9]*)\\s*Hath",'i')		.exec(AvaHath)	 [1].replace(new RegExp(",","gmi"),"");
	Credits 		= parseInt(Credits);
	Hath 			= parseInt(Hath);
	//購買駭斯幣 BuyCredits	
	var BuyHath 	= $("#bid_count");
	var BuyCredits 	= $("#bid_price");
	
	if($(BuyHath).val() 	== "0") $(BuyHath).val("");
	if($(BuyCredits).val() 	== "0") $(BuyCredits).val("");
	
	$(BuyHath).keyup(function(){ //alert("ccc");
		//$(BuyCredits).val($(BuyHath).val());
	})
	
	$(BuyCredits).keyup(function(){
		var BuyHathVal = parseInt($(BuyCredits).val());
		$(BuyHath).val( Math.floor(Credits / BuyHathVal) );
		
	})
	
	//賣出駭斯幣
	/*
	var SellHath 	= $("#ask_count");
	var SellCredits = $("#ask_price");
	
	if($(SellHath).val() 	== "0") $(SellHath).val("")
	if($(SellCredits).val() == "0") $(SellCredits).val("")
		
	$(SellHath).keyup(function(){ //alert("ccc");
		//$(SellCredits).val($(SellHath).val());
	})
	$(SellCredits).keyup(function(){
		var SellHathVal = parseInt($(SellCredits).val());
		$(SellHath).val( Math.floor(Credits / SellHathVal) );
		
	})
	*/
}

//====================================================================================================
//e-hentai magnet link
//https://greasyfork.org/zh-TW/scripts/13311-e-hentai-magnet-link/code

GalleryTorrents();
function GalleryTorrents(){ if(!url.match("gallerytorrents.php")) return;
	$("form a[href*='.torrent']").each(function(i){
		var magnet 	= "magnet:?xt=urn:btih:" + this.href.match(/\/(\w+)\.torrent/i)[1];
		var torrent	= this.href.split("?p=")[0];
		var HTML	= "<br><br><a style='color:blue' href='" + torrent + "'>[下載公眾用種子]</a>"
					+ "、<a style='color:green'      href='" + magnet  + "'>[下載公眾用磁鏈]</a>";
		$(this).after(HTML);
	});
	
	$("#ett ~ table a[href$='.torrent']").each(function(){
		var magnet 	= "magnet:?xt=urn:btih:" + this.href.match(/\/(\w+)\.torrent/i)[1];
		var HTML	= "<tr><td><a href='" + magnet + "'><font color='green'>公開用磁鏈</font></a></td>"
					+ "<td>( 可公開使用分享 - 發表或給予他人 )</td></tr>"
		$(this).parents("tbody:eq(0)").append(HTML);
	})
}

//====================================================================================================
//EH to ExH
//https://greasyfork.org/zh-TW/scripts/19810-eh-to-exh

GalleryNotAvailable();
function GalleryNotAvailable(){ if(!url.match("g.e-hentai.org\/g\/")) 	return;
	if(document.title !== "Gallery Not Available - E-Hentai Galleries") return;
	//$(window).on('beforeunload', function (){ return false; });
	$("#continue").parent().html("正轉移到裡站...");
	window.location.href = window.location.href.replace("g.e-hentai.org","exhentai.org");
}

//====================================================================================================
//Ex-Hentai: Frame Popups v0.2
//https://greasyfork.org/zh-TW/scripts/10268-ex-hentai-frame-popups
//FramePopups();
function FramePopups(){ 
	//http://stackoverflow.com/a/8434327
	$(	"<style type='text/css'>"
			+"#lb-oberlay { top: 0; left: 0; width: 100%; height: 100%; position: fixed; z-index: 100000; overflow: hidden; background: rgba(35,35,35,.7); }"
			+"#lb-frame { box-shadow: 5px 5px 10px black; position: fixed; left: 50%; top: 50%; z-index: 100001; border: 0; }"
		+"</style>").appendTo("head");
	
	//重叠元素就绪 
	var oberlay = $("<div id='lb-oberlay' style='display:none;'></div>");
	var popup 	= $("<iframe id='lb-frame' style='display:none;' seamless='true'></iframe>");
	$("body").append(oberlay).append(popup);
	
	//绑定元素事件
	function hideOberlay () { $("#lb-oberlay,#lb-frame").css("display","none"); }
	$(oberlay).click(hideOberlay);
	$(popup).load(function(){
		var wnd = $(popup)[0].contentWindow;
		wnd.close = hideOberlay;
		[].map.call(wnd.document.querySelectorAll('[style*="height"]'), function (x) {
			x.style.height = '';
		});
	})
	
	//仿 LightBox
	window.$(popup)[0] = function (url, w, h) {
		// 强行重写 /w\
		w += 20;
		h += 20;
		
		if ($(popup)[0].src != url) $(popup)[0].src = url;
		
		$(popup)[0].style.width  = w + 'px';
		$(popup)[0].style.height = h + 'px';
		$(popup)[0].style.marginLeft = -w/2 + 'px';
		$(popup)[0].style.marginTop  = -h/2 + 'px';
		$(oberlay)[0].style.display = $(popup)[0].style.display = 'block';
	};
}





//取得網址標記
function getQueryString( paramName,paramURL){
	if(paramURL == undefined) paramURL = window.location.href;
	
	paramName = paramName .replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]").toLowerCase();
	var reg = "[\\?&]"+paramName +"=([^&#]*)";
	var regex = new RegExp( reg );
	var regResults = regex.exec( paramURL.toLowerCase());
	if( regResults == null ) {
		   //alert(regResults);
		   return "";
	} else {
		   //alert(regResults[1]);
		   return regResults [1];
	}
}

function deleteAllCookies() {
    var cookies = document.cookie.split(";");

    for (var i = 0; i < cookies.length; i++) {
    	var cookie = cookies[i];
    	var eqPos = cookie.indexOf("=");
    	var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
    	document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
    }
}