Holy War

Skips (clicks "New Opponent") those with characteristics lower/higher than a set amount of haul, attack, victory/loss ratio, defense, level, etc. - works great for those without premium who still want to find players with desirable attributes. Also automatically plunders, works, and attacks (optional) to get gold while you sleep. Simply change the min/max values to your desired specifications and let it roll!

当前为 2020-02-26 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Holy War
  3. // @namespace https://greasyfork.org/users/3633-michael-frake
  4. // @description Skips (clicks "New Opponent") those with characteristics lower/higher than a set amount of haul, attack, victory/loss ratio, defense, level, etc. - works great for those without premium who still want to find players with desirable attributes. Also automatically plunders, works, and attacks (optional) to get gold while you sleep. Simply change the min/max values to your desired specifications and let it roll!
  5. // @include *holy-war.net/busy*
  6. // @include *holy-war.net/auth*
  7. // @include *holy-war.net/assault*
  8. // @include *holy-war.net/town/farm*
  9. // @include *holy-war.net/char*
  10. // @include *holy-war.net/town/alchemist*
  11. // @include *holy-war.net/welcome*
  12. // @include *holy-war.de/busy*
  13. // @include *holy-war.de/auth*
  14. // @include *holy-war.de/assault*
  15. // @include *holy-war.de/town/farm*
  16. // @include *holy-war.de/char*
  17. // @include *holy-war.de/town/alchemist*
  18. // @include *holy-war.de/welcome*
  19. // @version 2.12
  20. // @grant none
  21. // ==/UserScript==
  22.  
  23. //------------- customization options
  24. var de = false; //set this to true if you use the .de version of the website
  25. var world = "1EN"; //YOU MUST CHANGE THIS TO YOUR WORLD.
  26. var auto_plunder = true; //plunder automatically for 60 minutes.
  27. var auto_attack = true; //automatically attacks if opponent fits stat standards [CAUTION: USES GOLD].
  28. var use_totals = true; //if this is in effect, attacking only considers the opponent's summed stats versus your summed basic stats, not including horse, equipment, or house.
  29. var auto_work = true; //work only after plunder time = 0. good at night.
  30. var auto_train = true; //trains only the character's lowest stats and buys potions with the remaining gold automatically after plundering [NOT THE HORSE - CAUTION: USES GOLD].
  31. var auto_login = true; //only works if you have username and password defined below.
  32.  
  33. var my_stats = [ //if you are using auto_attack, YOU MUST CHANGE THESE TO YOUR STATS in order to fight effectively.
  34. //Alternatively, set these to the maximum values you accept for an opponent's stats.
  35. strength_max = 69,
  36. attack_max = 69,
  37. agility_max = 69,
  38. stamina_max = 69,
  39. defence_max = 69
  40. ];
  41.  
  42. var attack_thresholds = [ //if you are not using use_totals, update these thresholds to your preferences.
  43. level_min = 28,
  44. haul_min = 150, //do they ever play? if not, probably no gold.
  45. ratio_min = 0.2 //if they lose constantly, they probably have no gold.
  46. ];
  47.  
  48. var username = ""; //obviously update with your own info, then never share the code directly!
  49. var password = "";
  50.  
  51. /*
  52. NOTE: Beware of contradictions. If you have auto attack on, the script is designed to ignore
  53. auto work and vice versa (you can't attack/work at the same time).
  54. */
  55.  
  56. var stat_names = [
  57. level_str = 'Level',
  58. haul_str = 'Gold haul',
  59. strength_str = 'Strength',
  60. attack_str = 'Attack',
  61. agility_str = 'Agility',
  62. stamina_str = 'Stamina',
  63. defence_str = 'Defence',
  64. ratio_str = 'Victories/defeats'
  65. ];
  66. //-------------
  67.  
  68.  
  69. //------------- initialization/functions
  70. var i;
  71. var j;
  72. var my_total;
  73.  
  74. for (j = 0; j<my_stats.length; j++) { //initializes my_total
  75. my_total += my_stats[j];
  76. }
  77.  
  78. function redir(url) { //always pass the .net version into these redirect functions, it will fix it if the "de" var is true
  79. if (de == false) {
  80. window.location.href = url + world;
  81. }
  82. else {
  83. window.location.href = url.replace("net", "de") + world;
  84. }
  85. }
  86.  
  87. function delRedir(url, time) { //delays a redirect by the time in milliseconds
  88. if (de == false) {
  89. window.setTimeout('window.location.href="' + url + '"' + world + ';', time);
  90. }
  91. else {
  92. window.setTimeout('window.location.href="' + url.replace("net", "de") + '"' + world + ';', time);
  93. }
  94. }
  95.  
  96. var additive = '</td><td style = "width:40%; text-align:left;">'; //comes after each stat
  97. function getStat(string) {
  98. string += additive;
  99. var opp_stat = document.body.innerHTML.substring(document.body.innerHTML.indexOf(string)+string.length-2, document.body.innerHTML.indexOf(string)+string.length+8);
  100. opp_stat = Number(opp_stat.replace(/[^0-9.]/g, ""))
  101. if (opp_stat != null) {
  102. return opp_stat;
  103. }
  104. else {
  105. window.alert("error in finding stat " + stat_names[i]);
  106. return false;
  107. }
  108. }
  109.  
  110. function check(string, type, limit) { //returns true if you can't defeat the opponent or the opponent is too weak.
  111. var opp_stat = getStat(string);
  112. if (opp_stat != false) { //do not rephrase logic here - it's only false or a stat, never true
  113. if (limit == "max") {
  114. if (opp_stat > type) {
  115. return true;
  116. }
  117. }
  118. else {
  119. if (opp_stat < type) {
  120. return true;
  121. }
  122. else {
  123. return false;
  124. }
  125. }
  126. }
  127. return true;
  128. }
  129.  
  130. if (window.location.href.indexOf("welcome") != -1 && auto_plunder == true) { //redirect if at home screen to auto-plunder
  131. redir("http://holy-war.net/assault/1on1/?w=");
  132. }
  133.  
  134. if (window.location.href.indexOf("auth") != -1 && auto_login == true) { //auto login if on the login page
  135. document.getElementsByName("username")[0].value = username;
  136. document.getElementsByName("password")[0].value = password;
  137. document.getElementsByName("world")[0].value = world;
  138. document.getElementsByClassName("submit_image")[0].click();
  139. }
  140.  
  141. var opp_total = 0; //opponent's summed stats
  142. if (window.location.href.indexOf("assault/1on1/search") != -1) { //total opponent's stats and decide to attack if an opponent was searched
  143. for (i = 2; i <= 6; i++) { //2-6 of stat_names are the only stats we care about for this calculation
  144. if (getStat(stat_names[i]) != false) {
  145. opp_total += getStat(stat_names[i]);
  146. }
  147. else {
  148. use_totals = false; //only doing this because of the error
  149. }
  150. }
  151. //should we attack?
  152. if (auto_attack == true) {
  153. var defeatable = false;
  154. j = 0; //separate counter for my_stats
  155. for (i = 0; i < stat_names.length; i++) { //0, 1, 7 are all the mins (level, ratio, haul)
  156. defeatable = true; //if check returns true, then you can't defeat the opponent or the opponent is too weak.
  157. if (use_totals == false) {
  158. if (i == 0 || i == 1 || i == 7) { //attack_thresholds
  159. window.alert(stat_names[i] + " checking to " + attack_thresholds[j]);
  160. if (check(stat_names[i], attack_thresholds[j], "min") == true) {
  161. defeatable = false;
  162. }
  163. j++; //correct counter to compare to attack_thresholds appropriately
  164. }
  165. else {
  166. if (check(stat_names[i], my_stats[i - 2], "max") == true) { //must compare to my_stats - 2 because of the combined nature of stat_names
  167. defeatable = false;
  168. }
  169. }
  170. }
  171. else { //using totals instead
  172. if (opp_total > my_total) {
  173. window.alert("Opponent's total is " + opp_total + ", which is greater than my total of " + my_total);
  174. defeatable = false;
  175. }
  176. }
  177. }
  178. if (defeatable == true && document.getElementsByName("Attack")[0]) {
  179. document.getElementsByName("Attack")[0].click(); //attack if defeatable
  180. }
  181. if (defeatable != true && document.getElementsByName("Attack")[0]) {
  182. document.getElementsByTagName("button")[0].click(); //new opponent
  183. }
  184. }
  185.  
  186. }
  187. //-------------
  188.  
  189.  
  190. //------------- logic
  191. var time_left = document.getElementsByName("ravageTime")[0];
  192.  
  193. if (document.body.innerHTML.indexOf("Gold plundered: ") != -1 || document.body.innerHTML.indexOf("Summarised fight report") != -1) {
  194. redir("http://holy-war.net/assault/1on1/"); //reset and plunder again if finished
  195. }
  196.  
  197. if (time_left && auto_plunder == true && document.getElementsByName("PLUNDER_ACTION")[0] && time_left.options[0].value == "10") {
  198. document.getElementsByName("PLUNDER_ACTION")[0].click(); //click plunder if time is greater than 0
  199. }
  200.  
  201. if (time_left && auto_plunder == false && auto_work == false && auto_attack == true) {
  202. document.getElementsByName("Search")[0].click(); //attacks if auto_attack = true
  203. }
  204.  
  205. if (time_left != null && time_left.options[0].value != "10" && auto_work == true && auto_attack == false) {
  206. redir("http://holy-war.net/char/attributes/");
  207. }
  208.  
  209. if (window.location.href.indexOf("town/farm") != -1 && document.body.getElementsByTagName("select")[0] && auto_work == true) {
  210. document.body.getElementsByTagName("select")[0].value = "8" //8 hours for auto work after plunder
  211. document.body.getElementsByTagName("button")[0].click();
  212. }
  213.  
  214. if (window.location.href.indexOf("char/") != -1 && auto_train == true) {
  215. var widths = [];
  216. var stat_names_stats = [
  217. 'Strength',
  218. 'Attack',
  219. 'Defence',
  220. 'Agility',
  221. 'Stamina'
  222. ];
  223. var string;
  224. for (i = 0; i < stat_names_stats.length; i++) {
  225. string = stat_names_stats[i];
  226. var my_stat = document.body.innerHTML.substring(document.body.innerHTML.indexOf(string, 9000)+446, document.body.innerHTML.indexOf(string, 9000)+452);
  227. my_stat = Number(my_stat.replace(/[^0-9.]/g, ""));
  228. widths[i] = my_stat;
  229. }
  230. var min_stat = Math.min.apply(Math, widths);
  231. var stat_num;
  232. for (var k = 0; k<widths.length; k++) {
  233. if (widths[k] == min_stat) {
  234. stat_num = k;
  235. k = widths.length;
  236. break;
  237. }
  238. }
  239. var buttons = document.getElementsByTagName("button");
  240. var clickables = [];
  241. for (j = 0; j<buttons.length; j++) {
  242. if (buttons[j].name == "Train") {
  243. clickables[j]= buttons[j];
  244. }
  245. }
  246. if (clickables.length == 8) {
  247. clickables[stat_num].click();
  248. }
  249. else if (clickables[0] && clickables.length > 3) {
  250. clickables[0].click();
  251. }
  252. if (auto_work == true) {
  253. delRedir("http://holy-war.net/town/alchemist/?w = ", 2000);
  254. }
  255. }
  256.  
  257. if (window.location.href.indexOf("alchemist/") != -1 && auto_train == true) {
  258. var potions = document.getElementsByName("No alternative text available");
  259. var buyables = [];
  260. for (i = 0; i<potions.length; i++) {
  261. if (potions[i].innerHTML.indexOf("btn_kaufen") != -1) { //buy button image
  262. buyables[i] = potions[i];
  263. }
  264. }
  265. if (buyables[buyables.length-1]) {
  266. buyables[buyables.length-1].click();
  267. }
  268. else {
  269. if (auto_work == true) {
  270. delRedir("http://holy-war.net/town/farm/?w = ", 2000);
  271. }
  272. }
  273. }
  274. //-------------