// ==UserScript==
// @name FR - AH - Buy Dragon Hits
// @namespace https://github.com/flamyfox/FrFun
// @version 0.1
// @description 1. Show Dragon Color label on AH page 2.Check blood for 2 dragons
// @author flamyfox
// @match http://www1.flightrising.com/auction-house/buy/realm/dragons*
// @grant GM_xmlhttpRequest
// ==/UserScript==
$(document).ready(function() {
$("head").append("");
//add ctrl board
var cBoard = "
"
+ " "
+ "
";
$("body").append(cBoard);
$("body").append("");
$("#myD").val(sessionStorage.getItem('myDID'));
$(".board input[type=checkbox]").on("click",function(){
$(".selD").prop({checked:false});
$("#bloodmsg").empty();
i=0;
});
showColor();
goCheck();
});
function showColor(){
$("#ah-content>.ah-listing-row").each(function() {
//µ±Ç°ÐУ¨loop£©
var thisLine = $(this);
var dID = thisLine.attr("data-listing-dragonid");
var thisColor = $("#dragontip-" + dID).find(" div[style='color:#000; font-size:10px; margin-top:3px;']");
var colorP = thisColor.find("div:eq(3)").text().split(" ");
var colorS = thisColor.find("div:eq(4)").text().split(" ");
var colorT = thisColor.find("div:eq(5)").text().split(" ");
//console.log(thisColor[2]);
thisLine.append(""
+"" + colorP[2] + ""
+"" + colorS[2] + ""
+"" + colorT[2] + ""
+"
");
thisLine.append("");
});
}
var i=0, twoDragon = new Array();
function goCheck(){
$(document).on("click","#ah-content>.ah-listing-row .selD",function() {
var chkFlag = $(this).is(':checked');
var chkMyFlag = $(".board input[type=checkbox]").is(':checked');
var dID = $(this).val();
var myID =$("#myD").val();
console.log(chkMyFlag,chkFlag,i);
sessionStorage.setItem('myDID',myID);
if(chkMyFlag===true){
$("#bloodmsg").empty();
$(".selD").prop({checked:false});
if( chkFlag === true){
$(this).prop({checked:true});
bloodCheck(myID,dID);
}
if( chkFlag === false){
$("#bloodmsg").empty();
}
}
if(chkMyFlag===false){
if( chkFlag === true){
if ( i > 1){
alert("only 2 dragons");
$(this).prop({checked:false});
return;
}else{
twoDragon.push(dID);
if(i==1){
bloodCheck(twoDragon[0],twoDragon[1]);
}
i = i + 1;
}
}
if( chkFlag === false){
twoDragon.remove(dID);
$("#bloodmsg").empty();
i = i - 1;
}
}
});
}
Array.prototype.indexOf = function(val) {
for (var j = 0; j < this.length; j++) {
if (this[j] == val) return j;
}
return -1;
};
Array.prototype.remove = function(val) {
var index = this.indexOf(val);
if (index > -1) {
this.splice(index, 1);
}
};
function bloodCheck(d1,d2){
var url = "http://flightrising.com/includes/ol/scryer_bloodlines.php?id1=" + d1 + "&id2=" + d2;
// + " div[style='width:250px; margin-left:15px; margin-right:15px; margin-top:20px; text-align:center;']";
GM_xmlhttpRequest({
method: "GET",
url:url,
onload: function(response) {
if (response.status == 200) {
$("#bloodmsg").append(response.responseText);
}
}
});
}