Advertisement
Guest User

Untitled

a guest
Feb 1st, 2015
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.65 KB | None | 0 0
  1. /* Buttons */
  2. var start_trade_class = "TradeCurrencyModalBtn";
  3. var cancel_trade_class = "btn-negative";
  4.  
  5. /* Input */
  6. var limit_order_id = "ctl00_ctl00_cphRoblox_cphMyRobloxContent_ctl00_LimitOrderRadioButton";
  7. var give_currency_id = "ctl00_ctl00_cphRoblox_cphMyRobloxContent_ctl00_HaveCurrencyDropDownList";
  8. var receive_currency_id = "ctl00_ctl00_cphRoblox_cphMyRobloxContent_ctl00_WantCurrencyDropDownList";
  9. var give_box_id = "ctl00_ctl00_cphRoblox_cphMyRobloxContent_ctl00_HaveAmountTextBoxRestyle";
  10. var receive_box_id = "ctl00_ctl00_cphRoblox_cphMyRobloxContent_ctl00_WantAmountTextBox";
  11. var submit_trade_id = "ctl00_ctl00_cphRoblox_cphMyRobloxContent_ctl00_SubmitTradeButton";
  12.  
  13. /* Trade Currency */
  14. function POST(){
  15. $.ajax({
  16. url : "/My/Money.aspx/GetMyItemTrades",
  17. type : "POST",
  18. data : '{"statustype":"inbound","startindex":0}',
  19. contentType : "application/json; charset=UTF-8",
  20. success : function(Data){
  21. var Base = jQuery.parseJSON(jQuery.parseJSON(Data.d).Data[0])
  22. var TradeId = Base["TradeSessionID"]
  23. var Partner = Base["TradePartnerID"]
  24. var Token = ""
  25. $.get("/My/Money.aspx",function(Data){
  26. Token = Data.match(/setToken(\W(.+)\W);/)[2].replace(/'/g,"")
  27. Token = Token.replace("+","%2B").replace("/","%2F")
  28. }).always(function(){
  29. $.post("/Trade/TradeHandler.ashx?token=" + Token,{TradeID : TradeId,cmd : "pull"},function(Data){
  30. var Base = jQuery.parseJSON(Data.data).AgentOfferList
  31. var Other = 1
  32. if (Number(Base[0].AgentID) == Number(Partner)){
  33. Other = 0
  34. }
  35. var OtherVal = Base[Other]["OfferValue"]
  36. var SelfVal = Base[Other == 0 && 1 || 0]["OfferValue"]
  37. var TradeJSON = Data.data
  38. if (OtherVal/3 < SelfVal){
  39. $.post("/Trade/TradeHandler.ashx?token=" + Token,{TradeID : TradeId,TradeJSON:TradeJSON,cmd : "maketrade"})
  40. }
  41. POST()
  42. })
  43. })
  44. }
  45. })
  46. }
  47. POST()
  48.  
  49. /* Info */
  50. var quote_panel_class = "CurrencyQuote";
  51. var my_robux = "RobuxAlertCaption";
  52. var my_tix = "TicketsAlertCaption";
  53.  
  54. /* History */ // Dp not touch these values. Or anything for that matter. Go away
  55. var Previous_Tix_Traded = 0;
  56. var Previous_Robux_Traded = 0;
  57. var Current_Tix_Gained = 0; // "Current" variables are the ones that hold the values of the maximum to trade. They will not trade more money than you have gained.
  58. var Current_Robux_Gained = 0;
  59. var Trading_Robux = 100; // CHANGE NUMBER TO THE NUMBER OF ROBUX YOU CURRENTLY HAVE/ARE WILLING TO USE
  60. var Trading_Tix = 0;
  61. var Previous_Bux_Rate = 0;
  62. var Previous_Tix_Rate = 0;
  63. var Current_Trading = "bux" // We start trading bux first
  64. var InTrade = 0;
  65. var Loading = 0;
  66. var total_profit = 0;
  67. var pending_profit = 0;
  68.  
  69. /* others */
  70. var framedoc;
  71. var tcinterval;
  72. var currenttrading_element;
  73. var expecting_element;
  74. var giving_element;
  75. var totalprofit_element;
  76.  
  77. // Multiply R$ by the right
  78. // Divide TIX by the left
  79. // Round only final value
  80.  
  81. function FetchExternalData(){
  82. var d = "";
  83. $.get("http://www.roblox.com/My/Money.aspx#/#TradeCurrency_tab", function(data){
  84. d = data;
  85. //console.log( $("#" + my_robux, data).text() );
  86. });
  87. return d;
  88. }
  89. /*
  90. function getPos(ele){
  91. var x=0;
  92. var y=0;
  93. while(true){
  94. x += ele.offsetLeft;
  95. y += ele.offsetTop;
  96. if(ele.offsetParent === null){
  97. break;
  98. }
  99. ele = ele.offsetParent;
  100. }
  101. return [x, y];
  102. }
  103. console.log( getPos( document.getElementById("frame1").contentDocument.getElementById("ctl00_ctl00_cphRoblox_cphMyRobloxContent_ctl00_SubmitTradeButton") ))*/
  104.  
  105. function GetBuxRate(Rates){ // What to multiply bux by
  106. var tes = Rates.match(/(.*)\/(.*)/);
  107. return tes[2];
  108. }
  109.  
  110. function GetTixRate(Rates){ // What to divide tix by
  111. var tes = Rates.match(/(.*)\/(.*)/);
  112. return tes[1];
  113. }
  114.  
  115. function GetSpread(){ // Get spread
  116. var Spread = framedoc.getElementsByClassName("column")[0].childNodes[5]
  117. console.log(Spread);
  118. return Spread.innerHTML;
  119. }
  120.  
  121. function Click(String, isClass, d){
  122. if (isClass == true){
  123. $("." + String, d)[0].click();
  124. }else{
  125. $("#" + String, d).click()
  126. }
  127. }
  128.  
  129. function OpenTradeWindow(d){
  130. Click(start_trade_class, true, d);
  131. Click(limit_order_id, false, d);
  132. }
  133.  
  134. function SetTradeTo(currency, d){
  135. if (currency === "tix"){
  136. $("#" + give_currency_id, d).val("Tickets");
  137. $("#" + receive_currency_id, d).val("Robux");
  138. }else if(currency === "bux"){
  139. $("#" + give_currency_id, d).val("Robux");
  140. $("#" + receive_currency_id, d).val("Tickets");
  141. }
  142. }
  143.  
  144. function MakeIFrame(){
  145. var f = document.createElement("iframe");
  146. f.width = window.innerWidth;
  147. f.height = 350
  148. f.style.position = "absolute"
  149. f.style.top = "0px";
  150. f.style.left = "0px";
  151. f.style.zIndex = 100001;
  152. f.setAttribute("src", "http://www.roblox.com/My/Money.aspx#/#TradeCurrency_tab");
  153. f.id = "frame1";
  154. document.body.outerHTML = "";
  155. document.body.appendChild(f);
  156.  
  157. currenttrading_element = document.createElement("span");
  158. currenttrading_element.style.display = "block";
  159. currenttrading_element.style.width = "400px"
  160. currenttrading_element.style.backgroundColor = "rgb(200,200,200)";
  161. currenttrading_element.style.position = "absolute";
  162. currenttrading_element.style.top = "360px";
  163. currenttrading_element.style.left = "10px";
  164. currenttrading_element.style.fontSize = "25px";
  165. currenttrading_element.style.textAlign = "center";
  166. currenttrading_element.style.borderRadius = "5px";
  167. currenttrading_element.innerHTML = "Currently exchanging: R$";
  168. document.body.appendChild(currenttrading_element);
  169.  
  170. giving_element = document.createElement("span");
  171. giving_element.style.display = "block";
  172. giving_element.style.borderRadius = "5px";
  173. giving_element.style.width = "400px"
  174. giving_element.style.backgroundColor = "rgb(200,200,200)";
  175. giving_element.style.position = "absolute";
  176. giving_element.style.top = "400px";
  177. giving_element.style.left = "10px";
  178. giving_element.style.fontSize = "25px";
  179. giving_element.style.textAlign = "center";
  180. document.body.appendChild(giving_element);
  181.  
  182. expected_element = document.createElement("span");
  183. expected_element.style.display = "block";
  184. expected_element.style.borderRadius = "5px";
  185. expected_element.style.width = "400px"
  186. expected_element.style.backgroundColor = "rgb(200,200,200)";
  187. expected_element.style.position = "absolute";
  188. expected_element.style.top = "440px";
  189. expected_element.style.left = "10px";
  190. expected_element.style.fontSize = "25px";
  191. expected_element.style.textAlign = "center";
  192. document.body.appendChild(expected_element);
  193.  
  194. totalprofit_element = document.createElement("span");
  195. totalprofit_element.style.display = "block";
  196. totalprofit_element.style.borderRadius = "5px";
  197. totalprofit_element.style.width = "400px"
  198. totalprofit_element.style.backgroundColor = "rgb(200,200,200)";
  199. totalprofit_element.style.position = "absolute";
  200. totalprofit_element.style.top = "360px";
  201. totalprofit_element.style.right = "10px";
  202. totalprofit_element.style.fontSize = "25px";
  203. totalprofit_element.style.textAlign = "center";
  204. totalprofit_element.innerHTML = "Total Profit: 0 R$";
  205. document.body.appendChild(totalprofit_element);
  206. }
  207.  
  208. function simulatedClick(target, options) {
  209.  
  210. var event = target.ownerDocument.createEvent('MouseEvents'),
  211. options = options || {};
  212.  
  213. //Set your default options to the right of ||
  214. var opts = {
  215. type: options.type || 'click',
  216. canBubble:options.canBubble || true,
  217. cancelable:options.cancelable || true,
  218. view:options.view || target.ownerDocument.defaultView,
  219. detail:options.detail || 1,
  220. screenX:options.screenX || 0, //The coordinates within the entire page
  221. screenY:options.screenY || 0,
  222. clientX:options.clientX || 0, //The coordinates within the viewport
  223. clientY:options.clientY || 0,
  224. ctrlKey:options.ctrlKey || false,
  225. altKey:options.altKey || false,
  226. shiftKey:options.shiftKey || false,
  227. metaKey:options.metaKey || false, //I *think* 'meta' is 'Cmd/Apple' on Mac, and 'Windows key' on Win. Not sure, though!
  228. button:options.button || 0, //0 = left, 1 = middle, 2 = right
  229. relatedTarget:options.relatedTarget || null,
  230. }
  231.  
  232. //Pass in the options
  233. event.initMouseEvent(
  234. opts.type,
  235. opts.canBubble,
  236. opts.cancelable,
  237. opts.view,
  238. opts.detail,
  239. opts.screenX,
  240. opts.screenY,
  241. opts.clientX,
  242. opts.clientY,
  243. opts.ctrlKey,
  244. opts.altKey,
  245. opts.shiftKey,
  246. opts.metaKey,
  247. opts.button,
  248. opts.relatedTarget
  249. );
  250.  
  251. //Fire the event
  252. target.dispatchEvent(event);
  253. }
  254.  
  255. MakeIFrame();
  256. console.log("Giving 5 seconds for page to load.");
  257.  
  258. setTimeout(function(){
  259. tcinterval = setInterval(function(){
  260. $d = $("#frame1").contents()
  261. console.log("===================== NEW TRANSACTION ======================");
  262. if ((InTrade == 0) && (Loading == 0) && ($("." + start_trade_class, $d)[0]) ){
  263. Loading = 1;
  264. $.get("http://www.roblox.com/My/Money.aspx#/#TradeCurrency_tab", function(data){
  265. Loading = 0;
  266. $my_robux = $("#" + my_robux, data).text();
  267. $my_tix = $("#" + my_tix, data).text();
  268. $tix_rate = Number(GetTixRate($("." + quote_panel_class, data)[0].childNodes[3].childNodes[2].innerHTML));
  269. $bux_rate = Number(GetBuxRate($("." + quote_panel_class, data)[0].childNodes[3].childNodes[2].innerHTML));
  270. $spread = Number($(".column", data)[0].childNodes[5].innerHTML);
  271. // check if any offers or bids are pending (bids = tix, offers = bux)
  272. $offers = $('.offer', data).length/2;
  273. $bids = $('.bid', data).length/2;
  274. $offerspending = $offers + $bids
  275. console.log( $offerspending + " offers pending.");
  276. if ( ($offerspending) < 1){
  277. total_profit = (total_profit + pending_profit);
  278. pending_profit = 0;
  279. totalprofit_element.innerHTML = "Total Profit: " + total_profit + " R$";
  280. $expected_bux = Math.round(Trading_Tix/$tix_rate);
  281. $bux_profit = ($expected_bux - Trading_Robux);
  282. $expected_tix = Math.round(Trading_Robux*$bux_rate);
  283. $tix_profit = ($expected_tix - Trading_Tix);
  284. console.log($tix_profit);
  285. if ((Math.abs($spread) < 550) && ($spread < 0) && ($bux_profit > 0) && (Current_Trading === "tix")){
  286. console.log("Profit to be made on TIX to R$: " + $spread + " - Rate: " + $tix_rate);
  287. InTrade = 1;
  288. console.log("Expected to profit " + $bux_profit + " R$ from this trade.");
  289. OpenTradeWindow($d);
  290. //SetTradeTo("tix", $d);
  291. $("#"+give_box_id, $d).val(Trading_Tix);
  292. $("#"+receive_box_id, $d).val($expected_bux);
  293. Trading_Robux = $expected_bux;
  294. Current_Trading = "bux"
  295. currenttrading_element.innerHTML = "Currently exchanging: R$";
  296. giving_element.innerHTML = "Gave: " + Trading_Tix + " TIX";
  297. expected_element.innerHTML = "Expecting: " + $expected_bux + " R$";
  298. pending_profit = $bux_profit;
  299. setTimeout(function(){
  300. simulatedClick( document.getElementById("frame1").contentDocument.getElementById(submit_trade_id) )
  301. //simulatedClick($("#"+submit_trade_id, $d));
  302. //$("#"+submit_trade_id, $d).trigger('click');
  303. InTrade = 0;
  304. }, 1500
  305. );
  306. }else if((Math.abs($spread) < 550) && ($bux_profit < 0) && (Current_Trading === "tix")){
  307. console.log("Will lose profit on TIX to R$. Not trading.");
  308. }else if ((Math.abs($spread) < 550) && ($spread > 0) && ($tix_profit > 20) && (Current_Trading === "bux")){
  309. console.log("Good spread to trade R$ to TIX: " + $spread + " - Rate: " + $bux_rate);
  310. InTrade = 1;
  311. console.log("Expected to profit " + $tix_profit + " TIX from this trade.");
  312. OpenTradeWindow($d);
  313. SetTradeTo("bux", $d);
  314. $("#"+give_box_id, $d).val(Trading_Robux);
  315. $("#"+receive_box_id, $d).val($expected_tix);
  316. Trading_Tix = $expected_tix;
  317. Current_Trading = "tix"
  318. currenttrading_element.innerHTML = "Currently exchanging: TIX";
  319. giving_element.innerHTML = "Gave: " + Trading_Robux + " R$";
  320. expected_element.innerHTML = "Expecting: " + $expected_tix + " TIX";
  321. setTimeout(function(){
  322. simulatedClick( document.getElementById("frame1").contentDocument.getElementById(submit_trade_id) )
  323. //simulatedClick($("#"+submit_trade_id, $d));
  324. //$("#"+submit_trade_id, $d).trigger('click');
  325. InTrade = 0;
  326. }, 1500
  327. );
  328. }else if ((Math.abs($spread) < 550) && ($tix_profit < 20) && (Current_Trading === "bux")){
  329. console.log("Will lose profit on R$ to TIX. Not trading.");
  330. }else{
  331. console.log("Bad spread. Not trading: " + $spread + " - Currently trying to exchange: " + Current_Trading);
  332. }
  333. }else{
  334. console.log("Waiting for current offer to finish...");
  335. }
  336. });
  337. }else{
  338. console.log("Currently in trade or loading page. Waiting...");
  339. }
  340. }, 5000);
  341. }, 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement