Advertisement
Guest User

Untitled

a guest
Dec 15th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Giełda Premium 118
  3. // @namespace Tampermonkey ? Home
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author xxx
  7. // @match [url]https://pl118.plemiona.pl/*[/url]
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. var mode = "sell"; // sell or buy when red (lowest price) "sell" or "buy"
  12. var interval = 1000; // interval in ms
  13. var waitForMerchant = 60000; // in ms
  14.  
  15. //////////////////////////////////////////////////////////////
  16. // Coded by: Couiz
  17. //////////////////////////////////////////////////////////////
  18.  
  19. var $button = $("input.btn-premium-exchange-buy"),
  20. $confirmButton = $(".btn-confirm-yes");
  21.  
  22. switch(mode) {
  23. case "sell":
  24. sell();
  25. break;
  26. case "buy":
  27. //buy();
  28. error();
  29. break;
  30. default:
  31. error();
  32. }
  33.  
  34. function error() {
  35. console.warn("Wrong mode selected.");
  36. }
  37.  
  38. function sell() {
  39. var merchants = PremiumExchange.data.merchants;
  40. var resources = {
  41. wood: {
  42. stock: PremiumExchange.data.stock.wood,
  43. capacity: PremiumExchange.data.capacity.wood,
  44. own: game_data.village.wood
  45. },
  46. stone: {
  47. stock: PremiumExchange.data.stock.stone,
  48. capacity: PremiumExchange.data.capacity.stone,
  49. own: game_data.village.stone
  50. },
  51. iron: {
  52. stock: PremiumExchange.data.stock.iron,
  53. capacity: PremiumExchange.data.capacity.iron,
  54. own: game_data.village.iron
  55. }
  56. };
  57. if (merchants === 0) {
  58. console.log("Waiting for merchants " + waitForMerchant + " ms");
  59. setTimeout(sell, waitForMerchant);
  60. return;
  61. }
  62. for (res in resources) {
  63. if (resources[res].stock < resources[res].capacity) {
  64. var value = resources[res].capacity - resources[res].stock;
  65. if (value > resources[res].own - 1000) {
  66. continue;
  67. }
  68. sellResource(res, value);
  69. setTimeout(sell, 4000);
  70. return;
  71. }
  72. }
  73. console.log('<3 Couiz');
  74. setTimeout(sell, interval);
  75. }
  76.  
  77. function searchPopup()
  78. {
  79. var $popUp = $(".confirmation-box"),
  80. $fader = $("#fader:visible");
  81. if ($popUp.length > 0 && $fader.length > 0) {
  82. return true;
  83. }
  84. return false;
  85. }
  86.  
  87. function sellResource(_res, _value) {
  88. $("input[name='sell_" + _res + "']").val(_value);
  89. setTimeout(function(){
  90. $button.click();
  91. var a = setInterval(function() {
  92. if (searchPopup()) {
  93. $confirmButton = $($confirmButton.selector);
  94. $confirmButton.click();
  95. console.log('Sold ' + _value + ' ' + _res);
  96. clearInterval(a);
  97. }
  98. }, 250);
  99. }, 250);
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement