FlightRising GUI Improvements

Improves the interface for Flight Rising.

  1. // Generated by CoffeeScript 1.10.0
  2.  
  3. /* UserScript options {{{1
  4. // ==UserScript==
  5. // @name FlightRising GUI Improvements
  6. // @description Improves the interface for Flight Rising.
  7. // @namespace ahto
  8. // @version 1.24.0
  9. // @include http://*flightrising.com/*
  10. // @require https://greasyfork.org/scripts/10922-ahto-library/code/Ahto%20Library.js?version=75750
  11. // @grant none
  12. // ==/UserScript==
  13. */
  14.  
  15. /* Features and changes {{{1
  16. General:
  17. - Adds two new links to Baldwin's Bubbling Brew.
  18. - Removes redundant links to messages and gems.
  19. - Adds commas to various numbers around the site.
  20. - Automatically bonds with familiars.
  21.  
  22. Auction House:
  23. - Clicking the icons next to price ranges will let you sort by only treasure or only gems.
  24. - Tells you how much items cost per unit.
  25. - Adds a clear item name button.
  26. - Clicking an item's name sets that to the name filter.
  27.  
  28. Baldwin's Bubbling Brew:
  29. - Replaces useless dialog text with a handy guide.
  30. - Flashes title when your brew is ready. (Leave BBB running in a background tab)
  31.  
  32. Higher or Lower game:
  33. - Automatically clicks 'play again'.
  34. - Added keyboard shortcuts for each of the guesses.
  35.  
  36. Mail:
  37. - Auto-collects attachments.
  38. - Selecting a message for deletion highlights the whole thing.
  39. */
  40. var AH_BUTTON_SPACING, AH_DEFAULT_CURRENCY, AH_UPDATE_DELAY, AuctionListing, AuctionSearch, BBB_BLINK_TIMEOUT, BBB_GUIDE, CurrencyFields, CurrencyFilterer, FormData, GEMS, HUMAN_TIMEOUT_MAX, HUMAN_TIMEOUT_MIN, LOADING_WAIT, TD_ATTR, TREASURE, autoCollectAll, blinker, bondButton, browseAllBackup, bubble, button, buttonHi, buttonLo, buttonTitle, currentTreasure, filterer, form, getItemDetails, getItemTooltip, getTab, guesses, info, instruct, itemNameText, j, len, newHTML, playAgain, price, ref, sell, setHumanTimeout, treasureIndicator, updateButton, updateListings,
  41. slice = [].slice;
  42.  
  43. TREASURE = 0;
  44.  
  45. GEMS = 1;
  46.  
  47. TD_ATTR = 'style="font-size:12px;"';
  48.  
  49. BBB_GUIDE = "<table>\n <tr>\n <th " + TD_ATTR + "><b>Muck (Familiars)</b></th>\n <th " + TD_ATTR + "><b>Slime (Apparel)</b></th>\n <th " + TD_ATTR + "><b>Misc</b></th>\n </tr>\n <tr>\n <td " + TD_ATTR + ">Copper 50%</td>\n <td " + TD_ATTR + ">Grey 70%(?)</td>\n <td " + TD_ATTR + ">Green 45%</td>\n </tr>\n <tr>\n <td " + TD_ATTR + ">Silver 30%</td>\n <td " + TD_ATTR + ">White 20%(?)</td>\n <td " + TD_ATTR + ">Yellow 20%</td>\n </tr>\n <tr>\n <td " + TD_ATTR + ">Gold 20%</td>\n <td " + TD_ATTR + ">Black 10%(?)</td>\n <td " + TD_ATTR + ">Orange 15%</td>\n </tr>\n <tr> <td/> <td/> <td " + TD_ATTR + ">Red 10%</td> </tr>\n <tr> <td/> <td/> <td " + TD_ATTR + ">Purple 8%</td> </tr>\n <tr> <td/> <td/> <td " + TD_ATTR + ">Blue 2%</td> </tr>\n</table>\n<b>\n <br>\n Misc:<br>\n Ooze (Material), Sludge (Trinkets), Goo (Food)\n</b>";
  50.  
  51. AH_BUTTON_SPACING = '140px';
  52.  
  53. AH_UPDATE_DELAY = 2000;
  54.  
  55. AH_DEFAULT_CURRENCY = void 0;
  56.  
  57. HUMAN_TIMEOUT_MIN = 300;
  58.  
  59. HUMAN_TIMEOUT_MAX = 1000;
  60.  
  61. BBB_BLINK_TIMEOUT = 500;
  62.  
  63. LOADING_WAIT = 1000;
  64.  
  65. setHumanTimeout = function(f, extraTime) {
  66. var wait_time;
  67. if (extraTime == null) {
  68. extraTime = 0;
  69. }
  70. wait_time = randInt(HUMAN_TIMEOUT_MIN + extraTime, HUMAN_TIMEOUT_MAX + extraTime);
  71. return setTimeout_(wait_time, f);
  72. };
  73.  
  74. getItemTooltip = function(id, tab, callback) {
  75. return $.get('/includes/itemajax.php', {
  76. id: id,
  77. food: food
  78. }).done(callback);
  79. };
  80.  
  81. getItemDetails = function(id, tab, callback) {
  82. return getItemTooltip(id, tab, function(results) {
  83. var foodPointStyle, info, nameStyle, r, sellValueStyle;
  84. results = $(results);
  85. nameStyle = "color:#731d08; font-weight:bold; font-size:11px;";
  86. foodPointStyle = "color:#000; font-size:10px; position:absolute; bottom:5px; right:5px; font-weight:bold;";
  87. sellValueStyle = "color:#000; font-size:10px; position:absolute; bottom:5px; font-weight:bold;";
  88. info = {
  89. name: results.find("div[style='" + nameStyle + "']").text(),
  90. sellValue: results.find("div[style='" + sellValueStyle + "']").text(),
  91. foodPoints: (r = results.find("div[style='" + foodPointStyle + "']")).length ? r.text() : void 0
  92. };
  93. return callback(info);
  94. });
  95. };
  96.  
  97. FormData = (function() {
  98. function FormData(form1) {
  99. this.form = form1;
  100. }
  101.  
  102. FormData.prototype.field = function(name, newValue) {
  103. var field;
  104. field = this.form.find("[name=" + name + "]");
  105. if (newValue) {
  106. return field.val(newValue);
  107. } else {
  108. return field.val();
  109. }
  110. };
  111.  
  112. return FormData;
  113.  
  114. })();
  115.  
  116. AuctionSearch = (function() {
  117. AuctionSearch.prototype.GET_NUMBER = /[0-9]+/;
  118.  
  119. function AuctionSearch(postData1) {
  120. var ref, ref1, ref2;
  121. this.postData = postData1;
  122.  
  123. /*
  124. * cat means category, tl means treasure low, gh means gems high. tab,
  125. * page (but this is auto-sent), cat, tl, th, gl, gh, name, ordering,
  126. * direct. Ordering can be 'expiration' or 'cost'. All values are
  127. * strings. direct (direction) can be 'ASC' or 'DESC'. Valid categories
  128. * are 'mats', 'app', 'dragons', 'fam', 'battle', 'skins', and 'other'.
  129. */
  130. this.sales = [];
  131. if (((ref = this.postData.direct) !== 'ASC' && ref !== 'DESC') || ((ref1 = this.postData.ordering) !== 'expiration' && ref1 !== 'cost') || ((ref2 = this.postData.cat) !== 'mats' && ref2 !== 'app' && ref2 !== 'dragons' && ref2 !== 'fam' && ref2 !== 'battle' && ref2 !== 'skins' && ref2 !== 'other')) {
  132. throw new Error('Invalid postData.');
  133. }
  134. $.post("includes/ah_buy_" + tab + ".php", this.postData).done((function(_this) {
  135. return function(response) {
  136. var pageHolderStyle, pages;
  137. response = $(response);
  138. pageHolderStyle = "font-size:12px; text-align:center; position:absolute; bottom:5px; height:27px; width:480px;";
  139. pages = parseInt(response.find("div[style='" + pageHolderStyle + "'] a[style='cursor:pointer;']:last").text());
  140. return _this.addResponse(response);
  141. };
  142. })(this));
  143. }
  144.  
  145. AuctionSearch.prototype.addResponse = function(response1) {
  146. var getNumber, j, len, results1, sale, saleInfo, sales;
  147. this.response = response1;
  148. console.log('setResponse called on', this.response);
  149. getNumber = function(string) {
  150. return parseInt(GET_NUMBER.exec(string)[0]);
  151. };
  152. sales = $('div[id^=sale]');
  153. results1 = [];
  154. for (j = 0, len = sales.length; j < len; j++) {
  155. sale = sales[j];
  156. saleInfo = {
  157. saleID: getNumber(sale.attr('id')),
  158. itemID: getNumber(sale.find('img[src^="/images/cms/trinket/"').attr('src')),
  159. quantity: parseInt(sale.find('span[style="position:absolute; bottom:0px; left:0px; background-color:#FFF; color:#731d08; font-size:11px; font-weight:bold; padding-right:2px; width:15px; height:10px; text-align:right;"]').text()),
  160. expiration: getNumber(sale.find('span[time]').attr('time')),
  161. price: getNumber(sale.find('div[id^=buy_button]').text()),
  162. currency: sale.find('img[src$=icon_gems.png]').length ? GEMS : sale.find('img[src$=icon_treasure.png]').length ? TREASURE : void 0
  163. };
  164. saleInfo.priceEA = saleInfo.price / saleInfo.quantity;
  165. sales.push(saleInfo);
  166. console.log(sale);
  167. results1.push(console.log(saleInfo));
  168. }
  169. return results1;
  170. };
  171.  
  172. return AuctionSearch;
  173.  
  174. })();
  175.  
  176. findMatches('a.navbar[href=\'main.php?p=pm\'],\na.navbar[href*=\'msgs\'],\na.navbar[href=\'main.php?p=ge\'],\na.navbar[href*=\'buy-gems\']', 2, 2).remove();
  177.  
  178. findMatches("a.navbar[href*=crossroads]").after('<a class=\'navbar navbar-glow-hover\' href=\'http://www1.flightrising.com/trading/baldwin/transmute\'>\n Alchemy (Transmute)\n</a>\n<a class=\'navbar navbar-glow-hover\' href=\'http://www1.flightrising.com/trading/baldwin/create\'>\n Alchemy (Create)\n</a>');
  179.  
  180. if (/www1/.test(window.location.href)) {
  181. treasureIndicator = findMatches('a.loginbar.loginlinks[title*=treasure]', 1, 1);
  182. currentTreasure = numberWithCommas(safeParseInt(treasureIndicator.text()));
  183. newHTML = treasureIndicator.html().replace(/\d+/, currentTreasure);
  184. treasureIndicator.html(newHTML);
  185. } else {
  186. treasureIndicator = findMatches('span#user_treasure', 1, 1);
  187. currentTreasure = numberWithCommas(safeParseInt(treasureIndicator.text()));
  188. treasureIndicator.text(currentTreasure);
  189. }
  190.  
  191. if (urlMatches(new RegExp('http://www1\.flightrising\.com/trading/baldwin.*', 'i'))) {
  192. if (findMatches("input[value='Collect!']", 0, 1).length) {
  193. blinker = setInterval((function() {
  194. if (document.title === 'Ready!') {
  195. return document.title = '!!!!!!!!!!!!!!!!';
  196. } else {
  197. return document.title = 'Ready!';
  198. }
  199. }), BBB_BLINK_TIMEOUT);
  200. window.onfocus = function() {
  201. clearInterval(blinker);
  202. return document.title = 'Ready!';
  203. };
  204. }
  205. if (urlMatches(new RegExp('/baldwin/create', 'i'))) {
  206. bubble = findMatches('.baldwin-create-speech-bubble', 1, 1);
  207. instruct = findMatches('.baldwin-create-instruct', 1, 1);
  208. bubble.css('padding', '5px').css('right', 'inherit');
  209. instruct.css('background', 'inherit');
  210. bubble.html(BBB_GUIDE);
  211. }
  212. if (urlMatches(new RegExp('/baldwin/transmute', 'i'))) {
  213. info = findMatches('.baldwin-cauldron-status', 0, 1);
  214. if (info.length) {
  215. bubble = findMatches('#speech-bubble-content', 1, 1);
  216. bubble.contents().remove();
  217. bubble.html(BBB_GUIDE);
  218. bubble.append(info);
  219. }
  220. }
  221. }
  222.  
  223. if (urlMatches(new RegExp('http://flightrising\.com/main\.php.*p=market', 'i'))) {
  224. ref = findMatches('#market > div > div:nth-child(3) > div:nth-child(4)', 1);
  225. for (j = 0, len = ref.length; j < len; j++) {
  226. price = ref[j];
  227. price = $(price);
  228. price.text(numberWithCommas(safeParseInt(price.text())));
  229. }
  230. }
  231.  
  232. if (urlMatches(new RegExp("http://flightrising\.com/main\.php.*p=hilo", 'i'))) {
  233. guesses = parseInt(findMatches('#super-container > div:nth-child(2) > div:nth-child(4) > div:nth-child(2)', 1, 1).text());
  234. if (guesses > 0) {
  235. playAgain = findMatches('.mb_button[value="Play Again"]', 0, 1);
  236. if (playAgain.length) {
  237. setHumanTimeout(function() {
  238. return playAgain.click();
  239. });
  240. } else {
  241. findMatches('#super-container > div:nth-child(3) > div:nth-child(3)', 1, 1).html('Press <b>j (lower)</b> or <b>k (higher)</b>, or use the buttons on the left.<br>\nIf you guess correctly, you\'ll win 65 treasure (as of 2015.09.10).');
  242. buttonLo = findMatches('map[name=hilo_map] > area[href*="choice=lo"]', 1, 1);
  243. buttonHi = findMatches('map[name=hilo_map] > area[href*="choice=hi"]', 1, 1);
  244. $(document).keypress(function(e) {
  245. switch (String.fromCharCode(e.charCode).toLowerCase()) {
  246. case 'j':
  247. return buttonLo.click();
  248. case 'k':
  249. return buttonHi.click();
  250. default:
  251. return console.log("Got unrechognized charCode: " + e.charCode);
  252. }
  253. });
  254. }
  255. }
  256. }
  257.  
  258. if (urlMatches(new RegExp("http://flightrising\.com/main\.php.*p=lair", 'i'))) {
  259. if ((bondButton = findMatches('img[src*="button_bond.png"]', 0, 1)).length) {
  260. setHumanTimeout(function() {
  261. bondButton.click();
  262. return setHumanTimeout(function() {
  263. return findMatches('button#no', 1, 1).click();
  264. });
  265. });
  266. } else if (findMatches('img[src*="button_bond_inactive.png"]', 0, 1).length) {
  267. if ($('img[src*="bar_bond_max.png"]').length) {
  268. document.title = 'Awakened!';
  269. } else {
  270. document.title = 'Bonded!';
  271. }
  272. }
  273. }
  274.  
  275. if (urlMatches(new RegExp('http://flightrising\.com/main\.php.*p=ah', 'i'))) {
  276. if (findMatches('input[value=Search]', 0, 1).length) {
  277. AuctionListing = (function() {
  278. function AuctionListing(element) {
  279. this.element = element;
  280. this.numberOfItems = safeParseInt(this.element.find('div:nth-child(1) > span:nth-child(1) > span').text());
  281. this.button = this.element.find('[id*=buy_button]');
  282. this.price = safeParseInt(this.button.text());
  283. this.priceEA = this.price / this.numberOfItems;
  284. this.nameElement = this.element.find('div:nth-child(1) > span:nth-child(2) > span:nth-child(1)');
  285. this.name = this.nameElement.text();
  286. }
  287.  
  288. AuctionListing.prototype.modifyElement = function() {
  289. var priceEAString, priceString, target;
  290. target = this.button[0].childNodes[2];
  291. if (target == null) {
  292. console.warn("Tried to modifyElement() for " + this.name + " @ " + this.price + " but the auction expired(?).");
  293. return;
  294. }
  295. if (!safeParseInt(target.textContent) === this.price) {
  296. throw new Error("Tried to modify an auction house item but the price didn't match expectations.");
  297. }
  298. priceString = numberWithCommas(this.price);
  299. priceEAString = numberWithCommas(Math.round(this.priceEA));
  300. if (this.numberOfItems > 1) {
  301. target.textContent = " " + priceString + " (" + priceEAString + " ea)";
  302. } else {
  303. target.textContent = " " + priceString;
  304. }
  305. this.button.css('width', AH_BUTTON_SPACING);
  306. return this.nameElement.html("<a href='javascript:$(\"input[name=name]\").val(\"" + this.name + "\")'>" + this.name + "</a>");
  307. };
  308.  
  309. return AuctionListing;
  310.  
  311. })();
  312. getTab = function() {
  313. var ref1, tab;
  314. if ((tab = /[?&]tab=([^&]+)/.exec(window.location.href)) != null) {
  315. tab = tab[1];
  316. } else {
  317. tab = 'food';
  318. }
  319. if ((ref1 = !tab) === 'food' || ref1 === 'mats' || ref1 === 'app' || ref1 === 'dragons' || ref1 === 'fam' || ref1 === 'battle' || ref1 === 'skins' || ref1 === 'other') {
  320. throw new Error("Detected tab as invalid option " + (postData.tab.toString()) + ".");
  321. }
  322. return tab;
  323. };
  324. CurrencyFields = (function() {
  325. function CurrencyFields(img, low, high) {
  326. this.img = img;
  327. this.low = low;
  328. this.high = high;
  329. }
  330.  
  331. CurrencyFields.prototype.notEmpty = function() {
  332. var val;
  333. val = this.low.val().length || this.high.val().length;
  334. return val;
  335. };
  336.  
  337. return CurrencyFields;
  338.  
  339. })();
  340. CurrencyFilterer = (function() {
  341. CurrencyFilterer.prototype.LOW = '0';
  342.  
  343. CurrencyFilterer.prototype.HIGH = '999999999999999999';
  344.  
  345. function CurrencyFilterer(searchButton, treasureFields, gemFields) {
  346. this.searchButton = searchButton;
  347. this.treasureFields = treasureFields;
  348. this.gemFields = gemFields;
  349. this.treasureListener = this.makeListener(this.treasureFields, this.gemFields);
  350. this.gemListener = this.makeListener(this.gemFields, this.treasureFields);
  351. }
  352.  
  353. CurrencyFilterer.prototype.makeListener = function(us, them) {
  354. return (function(_this) {
  355. return function(event) {
  356. if (us.notEmpty()) {
  357. us.low.val('');
  358. us.high.val('');
  359. } else {
  360. us.low.val(_this.LOW);
  361. us.high.val(_this.HIGH);
  362. }
  363. them.low.val('');
  364. return them.high.val('');
  365. };
  366. })(this);
  367. };
  368.  
  369. CurrencyFilterer.prototype.init = function() {
  370. this.treasureFields.img.click(this.treasureListener);
  371. this.gemFields.img.click(this.gemListener);
  372. this.treasureFields.img.css('cursor', 'pointer');
  373. this.gemFields.img.css('cursor', 'pointer');
  374. if (AH_DEFAULT_CURRENCY != null) {
  375. return filterer.showOnly(AH_DEFAULT_CURRENCY);
  376. }
  377. };
  378.  
  379. CurrencyFilterer.prototype.showOnly = function(currency) {
  380. switch (currency) {
  381. case TREASURE:
  382. this.treasureListener();
  383. break;
  384. case GEMS:
  385. this.gemListener();
  386. break;
  387. default:
  388. throw new Error("CurrencyFilterer.showOnly called with invalid currency: " + currency);
  389. }
  390. return this.searchButton.click();
  391. };
  392.  
  393. return CurrencyFilterer;
  394.  
  395. })();
  396. filterer = new CurrencyFilterer(findMatches('input[value=Search]', 1, 1).click(), new CurrencyFields(findMatches('#searching img[src="/images/layout/icon_treasure.png"]', 1, 1), findMatches('input[name=tl]', 1, 1), findMatches('input[name=th]', 1, 1)), new CurrencyFields(findMatches('#searching img[src="/images/layout/icon_gems.png"]', 1, 1), findMatches('input[name=gl]', 1, 1), findMatches('input[name=gh]', 1, 1)));
  397. filterer.init();
  398. if (getTab() !== 'dragons') {
  399. itemNameText = $('#searching > div:nth-child(1)');
  400. itemNameText.html(itemNameText.html() + '<a href=\'javascript:$("input[name=name").val("")\'>\n &nbsp;(clear)\n</a>');
  401. updateListings = function() {
  402. var i, k, len1, listings, results1;
  403. listings = (function() {
  404. var k, len1, ref1, results1;
  405. ref1 = $('#ah_left div[id*=sale]');
  406. results1 = [];
  407. for (k = 0, len1 = ref1.length; k < len1; k++) {
  408. i = ref1[k];
  409. results1.push(new AuctionListing($(i)));
  410. }
  411. return results1;
  412. })();
  413. results1 = [];
  414. for (k = 0, len1 = listings.length; k < len1; k++) {
  415. i = listings[k];
  416. results1.push(i.modifyElement());
  417. }
  418. return results1;
  419. };
  420. updateListings();
  421. form = new FormData(findMatches('form#searching', 1, 1));
  422. browseAllBackup = window.browseAll = function() {
  423. var args, cat, filledFields, gh, ghl, gl, gll, i, k, l, len1, name, postData, ref1, th, thl, tl, tll;
  424. args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
  425. console.log('browseAll called with', args);
  426. postData = {};
  427. postData.tab = args[0], postData.page = args[1], k = args.length - 2, postData.ordering = args[k++], postData.direct = args[k++];
  428. if (postData.page == null) {
  429. postData.page = 1;
  430.  
  431. /*
  432. m = findMatches('#ah_left > div:nth-child(3) > span', 0, 1)
  433. if m.length
  434. postData.page = m.text()
  435. else
  436. console.log 'No page element found, assuming only 1 page.'
  437. postData.page = '1'
  438. */
  439. }
  440. if (postData.tab == null) {
  441. postData.tab = getTab();
  442. }
  443. if (postData.ordering == null) {
  444. if ($('img[src*="button_expiration_active.png"]').length) {
  445. postData.ordering = 'expiration';
  446. } else if ($('img[src*="button_price_active.png"]').length) {
  447. postData.ordering = 'cost';
  448. } else {
  449. throw new Error("Couldn't detect ordering (expiration or price).");
  450. }
  451. }
  452. if (postData.direct == null) {
  453. if ($('img[src*="button_ascending_active.png"]').length) {
  454. postData.direct = 'ASC';
  455. } else if ($('img[src*="button_descending_active.png"]').length) {
  456. postData.direct = 'DESC';
  457. } else {
  458. throw new Error("Couldn't detect sorting direction.");
  459. }
  460. }
  461. if ((cat = form.field('cat'))) {
  462. postData.cat = cat;
  463. }
  464. if ((name = form.field('name'))) {
  465. postData.name = name;
  466. }
  467. tl = form.field('tl');
  468. th = form.field('th');
  469. gl = form.field('gl');
  470. gh = form.field('gh');
  471. tll = tl ? tl.length : 0;
  472. thl = th ? th.length : 0;
  473. gll = gl ? gl.length : 0;
  474. ghl = gh ? gh.length : 0;
  475. filledFields = 0;
  476. ref1 = [tll, thl, gll, ghl];
  477. for (l = 0, len1 = ref1.length; l < len1; l++) {
  478. i = ref1[l];
  479. if (i) {
  480. filledFields += 1;
  481. }
  482. }
  483. if (tll || thl) {
  484. if (tll) {
  485. postData.tl = tl;
  486. }
  487. if (thl) {
  488. postData.th = th;
  489. }
  490. } else if (gll || ghl) {
  491. if (gll) {
  492. postData.gl = gl;
  493. }
  494. if (ghl) {
  495. postData.gh = gh;
  496. }
  497. }
  498. console.log('Posting', postData);
  499. return $.ajax({
  500. type: "POST",
  501. data: postData,
  502. url: "includes/ah_buy_" + postData.tab + ".php",
  503. cache: false
  504. }).done(function(stuff) {
  505. findMatches("#ah_left", 1, 1).html(stuff);
  506. return setTimeout((function() {
  507. window.browseAll = browseAllBackup;
  508. return updateListings();
  509. }), 100);
  510. });
  511. };
  512. button = findMatches('input#go', 1, 1);
  513. button.attr('type', 'button');
  514. button.click(function() {
  515. return browseAllBackup();
  516. });
  517. setTimeout((function() {
  518. return browseAllBackup();
  519. }), 400);
  520. findMatches('form#searching input[type=text]').keydown(function(e) {
  521. if (e.keyCode === 13) {
  522. return button.click();
  523. }
  524. });
  525. buttonTitle = 'Tells the userscript to update formatting (show price ea and other information)\non this page, since the code for doing that automatically has a tendency to\nforget.';
  526. updateButton = $("<input type=button value=\"Update formatting\" title=\"" + buttonTitle + "\" class=mb_button>");
  527. updateButton.click(function() {
  528. window.browseAll = window.browseAllBackup = browseAllBackup;
  529. return updateListings();
  530. });
  531. findMatches('#go', 1, 1).after(updateButton);
  532. }
  533. }
  534. }
  535.  
  536. if (urlMatches(new RegExp('flightrising\.com/main\.php.*action=sell', 'i'))) {
  537. sell = window.sell = function(id, nListings, price, quantity) {
  538. var itemInList;
  539. if (quantity == null) {
  540. quantity = 1;
  541. }
  542. if (nListings <= 0) {
  543. return;
  544. }
  545. itemInList = $("a[rel][onclick*='\\'" + id + "\\'']");
  546. itemInList = $(itemInList[itemInList.length - 1]);
  547. itemInList.click();
  548. return setTimeout((function() {
  549. var durationDropdown, gemRadio, postAuctionButton, quantityDropdown, treasurePrice, treasureRadio;
  550. quantityDropdown = $('select[name=qty]');
  551. durationDropdown = $('select[name=drtn]');
  552. treasurePrice = $('input[name=treas]');
  553. treasureRadio = $('input[type=radio][name=cur][value=t]');
  554. gemRadio = $('input[type=radio][name=cur][value=g]');
  555. postAuctionButton = $('input[type=submit][value="Post Auction"]');
  556. treasureRadio.click();
  557. treasurePrice.val(price.toString());
  558. quantityDropdown.val(quantity);
  559. durationDropdown.val(3);
  560. return setHumanTimeout((function() {
  561. postAuctionButton.click();
  562. return setHumanTimeout((function() {
  563. $('button#yes').click();
  564. return setHumanTimeout((function() {
  565. $('button#yes').click();
  566. return setHumanTimeout((function() {
  567. return sell(id, nListings - 1, price, quantity);
  568. }), LOADING_WAIT);
  569. }), LOADING_WAIT);
  570. }), LOADING_WAIT);
  571. }), LOADING_WAIT);
  572. }), LOADING_WAIT);
  573. };
  574. }
  575.  
  576. if (urlMatches(new RegExp('http://www1\.flightrising\.com/msgs/[0-9]+', 'i'))) {
  577. setHumanTimeout(function() {
  578. findMatches('button#take-items', 1, 1).click();
  579. return setHumanTimeout(function() {
  580. findMatches('button#confirm', 1, 1).click();
  581. return document.title = 'Collected!';
  582. });
  583. });
  584. }
  585.  
  586. if (new RegExp('http://www1\.flightrising\.com/msgs$', 'i').test(document.location.href)) {
  587. autoCollectAll = window.autoCollectAll = function() {
  588. var i, k, len1, links, ref1, results1;
  589. links = $('img[src$="attachment.png"], img[src$="icon_treasure.png"]').parents('tr').find('a[href*="msgs"]');
  590. ref1 = (function() {
  591. var l, len1, results2;
  592. results2 = [];
  593. for (l = 0, len1 = links.length; l < len1; l++) {
  594. i = links[l];
  595. results2.push($(i));
  596. }
  597. return results2;
  598. })();
  599. results1 = [];
  600. for (k = 0, len1 = ref1.length; k < len1; k++) {
  601. i = ref1[k];
  602. results1.push(window.open(i.attr('href')));
  603. }
  604. return results1;
  605. };
  606. $('#ajaxbody').append("<input type=button class=\"beigebutton thingbutton\" id=autoCollectButton value=\"Auto-collect all.\">");
  607. $('#autoCollectButton').click(function() {
  608. return autoCollectAll();
  609. });
  610. }