Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. javascript:
  2. var GetNumber = function (x)
  3. {
  4. return parseInt(x.replace(/<span class="grey">.<\/span>/g, '').match(/\d+/));
  5. };
  6.  
  7. $('tbody').find('tr.supply_location').each(function()
  8. {
  9. var traders = GetNumber($(this).find('td.traders')[0].innerHTML);
  10. var wood = GetNumber($(this).find('span[class *= "wood"]')[0].innerHTML);
  11. var stone = GetNumber($(this).find('span[class *= "stone"]')[0].innerHTML);
  12. var iron = GetNumber($(this).find('span[class *= "iron"]')[0].innerHTML);
  13. var totalresources = wood + stone + iron;
  14. var checkValue = Math.min(wood,stone,iron);
  15. if(traders > 0 && totalresources * 3 > traders*1000 && checkValue > 1000)
  16. {
  17. var button = $(this).find('input.call_button.btn');
  18. if(button.val() == "Selecteren")
  19. {
  20. button.click();
  21. var MaxGoldCoins = Math.min(wood/28000,stone/30000,iron/25000);
  22. wood = Math.floor(MaxGoldCoins*28000);
  23. stone = Math.floor(MaxGoldCoins*30000);
  24. iron = Math.floor(MaxGoldCoins*25000);
  25. totalresources = wood + stone + iron;
  26. if (totalresources > traders*1000)
  27. {
  28. MaxGoldCoins = traders / 83;
  29. wood = Math.floor(MaxGoldCoins*28000);
  30. stone = Math.floor(MaxGoldCoins*30000);
  31. iron = Math.floor(MaxGoldCoins*25000);
  32. }
  33. this.children[2].children[1].value = wood;
  34. this.children[3].children[1].value = stone;
  35. this.children[4].children[1].value = iron;
  36. }
  37. else
  38. {
  39. button.click();
  40. return false;
  41. }
  42. }
  43. });
  44.  
  45. void(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement