E-Hentai 中文功能集

E紳士功能中文總集

Verze ze dne 14. 06. 2016. Zobrazit nejnovější verzi.

// ==UserScript==
// @name         E-Hentai 中文功能集
// @namespace    Tast
// @version      0.10
// @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
//RGB色碼表
//http://www.ifreesite.com/color/
//http://g.e-hentai.org/bounty.php?u=43883
//http://g.e-hentai.org/uploader/Luna_Flina
//====================================================================================================
document.cookie="nw=1; path=/"; //表站內容物不警告
var url	 		= window.location.href;
//====================================================================================================
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(){
		alert("已儲存設定");
		//===============================================================
		//TagFlagColor
		var TagFlagColorSet = []
		$("#sortable li").each(function(){
			var BK_Pos = $(this).attr("TagFlagColor");
			TagFlagColorSet.push(BK_Pos)
		})
		GM_setValue("TagFlagColor"	,TagFlagColorSet)
		GM_setValue("TagFlagFly"	,$("option.BKC:selected").val())
		//alert(GM_getValue("TagFlagColor"));
		//alert(GM_getValue("TagFlagFly"));
		//===============================================================
		//GalleryAutoRate
		var AutoRateNum = parseInt($("#rating_box").val());
		GM_setValue("AutoRateNum",AutoRateNum);
		//alert(GM_getValue("AutoRateNum"));
		//===============================================================
		//GallertRateAutoTranslucent
		if($("#rating_hide").prop("checked")) 
				GM_setValue("rating_hide","1");
		else 	GM_setValue("rating_hide","0");
		//===============================================================
		//HrefBlank
		if($("#HrefBlank").prop("checked")) 
				GM_setValue("HrefBlank","1");
		else 	GM_setValue("HrefBlank","0");
	})
	
	uConfigTagFlagBKColor();
	uConfigAutoRate();
	uConfigRateAutoTranslucent();
	uConfigHrefBlank();
}

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>"
		+"額外排列方式:"
		+"<select id='BKC'>"//selected="selected"
			+'<option class="BKC" value="0" style="color:darkred  ;font-weight:bold;">不使用排列</option>'
			+'<option class="BKC" value="1" style="color:darkgreen;font-weight:bold;">排列到上方</option>'
			+'<option class="BKC" value="2" style="color:darkblue ;font-weight:bold;">排列到下方</option>'
		+"</select>"
		+'<ul id="sortable"></ul><br>'
		+"<button id='uCTFBKCbutton'>重新預設排列</button>");
	
	var BKCval = GM_getValue("TagFlagFly","1");
	$("#BKC")[0].selectedIndex = parseInt(BKCval);
	//$("option.BKC[value='" + BKCval + "']").prop("selected",true);
	
	$("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";
	}
}

function uConfigRateAutoTranslucent(){
	$("#uConfigFN").append("<br><br>"
		+"<h2>已評星畫冊圖片透明化</h2>"
		+"<p>搜尋項目畫冊如已被自己評等過,縮圖即透明化:"
		+'<input type="checkbox" id="rating_hide" style="position:relative; top:2px"></p>'
	);
	if(GM_getValue("rating_hide","1") == "1") $("#rating_hide").prop("checked",true)
}

function uConfigHrefBlank(){
	$("#uConfigFN").append("<br><br>"
		+"<h2>新開連結</h2>"
		+"<p>改變所有靜態連結變成開新分頁:"
		+'<input type="checkbox" id="HrefBlank" style="position:relative; top:2px"></p>'
	);
	if(GM_getValue("HrefBlank","0") == "1") $("#HrefBlank").prop("checked",true)
}

