Advertisement
Darrel

Untitled

Aug 27th, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.91 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Epic Erepublik
  3. // @version 1.05
  4. // @description Automated epic fighting. USE THIS SCRIPT ONLY WHEN YOU ARE AFK AND IN ONLY 1 WINDOW/TAB WITH EREPUBLIK LAUNCHED, OTHERWISE IT WILL EAT YOUR ENERGY BARS. WHEN NOT NEEDED TURN IT OFF IN GREASEMONKEY ETC
  5. // @include http://*.erepublik.com/*
  6. // @copyright MISI
  7. // @downloadURL http://userscripts.org/scripts/source/177749.user.js
  8. // @updateURL http://userscripts.org/scripts/source/177749.meta.js
  9. // ==/UserScript==
  10.  
  11. var main_type;
  12. var military_type;
  13. var url;
  14. var hp;
  15. var max_hp;
  16. var rec_hp;
  17. var i;
  18.  
  19.  
  20. function main() {
  21. main_type = location.href.split("/")[4];
  22. military_type = location.href.split("/")[5];
  23. hp = globalNS.userInfo.wellness;
  24. max_hp = reset_health_to_recover;
  25. rec_hp = parseInt($(".tooltip_health_limit").html());
  26. rw = document.referrer.split("/")[4];
  27.  
  28. if (main_type == "military") {
  29. if (military_type == "campaigns") {
  30. if (rw == "wars") {
  31. //let's burn some well to not waste refills
  32. url = "http://www.erepublik.com" + $(".fight_button[href*=military]").eq(1).attr("href");
  33. location.href = url;
  34. } else {
  35. //let's burn some well to not waste refills
  36. url = "http://www.erepublik.com" + $(".fight_button[href*=military]").eq(0).attr("href");
  37. location.href = url;
  38. }
  39. }
  40. }
  41. if (military_type == "battlefield") {
  42. //battle page, let's fight
  43. setTimeout(function() {
  44. if (SERVER_DATA.points.defender >= 1800 || SERVER_DATA.points.attacker >= 1800) {
  45. //battle finished, let's find another one
  46. location.href = "http://www.erepublik.com/en/military/campaigns";
  47. }
  48. i = 1;
  49. t = setInterval(function() {
  50. if (globalNS.userInfo.wellness < 10) {
  51. location.href = "http://www.erepublik.com/en";
  52. }
  53. $('#fight_btn').click();
  54. i++;
  55. if (i == 10) { //beshe 2
  56. setTimeout(function() {
  57. location.href = "http://www.erepublik.com/en";
  58. }, 2000);
  59. }
  60. }, 1500);
  61. }, 1000);
  62. }
  63. else if (main_type == "wars")
  64. {
  65. //join resistance by default
  66. var addressValue = $(".join").attr("href");
  67. location.href = addressValue;
  68. } else {
  69. // we are on main page
  70. if (reset_health_to_recover - globalNS.userInfo.wellness >= 10 && parseInt($(".tooltip_health_limit").html()) >= 10) {
  71. if ($("#DailyConsumtionTrigger").hasClass("energy")) {
  72. //energy bars, ignore
  73. } else {
  74. //let's eat food
  75. $("#DailyConsumtionTrigger").click();
  76. }
  77. }
  78. setTimeout(function() {
  79. if (reset_health_to_recover - parseInt($(".tooltip_health_limit").html()) <= 600) { //beshe 200 /600
  80. //let's burn some well to not waste refills
  81. location.href = "http://www.erepublik.com/en/military/campaigns"; //beshe CAMPAIGNS
  82. } else {
  83. //nothing to do, just refresh and relax
  84. location.href = "http://www.erepublik.com/en";
  85. }
  86. }, 360000);
  87. }
  88. }
  89.  
  90. function wait() {
  91. if ( unsafeWindow.jQuery === 'undefined') {
  92. setTimeout(wait, 100);
  93. } else {
  94. $ = unsafeWindow.jQuery;
  95. main();
  96. }
  97. }
  98. wait();
  99. /*function wait() {
  100. if (typeof unsafeWindow.jQuery == 'undefined') {
  101. setTimeout(wait, 100);
  102. } else {
  103. $ = unsafeWindow.jQuery;
  104. main();
  105. }
  106. }
  107. wait();
  108.  
  109.  
  110. function main() {
  111. main_type = location.href.split("/")[4];
  112. military_type = location.href.split("/")[5];
  113. hp = globalNS.userInfo.wellness;
  114. max_hp = reset_health_to_recover;
  115. rec_hp = parseInt($(".tooltip_health_limit").html());
  116.  
  117. if (main_type == "military") {
  118. //not main page
  119. if (military_type == "campaigns") {
  120. //battles list, check for epic battle
  121. //no epic battle
  122. if (reset_health_to_recover - globalNS.userInfo.wellness >= 10) {
  123. //let's burn some well to not waste refills
  124. url = "http://www.erepublik.com" + $(".fight_button[href*=military]").eq(0).attr("href");
  125. location.href = "http://www.erepublik.com/en/wars/show/40092";
  126. } else {
  127. //nothing to do, go back to main page
  128. location.href = "http://www.erepublik.com/en";
  129. }
  130. }
  131. else if (military_type == "battlefield") {
  132. //battle page, let's fight
  133. setTimeout(function() {
  134. if (SERVER_DATA.points.defender >= 1800 || SERVER_DATA.points.attacker >= 1800) {
  135. //battle finished
  136. location.href = "http://www.erepublik.com/en";
  137. }
  138. //epic battle, go all in
  139. t = setInterval(function() {
  140. if (globalNS.userInfo.wellness < 10) {
  141. //regen energy
  142. if ($("#DailyConsumtionTrigger").hasClass("energy")) {
  143. //energy bars, ignore
  144. location.href = "http://www.erepublik.com/en";
  145. } else {
  146. //let's eat food
  147. $("#DailyConsumtionTrigger").click();
  148. }
  149. }
  150. $('#fight_btn').click();
  151. }, 3000);
  152. }, 3000);
  153. }
  154. }
  155. else if (main_type == "wars")
  156. {
  157. //join resistance by default
  158. var addressValue = $(".join").attr("href");
  159. location.href = addressValue;
  160. } else {
  161. // we are on main page
  162. if (reset_health_to_recover - globalNS.userInfo.wellness >= 10 && parseInt($(".tooltip_health_limit").html()) >= 10) {
  163. if ($("#DailyConsumtionTrigger").hasClass("energy")) {
  164. //energy bars, ignore
  165. } else {
  166. //let's eat food
  167. $("#DailyConsumtionTrigger").click();
  168. }
  169. }
  170. setTimeout(function() {
  171. location.href = "http://www.erepublik.com/en/military/campaigns";
  172. }, 300000);
  173. }
  174. }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement