AutoChallenge (hardcoded to population, no +4 level check)

Automates the challenge functionality of Nationstates, warning works only for level +4 advantage!

  1. // ==UserScript==
  2. // @name AutoChallenge (hardcoded to population, no +4 level check)
  3. // @namespace Titannia
  4. // @include http://www.nationstates.net/page=challenge
  5. // @version 1
  6. // @grant none
  7. // @description Automates the challenge functionality of Nationstates, warning works only for level +4 advantage!
  8. // ==/UserScript==
  9.  
  10. function reloadChallengePage(){
  11.  
  12.  
  13. //Acquire proper nation names via first links in challenge screen.
  14. var self = document.getElementsByClassName("nlink")[0].href.split("=")[1]
  15. var target = document.getElementsByClassName("nlink")[1].href.split("=")[1]
  16.  
  17. var nations = self + "+" + target;
  18. var specialty = "3" //hardcoded to youth rebellion. Check bottom of script for full list of values and their description
  19. var go = "+Go!+";
  20.  
  21. //Performs a post or get with the specified key/values.
  22. performPost(window.location, {nations:nations,speciality:specialty,go:go});
  23.  
  24.  
  25. function performPost(path, params, method) {
  26.  
  27. //console.log(params);
  28. //alert(params);
  29. method = method || "post"; // Set method to post by default if not specified.
  30. // The rest of this code assumes you are not using a library.
  31. // It can be made less wordy if you use one.
  32. var form = document.createElement("form");
  33. form.setAttribute("method", method);
  34. form.setAttribute("action", path);
  35.  
  36. for(var key in params) {
  37. if(params.hasOwnProperty(key)) {
  38. var hiddenField = document.createElement("input");
  39. hiddenField.setAttribute("type", "hidden");
  40. hiddenField.setAttribute("name", key);
  41. hiddenField.setAttribute("value", params[key]);
  42.  
  43. form.appendChild(hiddenField);
  44. }
  45. }
  46.  
  47. document.body.appendChild(form);
  48. form.submit();
  49. }
  50.  
  51.  
  52. }
  53.  
  54. window.onload = function () {
  55.  
  56. //See if there is a 'Round 1' and click it, then schedule a reload.
  57. var link = document.getElementsByClassName("next-round")[0];
  58. if(link) {
  59. link.click();
  60. //link.click();
  61. setTimeout(reloadChallengePage,3600 + (Math.random() * 200)); //random reload time to avoid raising flags if Nationstates has certain measures in effect.
  62. }
  63. };
  64.  
  65.  
  66. /*
  67. Full list of all the possible specialties that can be selected.
  68. <value to enter> <description>
  69. none None
  70. 0 Civil Rights
  71. 1 Economy
  72. 2 Political Freedoms
  73. 3 Population
  74. 53 Authoritarianism
  75. 67 Averageness
  76. 31 Business Subsidization
  77. 6 Compassion
  78. 51 Corruption
  79. 55 Culture
  80. 46 Defense Forces
  81. 7 Eco-Friendliness
  82. 56 Employment
  83. 63 Environmental Beauty
  84. 52 Freedom From Corruption
  85. 50 Freedom From Taxation
  86. 62 Godlessness
  87. 27 Government Size
  88. 40 Happiness
  89. 39 Health
  90. 68 Human Development Index
  91. 45 Ideological Radicality
  92. 33 Income Equality
  93. 16 Industry: Arms Manufacturing
  94. 10 Industry: Automobile Manufacturing
  95. 12 Industry: Basket Weaving
  96. 18 Industry: Beverage Sales
  97. 24 Industry: Book Publishing
  98. 11 Industry: Cheese Exports
  99. 22 Industry: Furniture Restoration
  100. 25 Industry: Gambling
  101. 13 Industry: Information Technology
  102. 21 Industry: Insurance
  103. 20 Industry: Mining
  104. 14 Industry: Pizza Delivery
  105. 23 Industry: Retail
  106. 19 Industry: Timber Woodchipping
  107. 15 Industry: Trout Fishing
  108. 65 Influence
  109. 36 Intelligence
  110. 30 Law Enforcement
  111. 44 Lifespan
  112. 48 Most Pro-Market
  113. 34 Niceness
  114. 9 Nudity
  115. 61 Obesity
  116. 47 Pacifism
  117. 38 Political Apathy
  118. 69 Primitiveness
  119. 29 Public Healthcare
  120. 57 Public Transport
  121. 60 Recreational Drug Use
  122. 32 Religiousness
  123. 35 Rudeness
  124. 43 Safety
  125. 42 Safety from Crime
  126. 70 Scientific Advancement
  127. 17 Sector: Agriculture
  128. 26 Sector: Manufacturing
  129. 8 Social Conservatism
  130. 37 Stupidity
  131. 49 Taxation
  132. 58 Tourism
  133. 64 Toxicity
  134. 5 Unexpected Death Rate
  135. 4 Wealth Gaps
  136. 59 Weaponization
  137. 41 Weather
  138. 28 Welfare
  139. 66 World Assembly Endorsements
  140. 54 Youth Rebelliousness
  141.  
  142. */