// ==UserScript==
// @name E-Hentai 中文功能集
// @namespace Tast
// @version 0.40
// @description E紳士功能中文總集
// @author Tast
// @include *://exhentai.org/*
// @include *://ul.exhentai.org/*
// @include *://*e-hentai.org/*
// @include /\w*:\/\/\d{1,3}(\.\d{1,3}){3}\/archive\/\d*\/\w*/
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_getResourceURL
// @grant UnsafeWindow
// @run-at document-start
// @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
// @require https://greasyfork.org/scripts/20645-dd-icon-menu/code/DD%20Icon%20Menu.js?version=131966
// @require https://greasyfork.org/scripts/20781-thunder-flashget/code/Thunder_FlashGet.js?version=132742
// @resource JQUI https://code.jquery.com/ui/1.12.0-rc.2/themes/smoothness/jquery-ui.css
// @resource iconFN https://greasyfork.org/system/screenshots/screenshots/000/004/495/original/function_%283%29.png?1466097291
// @resource iconmenu http://www.dynamicdrive.com/dynamicindex1/iconmenu.css
// ==/UserScript==
//==============================================變數聲明==============================================
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
// @include *://95.211.212.238/archive/*
//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
//https://developer.chrome.com/devtools/docs/console-api
//====================================================================================================
document.cookie="nw=1; path=/"; //表站內容物不警告
var url = window.location.href;
var EHFN = {};
//====================================================================================================
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;
*/
}
$(document).ready(function() { //console.log( "document loaded" );
MainMenu();
MakeStyle();
ButtomCredit();
TagFlagBKColor();
ThumbLarger();
GalleryClickedTranslucent();
TooltipGallery();
LinkToHentai();
FavoritesRate();
if(url.match('uconfig.php')) uconfig();
if(url.match("hentai.org\/g\/")) GalleryAutoRate();
if(GM_getValue("rating_hide","1") == "1") GalleryRateAutoTranslucent()
if(GM_getValue("HrefBlank","0") == "1") HrefBlank();
if(url.match("home.php")) OverView_Money();
//if(url.match("exchange.php\\?t=hath")) Exchange_Hath();
if(url.match("gallerytorrents.php")) GalleryTorrents();
if(url.match("g.e-hentai.org\/g\/")) GalleryNotAvailable();
if(url.match("\/archive\/")) ArchiveWithLink();
if(url.match("hentai.org\/g\/")) GalleryFastFav();
if(url.match("hentai.org\/mpv\/")) GalleryMPV();
});
//====================================================================================================
//MainMenu for all
//http://www.flaticon.com/search?word=option
function MainMenu(){
$('head').append('<link rel="stylesheet" href="' + GM_getResourceURL("JQUI") + '" type="text/css" />');
$('head').append('<link rel="stylesheet" href="' + GM_getResourceURL("iconmenu") + '" type="text/css" />');
var iconFN = GM_getResourceURL("iconFN");
$("body").append(''
+'<ul id="myiconmenu" class="iconmenu">'
+'<li><a class="icon-list-ul" href="javascript:void()" rel="csslibrary">'
+'<img src="' + iconFN + '" width="16" height="16"></a></li>'
//+'<li><a class="icon-search" href="#" rel="ddcontentarea"></a></li>'
//+'<li><a class="icon-gears" href="#" rel="webtools" title="Web Tools"></a></li>'
//+'<li><a class="icon-rss" href="#" rel="[title]" title="RSS"></a></li>'
//+'<li><a class="icon-twitter" href="#" rel="[title]" title="Twitter"></a></li>'
+'</ul>'
+'<div id="csslibrary" class="iconsubmenu dropdownmenu">'
+'<ul class="ulmenu">'
+'<li><a href="javascript:void()" rel="MyPage">我的首頁</a></li>'
+'<li><a href="javascript:void()" rel="CurFN">頁面功能</a></li>'
+'</ul>'
+'</div>'
+'<div id="MyPage" class="iconsubmenu dropdownmenu">'
+'<ul class="ulmenu" id="MyPages">'
+'<li><a href="http://g.e-hentai.org/home.php" >概觀狀態</a></li>'
+'<li><a href="http://g.e-hentai.org/stats.php" >資訊統計</a></li>'
+'<li><a href="http://g.e-hentai.org/uconfig.php" >個人設定</a></li>'
+'<li><a href="http://g.e-hentai.org/hentaiathome.php" >紳士之家</a></li>'
+'<li><a href="http://g.e-hentai.org/bitcoin.php" >贊助捐款</a></li>'
+'<li><a href="http://g.e-hentai.org/hathperks.php" >特殊功能</a></li>'
+'<li><a href="http://g.e-hentai.org/exchange.php?t=hath" >駭斯市集</a></li>'
+'<li><a href="http://g.e-hentai.org/exchange.php?t=gp" >圖幣市場</a></li>'
+'<li><a href="http://g.e-hentai.org/logs.php?t=credits" >交易記錄</a></li>'
+'</ul>'
+'</div>'
+'<div id="CurFN" class="iconsubmenu dropdownmenu">'
+'<ul class="ulmenu" id="CurFNs">'
//+'<li><a id="SortOF" href="javascript:void()" style="display:none;">原始排序</a></li>'
//+'<li><a id="SortED" href="javascript:void()" style="display:none;">自訂排序</a></li>'
+'</ul>'
+'</div>'
);
DoMenu();
$(".ulmenu a").css("color","darkred");
//$("#myiconmenu").css("left","-12px");
$("#myiconmenu").hover( function(){ $(this).css("left","2px"); },
function(){ $(this).css("left","-12px"); }).css("left","-12px")
}
function DoMenu(){
ddiconmenu.docinit({ // initialize an Icon Menu
menuid:'myiconmenu', //main menu ID
easing:"easeInOutCirc",
dur:500 //<--no comma after last setting
})
}
//====================================================================================================
//MakeStyle Globe
function MakeStyle(){
if($("#searchbox").length) MakeBanner();
if(url.match("hentai.org\/g\/")) $("#gright,#gmid").css("height","auto")
}
function MakeBanner(){
var BannerImage = "http://tast.banner.tw/Javascript/EHentai/Banner/"
+ BannerList[getRandomInt(0,BannerList.length - 1)]
var BannerStyle = "width:100%;height:136px;background:#E3E0D1 "
+ "url(http://ehgt.org/c/graphics/botm_bg.jpg) repeat-x 0px center;"
+ "position:relative;z-index:2;margin:auto;text-align:center;"
//+ "display:none;"
var BannerDIV = "<div id='banner' title='點我顯示搜尋框' style='" + BannerStyle + "'><img src='" + BannerImage + "'></div>"
$(BannerDIV).insertBefore("#searchbox")
$("#searchbox").hide();
$("#banner").click(function(){ //alert("banner")
//$("#banner").hide("1000")
$("#searchbox").stop().toggle("1000")
}).tooltip({track: true})
$("#toppane > h1.ih").hide();
}
//====================================================================================================
//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"
}
var BannerList =
[
"botm.jpg"
,"botm1.jpg"
,"botm2.jpg"
,"botm3.jpg"
,"botm4.jpg"
,"botm5.jpg"
,"botm6.jpg"
,"botm7.jpg"
,"post-1043261-1453065886.png"
,"post-1043261-1459878769.png"
,"post-1205411-1453545585.png"
,"post-1213813-1464223667.png"
,"post-127081-1452881930.png"
,"post-1286649-1463427543.png"
,"post-132672-1453264159.png"
,"post-132672-1453264180.png"
,"post-132672-1457366051.png"
,"post-132672-1460483978.png"
,"post-132672-1465127703.png"
,"post-132672-1465127747.png"
,"post-13641-1452217112.png"
,"post-13641-1457418992.png"
,"post-13641-1463370445.png"
,"post-13641-1465330489.png"
,"post-2106993-1452896765.png"
,"post-2110236-1459837515.png"
,"post-2110236-1462723392.png"
,"post-2110236-1465478995.png"
,"post-2153245-1452325214.png"
,"post-2153245-1458318321.png"
,"post-2153245-1460276859.png"
,"post-2153245-1463409640.png"
,"post-2681250-1463306423.png"
,"post-560909-1465319313.png"
,"post-656086-1452086432.png"
,"post-656086-1457450435.png"
,"post-656086-1459954893.png"
,"post-656086-1462710628.png"
,"post-656086-1465407574.png"
,"post-667843-1452320099.png"
,"post-667843-1459938005.png"
,"post-667843-1462765451.png"
,"post-677653-1461312534.png"
,"post-677653-1462579393.png"
,"post-677653-1466565156.png"
,"post-701737-1453019841.png"
,"post-830109-1453159211.png"
,"post-830109-1457642801.png"
,"post-830109-1461101114.png"
,"post-830109-1462558129.png"
,"post-830109-1465490722.png"
,"post-853041-1461394043.png"
,"post-853041-1461396871.png"
,"post-924439-1463430167.png"
,"post-924439-1465255134.png"
]
function uconfig(){ if(!url.match('uconfig.php')) return;
$( "<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");
//===============================================================
//ThumbLarger
if($("#ThumbLarger").prop("checked"))
GM_setValue("ThumbLarger","1");
else GM_setValue("ThumbLarger","0");
})
uConfigTagFlagBKColor();
uConfigAutoRate();
uConfigRateAutoTranslucent();
uConfigHrefBlank();
uConfigThumb();
}
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(' #' + (i+1) + ":" + Tags)
//.append(' 畫冊標籤旗幟 - ' + (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(' #' + (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)
}
function uConfigThumb(){
$("#uConfigFN").append("<br><br>"
+"<h2>預覽畫質</h2>"
+"<p>改變搜尋項目畫冊預覽圖的畫質(增大一點)"
+'<input type="checkbox" id="ThumbLarger" style="position:relative; top:2px"></p>'
);
if(GM_getValue("ThumbLarger","1") == "1") $("#ThumbLarger").prop("checked",true)
}
//====================================================================================================
function TagFlagBKColor(){ //if(url.match("favorites.php")) return;
if(getQueryString("fly",url) == "0") return;
//設定順序=========================================================
$("div.itg:eq(0) > div.id1 , table.itg:eq(0) > tbody > tr")
.each(function(i){ $(this).attr("SortOF",i); }) //預覽模式 + 列表模式
$("#pp > div.id1")
.each(function(i){ $(this).attr("SortOF",i); }) //熱門板塊
//=========================================================
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("#pp")
$("div.id1").css("height","345px")
$("div.id3").css("height","280px")
//設定順序=========================================================
$("div.itg:eq(0) > div.id1 , table.itg:eq(0) > tbody > tr")
.each(function(i){ $(this).attr("SortED",i); }) //預覽模式 + 列表模式
$("#pp > div.id1")
.each(function(i){ $(this).attr("SortED",i); }) //熱門板塊
$("#CurFNs").append('<li class="SortOF"><a>取消排序</a></li>');
$("#CurFNs").append('<li class="SortED"><a>重新排序</a></li>');
DoMenu();
$("li.SortOF").click(function(){
$(getSorted('div.itg:eq(0) > div.id1' , 'SortOF')).appendTo('div.itg:eq(0)');
$(getSorted('#pp > div.id1' , 'SortOF')).appendTo('#pp');
$("div.itg:eq(0) div.c").appendTo("div.itg:eq(0)")
$("#pp div.c").appendTo("#pp")
})
$("li.SortED").click(function(){
$(getSorted('div.itg:eq(0) > div.id1' , 'SortED')).appendTo('div.itg:eq(0)');
$(getSorted('#pp > div.id1' , 'SortED')).appendTo('#pp');
$("div.itg:eq(0) div.c").appendTo("div.itg:eq(0)")
$("#pp div.c").appendTo("#pp")
});
}
}
//http://blog.troygrosfield.com/2014/04/25/jquery-sorting/
function getSorted(selector, attrName) {
return $($(selector).toArray().sort(function(a, b){
var aVal = parseInt(a.getAttribute(attrName)),
bVal = parseInt(b.getAttribute(attrName));
return aVal - bVal;
}));
}
//====================================================================================================
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;
//unsafeWindow.rating_set(AutoRateNum);
//$("#gdr area:eq(" + (AutoRateNum-1) + ")").click();
var APItarget = $("script:contains('var apikey'):eq(0)");
var APIinfo = $(APItarget).html();
//var base_url = new RegExp("var base_url = (.+);" ,'i') .exec(APIinfo)[1];
var dataIN =
{
"method" :"rategallery"
,"rating" : AutoRateNum
,"apiuid" : new RegExp("var apiuid = (.+);" ,'i') .exec(APIinfo)[1]
,"apikey" : new RegExp('var apikey = "(.+)";' ,'i') .exec(APIinfo)[1]
,"gid" : new RegExp("var gid = (.+);" ,'i') .exec(APIinfo)[1]
,"token" : new RegExp('var token = "(.+)";' ,'i') .exec(APIinfo)[1]
}
//https://sleazyfork.org/zh-TW/scripts/12053-e-hentai-exhentai-japanese-title/code
$.ajax({
url: "/api.php",
type: "POST",
data: JSON.stringify(dataIN),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data){ //console.error(JSON.stringify(data))
//alert( "Data Loaded: " + JSON.stringify(data));
if(data["rating_avg"] == undefined) return;
$("#rating_image").attr("class",data["rating_cls"]);
$("#rating_count").html(data["rating_cnt"]);
$("#rating_label").html("平均:" + data["rating_avg"]);
update_rating_image(AutoRateNum);
}
});
}
//====================================================================================================
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","1.0")
.css("filter","alpha(opacity=100)")
},function(){
$(this).find("div.id3 img")
.css("opacity","0.3")
.css("filter","alpha(opacity=30)")
})
}
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);
})
}
function GalleryClickedTranslucent(){
//$("div.id1[]").unbind('mouseenter mouseleave');
//http://stackoverflow.com/questions/9012537/how-to-get-the-element-clicked-for-the-whole-document
$("div.id1").click(function(event) {
//alert(event.target.innerHTML);
//var Target = this;
TargetHover(this);
});
}
//====================================================================================================
function HrefBlank(){
if(GM_getValue("HrefBlank","0") == "0") return;
//$("a").each(function(){ $(this).attr("target","_blank"); })
$("a:not([blank='none'])").attr("target","_blank");
$("td[onclick='document.location=this.firstChild.href']")
.attr("onclick","javascript:window.open(this.firstChild.href);");
}
//====================================================================================================
function ThumbLarger(){ if(GM_getValue("ThumbLarger","1") == "0") return;
$("div.id3 img").each(function(){
var naturalWidth = $(this).prop("naturalWidth")
var naturalHeight = $(this).prop("naturalHeight")
if(naturalWidth && naturalHeight){
//console.error(naturalWidth + " | " + naturalHeight)
CheckSetThumbWH(this);
}
else $(this).load(function(){ CheckSetThumbWH(this); })
})
$("table.itg div.it2 > img").each(function(){
var b = $(this).parent();
var width = $(b).css("width");
var height = $(b).css("height");
$(this) .attr("src" ,$(this).attr("src").replace("_l.","_250."))
.attr("chk","1")
.css("width" ,width)
.css("height" ,height)
})
unsafeWindow.load_pane_image = function(b){ if (b == undefined) return;
var a = b.innerHTML.split("~", 4);
var width = $(b).css("width");
var height = $(b).css("height");
if (a.length == 4 && a[0] == "init"){
//var width = "50px"
//var height = "50px"
var HTML = '<img src="http://' + a[1] + "/" + a[2] + '" alt="' + a[3] + '" style="margin:0;'
HTML += 'width:' + width + ';height:' + height + ';" chk="1"/>'
b.innerHTML = HTML.replace("_l.","_250.");
}
else {
var img = $(b).find("img:not([chk])");
if(!img.length) return;
$(img) .attr("src" ,$(img).attr("src").replace("_l.","_250."))
.attr("chk","1")
.css("width" ,width)
.css("height" ,height)
//console.error($(img).attr("src"));
}
}
}
function CheckSetThumbWH(Target){
$(Target).unbind('onload load');
var naturalWidth = $(Target).prop("naturalWidth")
var naturalHeight = $(Target).prop("naturalHeight")
$(Target) .css("width" ,naturalWidth)
.css("height" ,naturalHeight)
var src = $(Target).attr("src");
src = src.replace("_l.","_250.");
$(Target).attr("src",src);
var DivHeight = parseInt($(Target).parents("div.id3").css("height").replace("px",""));
$(Target).css("marginTop", (DivHeight - naturalHeight) / 2 + "px")
}
//====================================================================================================
function TooltipGallery(){
//預覽圖模式
$( "div.id1" ).tooltip({
items: "div.id2,div.id3",
content: function () {
var elem = $(this).parents("div.id1");
var TipText = "<div style='text-align: left;'>"
//+ $(elem).find("div.id41").attr("title") + "<br>"
+ $(elem).find("div.id2 > a").html() + "<br>"
$(elem).find("div.tft").each(function(index, element){
var color = $(this).css("background-position");
var tftText = "<p><font color='" + TagFlagColor[color] + "'>" +
$(element).attr("title")
.replace(new RegExp(", ","gmi"),"<br>")
.replace(new RegExp("\n","gmi"),"<br>")
TipText += tftText + "</font></p>"
})
$(elem).find("div.id44 > div > div[id*='favicon_']").each(function(index, element){
var color = $(this).css("background-position");
var Style = $(this).attr("style");
var favText = "<p><div class='i' style='" + Style + " display:inline;'></div>"
+"<font color='" + TagFlagColor[color] + "'>"
+$(this).attr("title")
TipText += favText + "</font></p>"
//console.error(favText)
})
//console.error(TipText)
return TipText + "</div>";
}
});
//列表模式
$( "table.itg" ).tooltip({
items: "div.it5",
content: function () {
var elemLen = 0;
var TipText = "<div style='text-align: left;'>";
$(this).parent().find("div.tfl").each(function(){ elemLen += 1;
var color = $(this).css("background-position");
var tftText = "<p><font color='" + TagFlagColor[color] + "'>" +
$(this).attr("title")
.replace(new RegExp(", ","gmi"),"<br>")
.replace(new RegExp("\n","gmi"),"<br>")
TipText += tftText + "</font></p>"
})
$(this).parent().find("div[id*='favicon_']").each(function(){ elemLen += 1;
var color = $(this).css("background-position");
var Style = $(this).attr("style");
var favText = "<p><div class='i' style='" + Style + " display:inline;'></div>"
+"<font color='" + TagFlagColor[color] + "'>"
+$(this).attr("title")
TipText += favText + "</font></p>"
//console.error(favText)
})
if(!elemLen)
return "";
else return TipText + "</div>";
}
})
}
//====================================================================================================
//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";
}
*/
//====================================================================================================
function LinkToHentai(){
//alert(document.body.innerHTML);
var GoText = "Error";
var GoHref = "Error";
/*
var GoFilter = [
"home.php"
,"stats.php"
,"hentaiathome.php"
,"bitcoin.php"
]
*/
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().attr("blank","none").insertAfter( "#nb a:eq(0)");
$( "#nb a:eq(0)" ).clone().attr("blank","none").html(GoText).attr("href",GoHref).insertAfter( "#nb img:eq(1)");
//if(document.body.title === "") window.location.href = GoHref;
//alert(listCookies());
http://g.e-hentai.org/z/0319/g.css
if(document.title == "" && url.match("exhentai.org")){ document.title = "無目標網頁";
var Banner= "http://tast.banner.tw/Javascript/EHentai/Banner/"
+ BannerList[getRandomInt(0,BannerList.length - 1)]
var style = "width:100%;height:136px;background:#E3E0D1 "
style += "url(http://ehgt.org/c/graphics/botm_bg.jpg) repeat-x 0px center;"
style += "position:relative;z-index:2;margin:auto;text-align:center;"
//$("head").append('<link rel="stylesheet" type="text/css" href="http://g.e-hentai.org/z/0319/g.css" />')
$("body")
.css("background-color","#34353b")
.attr("text","white")
.prepend(''
+"<div id='LinkToHentai' style='text-align:center;'>"
+"<div style='" + style + "'>"
+"<img src='" + Banner + "'>"
+"</div>"
+"<br><br>"
+"<a href='http://g.e-hentai.org/' blank='none'>進入表站首頁</a>"
+"<a> | </a>"
+"<a href='#' onclick='history.back()' blank='none'>回到上一頁</a>"
+"<a> | </a>"
+"<a href='http://exhentai.org/' blank='none'>進入裡站首頁</a>"
+"</div>")
$("#LinkToHentai a").css("color","white");
}
}
function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; }
//====================================================================================================
//E-Hentai Gallery Overview - How Rich Am I?
//https://greasyfork.org/zh-TW/scripts/6565-e-hentai-gallery-overview-how-rich-am-i
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
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);
})
}
//====================================================================================================
//http://www.primebox.co.uk/projects/jquery-cookiebar/
function FavoritesRate(){ if(!url.match("favorites.php")) return;
return;
/*
{
"method": "rategallery",
"apiuid": ,
"apikey": "",
"rating": 4,
"gid":944604,
"token":"908c058d7e"
}
*/
var elem_Sel = $("select.stdinput[name='ddact']:eq(0)");
var optionAttr = 'selected="selected" style="height:17px; padding-left:10px; padding-top:4px"'
$(elem_Sel).parent().parent().css("width","350px");
$(elem_Sel).prepend('<optgroup id="SelGroup" label="其他功能:" style="padding:3px 5px 5px 5px">')
$('<input type="button" id="FN_apply" value="執行" class="stdbtn">').insertAfter(elem_Sel);
$(elem_Sel).find("option[value='delete']").appendTo("#SelGroup")
$("#SelGroup").append('<option value="favIT" ' + optionAttr + '>批次評星</option>')
$("#FN_apply").click(function(){
//if()
})
}
//====================================================================================================
//EH to ExH
//https://greasyfork.org/zh-TW/scripts/19810-eh-to-exh
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");
}
//====================================================================================================
//ArchiveWithLink
//http://tool.chinaz.com/tools/thunder_flashget.aspx
function ArchiveWithLink(){ if(!url.match("\/archive\/")) return;
var href = $("#db a[href*='archive']").attr("href");
href = url.split('\/archive')[0] + href;
var Thunder = EncryptionThunder(href);
var FlashGet = EncryptionFlashGet(href);
var XuanFeng = EncryptionXuanFeng(href);
$("#db").append("<br><a href='" + Thunder + "'><font color='blue'><b>【迅雷網址】</b></font></a>")
$("#db").append(" | <a href='" + FlashGet+ "'><font color='green'><b>【快車網址】</b></font></a>")
$("#db").append(" | <a href='" + XuanFeng+ "'><font color='darkred'><b>【旋風網址】</b></font></a><br><br>")
$("#db").css("background-color","#E3E0D1").css("color","black")
$("#db a").css("color","purple")
}
function EncryptionThunder(href) { //迅雷
return "thunder://" + encode64(strUnicode2Ansi("AA" + href + "ZZ")); }
function EncryptionFlashGet(href) { //快车
return "flashget://" + encode64(strUnicode2Ansi("[FLASHGET]" + href + "[FLASHGET]")) + "&abc"; }
function EncryptionXuanFeng(href) { //旋风
return "qqdl://" + encode64(strUnicode2Ansi(href)); }
//====================================================================================================
//http://stackoverflow.com/questions/754607/can-jquery-get-all-css-styles-associated-with-an-element
function GalleryFastFav(){ if(!url.match("hentai.org\/g\/")) return;
var style = "background-image:url(http://ehgt.org/g/fav.png); color:white; text-align:center; display:inline;"
$("#gdd tbody:eq(0)").append(""
+'<tr id="FastFavTR">'
+'<td style="white-space:nowrap;" class="gdt1" id="FFtd1">快速收藏:</td>'
+'<td id="FastFavDIV" style="display:inline;">'
+'<div id="FFd1" style="display:inline-block;"></div>'
+'<div id="FFd2" style="display:inline-block;"></div>'
+'</td>'
//+'<td><img src="http://ehgt.org/g/e.png"></td>'
+'</tr>')
var ColorBK = Object.keys(TagFlagColor);
for(var i = 6 ; i < ColorBK.length ; i++){ //console.error(i);
var id = i - 6;
if(id <= 4)
var FavDivID = "#FFd1";
else var FavDivID = "#FFd2";
$(FavDivID).append(''
+'<a class="FastFav" id="FFa_' + id + '" style="float:left; cursor:pointer" '
+'onclick="FastFavTo(\'' + id + '\')" ' //+ ">"
+'onmouseout="FastFavOut(\'' + id + '\')" '
+'onmouseover="FastFavOver(\'' + id + '\')">'
+'<div class="i" id="FFd_' + id + '" style="' + style + 'background-position:' + ColorBK[i] + ';">'
+id
+'</div>'
+'</a>')
}
unsafeWindow.FastFavTo = function(id){ addfav(id); }
unsafeWindow.FastFavOver = function(id){
//$("#FFd_" + id).html("<b>+</b>");
var color = TagFlagColor[$("#FFd_" + id).css("background-position")]
$("#FFtd1").css("background-color",color)
}
unsafeWindow.FastFavOut = function(id){
//$("#FFd_" + id).html("");
$("#FFtd1").css("background-color","")
}
}
function addfav(id){
var gid = unsafeWindow.gid;
var token = unsafeWindow.token;
var TarURL = "/gallerypopups.php?act=addfav&gid=" + gid + "&t=" + token;
var IMGsrc = "http://www.erhlin.cch.org.tw/opd/img/loading.gif"
//"http://ehgt.org/g/roller.gif"
//$("#favoritelink").append("<br> <img src='" + IMGsrc + "'>")
$("#favoritelink").css("color","red")
$.ajax({
url: TarURL, type: "POST",
data: { favcat:id, update:"1" },
success: function(data){ //console.error(JSON.stringify(data))
var background_position = new RegExp("fi\\.style\\.backgroundPosition='(.+x)';" ,'mi').exec(data)[1];
var divTitle = new RegExp("fi\\.title='(.+)'\\;" ,'mi').exec(data)[1];
$("#favoritelink").html(divTitle).css("color","")
//console.error(divTitle + " - " + background_position);
if(!$("#fav").find("div.i").length){
$("#fav").append('<div class="i" style="background-image:url(http://ehgt.org/g/fav.png); margin-left:16px"></div>')
}
$("#fav").find("div.i")
.css("background-position",background_position)
.attr("title",divTitle)
}
});
}
//====================================================================================================
//GalleryMPV
//https://www.sitepoint.com/javascript-custom-events/
function GalleryMPV(){ if(!url.match("hentai.org\/mpv\/")) return;
//Auto Reload Failed Image
document.addEventListener("load_image", newMessageHandler, false);
function newMessageHandler(e) { //console.error(JSON.stringify(e.detail.b))
var b = e.detail.b
var ImageElem = $("#imgsrc_" + b)
$(ImageElem).error(function() {
console.error("Image fail(" + b + "):" + $(this).attr("src"))
setTimeout(function(){ unsafeWindow.action_reload(b); }, 2000);
});
//.load(function(){ console.error("Load:" + $(this).attr("src")); })
}
unsafeWindow.load_image = load_image2
//Ajust From HashTag
var hash = location.hash;
if(hash.length >= 2) document.location = hash
}
function load_image2(b) {
//console.log(b)
if (imagelist[b - 1].i != undefined) {
var c = '<a href="#page' + (b + 1) + '"><img id="imgsrc_' + b + '" src="' + imagelist[b - 1].i + '" title="' + imagelist[b - 1].n + '" style="margin:0; width:' + imagelist[b - 1].xres + "px; height:" + imagelist[b - 1].yres + 'px" /></a> <div class="mi1"> <div class="mi2"> ' + (imagelist[b - 1].o == "org" ? '<img style="cursor:default" title="Original Image" src="' + img_url + 'mpvd_d.png" />': '<img title="' + imagelist[b - 1].o + '" onclick="action_fullimg(' + b + ')" src="' + img_url + 'mpvd.png" />') + ' <img title="Reload broken image" onclick="action_reload(' + b + ')" src="' + img_url + 'mpvr.png" /> </div> <div class="mi3"> <a href="' + base_url + imagelist[b - 1].lo + '" target="_ehshow_' + gid + "_" + b + '"><img title="Open image in normal viewer" onclick="action_open(' + b + ')" src="' + img_url + 'mpvn.png" /></a> <img title="Show galleries with this image" onclick="action_search(' + b + ')" src="' + img_url + 'mpvs.png" /> <img title="Get forum link to image" onclick="action_link(' + b + ')" src="' + img_url + 'mpvl.png" /> </div> <div class="mi4">' + imagelist[b - 1].d + " :: " + imagelist[b - 1].n + '</div> <div style="clear:both"></div> </div>';
document.getElementById("image_" + b).innerHTML = c;
rescale_image(b, document.getElementById("imgsrc_" + b))
//Here is start
var event = new CustomEvent( "load_image", { bubbles: true, cancelable: true,
detail: { "b":b }}
);
document.dispatchEvent(event);
//and Stop
} else {
if (imagelist[b - 1].xhr != undefined) {
return
}
imagelist[b - 1].xhr = new XMLHttpRequest();
var a = {
method: "imagedispatch",
gid: gid,
page: b,
imgkey: imagelist[b - 1].k,
mpvkey: mpvkey
};
api_call(imagelist[b - 1].xhr, a,
function() {
load_image_dispatch(b)
})
}
}
//====================================================================================================
//Last
function ButtomCredit(){
var iconFN = GM_getResourceURL("iconFN");
$("body").append(
"<div id='CreditText' align='center' style='display:none;'><br><br>"
+"<a href='https://goo.gl/4L9grY'>E-Hentai 中文功能集 By Tast</a><br><br>"
+'<div>Icons made by <a href="http://www.flaticon.com/authors/vaadin" title="Vaadin">Vaadin</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>'
+"</div><br>"
+"<div align='center'><div id='Credit' style='display:inline;'>"
+"<img src='" + iconFN + "' width='32' height='32'><br><br>"
+"</div></div>");
$("#Credit").click(function(){ $( "#CreditText" ).toggle( "blind", 500 ); })
if(url.match("exhentai.org")) $("#CreditText a").css("color","white")
}
//取得網址標記
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];
}
}