// ==UserScript== // @name FR - Mailbox - Easy Attachments // @namespace flamyfox.github.io // @version 0.2 // @description Auto mail attachment and attachment select // @author flamyfox // @match http://www1.flightrising.com/msgs/new // @grant none // ==/UserScript== var iID = new Array(16); var iQty = new Array(16); var iStack = new Array(16); var itemImg = new Array(16); $(document).ready(function() { //creat style sheet $("body").append(""); //add ctrl board var cBoard = "
" + " | " + " " + "" + "
"; $("body").append(cBoard); //listener //auto $("#bAuto").bind("click",function() { $("#itempage").find(".mask").remove(); clrItem(); getItemA(); }); //handel $("#bHandle").bind("click",function() { clrItem(); creatMask() ; }); $("#bDone").bind("click",function() { getChkItem(); }); }); //Auto Attach function getItemA(){ var i=0 , item; $("#itempage .item-attachment").each(function() { item = $(this); itemImg[i] = item.find("img").attr("src"); iID[i] = item.find(".intclue").attr("rel").replace("#tooltip-","");// rel="#tooltip-6" iQty[i] = item.find("span").text(); iStack[i] = item.attr("id"); //console.log( iID[i] +","+ iQty[i] +","+ iStack[i] +","+ i ); i = i + 1; if ( i > 15 ){ return false; } }); atcItemH(i); } //Handle Attach function creatMask(){ var i=0; $("#itempage").find(".mask").remove(); $("#itempage>span").each(function() { $(this).append(""); i= i+ 1; }); } function getChkItem(){ var i=0, item, chkFlag; $("#itempage>span").each(function(){ item = $(this); chkFlag = item.find("input[type=checkbox]").is(':checked'); if( chkFlag === true ){ itemImg[i] = item.find("img").attr("src"); iID[i] = item.find(".intclue").attr("rel").replace("#tooltip-","");// rel="#tooltip-6" iQty[i] = item.find("span").text(); iStack[i] = item.attr("id"); console.log( iID[i] +","+ iQty[i] +","+ iStack[i] +","+ i ); i = i + 1; } }); //console.log(i);//16 if( i < 17 ){ atcItemH(i);} else if ( i > 16){ alert("Can't add more than 16 items!"); } } //attachment img function atcItemH( chkNum ){ for(var i=1; i<=chkNum; i++){ var target = "#item" + i; $(target).find("input[name=item-id-"+ i +"]").val(iID[i-1]); $(target).find("input[name=item-qty-"+ i +"]").val(iQty[i-1]); $(target).find("input[name=item-stack-"+ i +"]").val(iStack[i-1]); $(target).find(".insert_item img").remove(); $(target).find(".insert_item span").remove(); $(target).find(".insert_item").append("" + iQty[i-1] + ""); } } //clear attach function clrItem(){ for(var i=1; i<=16; i++){ var target = "#item" + i; $(target).find("input[name=item-id-"+ i +"]").val(""); $(target).find("input[name=item-qty-"+ i +"]").val(""); $(target).find("input[name=item-stack-"+ i +"]").val(""); $(target).find(".insert_item img").remove(); $(target).find(".insert_item span").remove(); } }