//====================================================================================================
TagFlagBKColor();
function TagFlagBKColor(){ //if(url.match("favorites.php")) return;
	if(getQueryString("fly",url) == "0") return;
	
	var TagFlagFly 		= GM_getValue("TagFlagFly","0");
	var TagFlagColorI 	= GM_getValue("TagFlagColor",[]);
	//var IsListMode	 	= $("#dmi a[href*='?inline_set=dm_t']").length;
	//var IsThumMode 		= $("#dmi a[href*='?inline_set=dm_l']").length;
	//主要區塊
	for(var i = 0 ; i < TagFlagColorI.length ; i++){
		//console.error(i);
		//縮圖模式=========================================================
		//標籤
		$("div.itg 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.itg:eq(0) div.i[id*='favicon_'][style*='" + TagFlagColorI[i] + "']").each(function(){
			var Target = $(this).parent().parent().parent().parent();
			DoFlaged(Target,i);
			DoFaved(Target);
		})
		//列表模式=========================================================
		//標籤
		$("table.itg div.tfl[style*='" + TagFlagColorI[i] + "']").each(function(){
			var Target = $(this).parent().parent().parent().parent().parent()
			DoFlaged(Target,i)
		})
	}
	
	//熱門版面
	for(var i = 0 ; i < TagFlagColorI.length ; i++){
		//標籤
		$("#pp div.tft[style*='" + TagFlagColorI[i] + "']").each(function(){
			var Target = $(this).parent().parent().parent();
			DoFlaged(Target,i,1);
		})
		//最愛
		$("#pp div.i[id*='favicon_'][style*='" + TagFlagColorI[i] + "']").each(function(){
			var Target = $(this).parent().parent().parent().parent();
			DoFlaged(Target,i,1);
			DoFaved(Target);
		})
	}
	
	var Child = -1;
	function DoFlaged(Target,i,type){
		//$(Target).prependTo("div.itg:eq(0)");
		if($(Target).attr("Flaged") == "1") return;
		$(Target).css("background-color",TagFlagColor[TagFlagColorI[i]]);
		$(Target).attr("Flaged","1");
		
		if(TagFlagFly !== "0"){
			if(!type){
				$(Target).appendTo("div.itg:eq(0)");
				if($(Target).attr("class").match("gtr"))
					$(Target).appendTo("table.itg:eq(0) > tbody:eq(0)");
			}
			else $(Target).appendTo("#pp");
		}
	}
	
	function DoFaved(Target){
		$(Target).find("div.id3 img")
			.css("opacity","0.6")
			.css("filter","alpha(opacity=60)")
			.css("border-width","2px")
			.css("border-color","#00E3E3")
			.css("border-style","solid")
				
		$(Target).find("div.id2 a")
			.css("color","#00E3E3")
			//.css("color","white")
			
		$(Target)
			.css("border-width","1px")
			.css("border-color","#00E3E3")
			.css("border-style","solid")
			//.css("border-style","dashed")
				
		$(Target).hover(function(){
			$(this).find("div.id3 img")
				.css("opacity","1.0")
				.css("filter","alpha(opacity=100)")
			$(Target).find("div.id2 a")
				.css("color","white")
			//列表模式
			$(Target).find("div.it5 a")
				.css("color","white")
		},function(){
			$(this).find("div.id3 img")
				.css("opacity","0.6")
				.css("filter","alpha(opacity=60)")
			$(Target).find("div.id2 a")
				.css("color","#00E3E3")
			//列表模式
			$(Target).find("div.it5 a")
				.css("color","")
		})
	}
	
	if(TagFlagFly == "1"){
		//標籤
		$("div.itg:eq(0) > div.id1[Flaged!='1']").each(function(){
			$(this).appendTo("div.itg:eq(0)");
		})
		//最愛
		$("table.itg:eq(0) > tbody:eq(0) > tr[class*='gtr'][Flaged!='1']").each(function(){
			$(this).appendTo("table.itg:eq(0) > tbody:eq(0)");
		})
		//熱門版面
		$("#pp > div.id1[Flaged!='1']").each(function(){
			$(this).appendTo("#pp");
		})
	}
	if(TagFlagFly !== "0"){
		$("div.itg:eq(0) div.c").appendTo("div.itg:eq(0)")
		$("#pp div.c").appendTo("div.itg:eq(0)")
		$("div.id1").css("height","335px")
		$("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();
}

//====================================================================================================
function TargetHover(Target){
	$(Target).unbind('mouseenter mouseleave');
	
	$(Target).find("div.id3 img")
		.css("opacity","0.3")
		.css("filter","alpha(opacity=30)")
	$(Target).hover(function(){
		$(this).find("div.id3 img")
			.css("opacity","2.0")
			.css("filter","alpha(opacity=200)")
	},function(){
		$(this).find("div.id3 img")
			.css("opacity","0.3")
			.css("filter","alpha(opacity=30)")
	})
}

GalleryRateAutoTranslucent()
function GalleryRateAutoTranslucent(){ if(GM_getValue("rating_hide","1") == "0") return;
	$("div.id43[class!='id43 ir']").each(function(){
		var Target = $(this).parent().parent();
		if($(Target).attr("Flaged") == "1") $(Target).unbind('mouseenter mouseleave');
		$(Target).attr("Rated","1");
		TargetHover(Target);
	})
}

GalleryClickedTranslucent();
function GalleryClickedTranslucent(){
	//$("div.id1[]").unbind('mouseenter mouseleave');
	//http://stackoverflow.com/questions/9012537/how-to-get-the-element-clicked-for-the-whole-document
	/*
	$(document).click(function(event) {
		var Target = $(event.target)
		if(!$(Target).hasClass("id1")) return;
		if($(Target).attr("Flaged") == "1" || $(Target).attr("Rated") == "1") return;
		TargetHover(Target);
	});
	*/
	$("div.id1").click(function(event) {
		var Target = this;
		//if($(Target).attr("Flaged") == "1" || $(Target).attr("Rated") == "1") return;
		TargetHover(Target);
	});
}

//====================================================================================================
HrefBlank();
function HrefBlank(){
	if(GM_getValue("HrefBlank","0") == "0") return;
	//$("a").each(function(){ $(this).attr("target","_blank"); })
	$("a").attr("target","_blank");
	$("td[onclick='document.location=this.firstChild.href']").attr("onclick","javascript:window.open(this.firstChild.href);");
}
//====================================================================================================
//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);
	})
}

//====================================================================================================
//FavoritesRate();
function FavoritesRate(){ if(!url.match("favorites.php")) return;
	/*
	{
		"method": "rategallery",
		"apiuid": ,
		"apikey": "",
		"rating": 4,
		"gid":944604,
		"token":"908c058d7e"
	}
	*/
	
	
}

//====================================================================================================
//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");
}

//取得網址標記
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];
	}
}