// ==UserScript== // @name FR - CR - Easy Attachments // @namespace flamyfox.github.io // @version 2.0 // @description select muti-items with in one CR, and change amounts to what you like // @author flamyfox // @match http://www1.flightrising.com/crossroads/offer/make // @match http://www1.flightrising.com/crossroads/deliver/start // @grant none // ==/UserScript== var item, chkFlag, i=0; //i表示附件的总计数 var iID,iQty,iStack,itemImg; $(document).ready(function() { //creat style sheet $("body").append(""); //add ctrl board var cBoard = "
" + "
" + "item" + " " + " " + " " + " " + "
"; $("body").append(cBoard); //listener $("#bClear").bind("click",function() { clrItem(); }); $("#bHandle").bind("click",function() { creatMask() ; }); $("#bDone").bind("click",function() { reAttch(); atcItemH(i); }); createList(); $(document).on("click",".selectbox>div>img",function() { $(this).parent().remove(); i = i - 1; //console.log(i); }); $("#bSearch").bind("click",function() { quickSearch(); }); }); //attachment img function atcItemH( chkNum ){ for(var k=1; k<=chkNum; k++){ var attDiv = $(".selectbox>div:eq(" + (k-1) + ")"); var target = "#item" + k; $(target).find("input[name=item-id-"+ k +"]").val(attDiv.attr("data-iID")); $(target).find("input[name=item-qty-"+ k +"]").val(attDiv.find("input").val()); $(target).find("input[name=item-stack-"+ k +"]").val(attDiv.attr("data-iStack")); $(target).find(".insert_item img").remove(); $(target).find(".insert_item span").remove(); $(target).find(".insert_item").append("" + attDiv.find("input").val() + ""); } } //Create function createList(){ $(document).on("click",".mask input[type=checkbox]",function() { chkFlag = $(this).is(':checked'); item = $(this).parent().parent(); itemImg = item.find("img").attr("src"); iID = item.find(".intclue").attr("rel").replace("#tooltip-","");// rel="#tooltip-6" iQty = item.find("span").text(); iStack = item.attr("id"); //console.log( itemImg+","+iID +","+ iQty +","+ iStack +","+ i ); var hasItem = $(".selectbox").find("div[data-iStack=" + iStack +"]"); if( chkFlag === true && hasItem.length === 0 ){ i = i + 1; if ( i > 36){ alert("Can't add more than 36 items!"); $(this).prop({checked:false}); i = i - 1; return; } $(".selectbox").append( "
" + "" + "" + "
" ); //console.log(i); } if( chkFlag === false && hasItem.length === 1 ){ hasItem.remove(); i = i - 1; //console.log(i); } }); } //Handle Attach function creatMask(){ var j = 0; $("#itempage").find(".mask").remove(); $("#itempage>span").each(function() { $(this).append(""); j= j + 1; }); } //clear attach function clrItem(){ i=0; $(".selectbox").empty(); reAttch(); } function reAttch(){ for(var j=1; j<=36; j++){ var target = "#item" + j; $(target).find("input[name=item-id-"+ j +"]").val(""); $(target).find("input[name=item-qty-"+ j +"]").val(""); $(target).find("input[name=item-stack-"+ j +"]").val(""); $(target).find(".insert_item img").remove(); $(target).find(".insert_item span").remove(); } } function quickSearch(){ var itemID = $("#itemID").val(); var anchor= $("#itempage img[src$='"+ itemID +".png']").parent().parent(); var position = anchor.position().top + $("#itempage").scrollTop(); $("#itempage").animate({scrollTop: position}); }