Advertisement
Guest User

Dark Throne GOLD Recruiter + AutoTraining + BuyMercenaries

a guest
Apr 25th, 2012
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.78 KB | None | 0 0
  1. // ==UserScript==
  2. // @name [CB] Dark Throne GOLD Recruiter
  3. // @description Dark Throne recruiter for gold (final) version (http://www.darkthrone.com/)
  4. // @description Updated to work with the HTML and JavaScript updates announced on Feb 7, 2009
  5. // @include http://www.darkthrone.com/recruiter*
  6. // @include http://www.darkthrone.com/training*
  7. // @include http://www.darkthrone.com/mercenaries*
  8. // @exclude http://www.darkthrone.com/recruiter/outside/*
  9. // @author CornelB
  10. // @author cornelb@gmail.com
  11. // @version 1.8
  12. // ==/UserScript==
  13.  
  14. var recruitImg = document.getElementById("recruit_image");
  15. var comecar = document.getElementById("recruit_link");
  16. //var acabou = document.getElementsByClassName("center")[0].innerHTML;
  17.  
  18. //if(acabou != null && acabou.indexOf("You") > -1) {
  19. // window.location.href = "http://www.darkthrone.com/training";
  20. //}
  21.  
  22.  
  23. if(comecar != null){
  24. recruitLink=comecar.parentNode;
  25. document.addEventListener('keydown', keyPressHandler, false);
  26. }
  27. //var recruitImg = null;
  28.  
  29. var url = window.location.href;
  30. if(url.match("/recruiter")) {
  31.  
  32. if(recruitImg != null){
  33.  
  34. recruitLink=recruitImg.parentNode;
  35. appendAbortButton();
  36. document.addEventListener('keydown', keyPressHandler, false);
  37. window.setTimeout(function(){make_form()},Math.floor(Math.random() * (3300 - 2300 + 1)) + 2300);
  38. } else {
  39. window.location.replace("http://www.darkthrone.com/training");
  40. GM_openInTab("http://www.darkthrone.com/mercenaries");
  41. }
  42.  
  43. } else if (url.match("/mercenaries")) {
  44.  
  45. for(var i = 4; i < 14; i += 3){
  46. var mercenaries = document.getElementsByClassName("center")[i].innerHTML;
  47.  
  48. if(mercenaries.trim() > 0) {
  49. document.getElementsByClassName("btn button_buy_all ")[0].click();
  50. break;
  51. }
  52. }
  53.  
  54. } else {
  55.  
  56. appendRadios();
  57.  
  58. if(GM_getValue("campo") == ""){
  59.  
  60. } else {
  61. temCitizens(GM_getValue("campo"));
  62. }
  63. }
  64.  
  65.  
  66. function make_form(){
  67. var f=document.createElement('form');
  68. f.style.display='none';
  69. recruitLink.parentNode.appendChild(f);
  70. f.method='POST';
  71. f.action=recruitLink.href;
  72. f.submit();
  73. }
  74.  
  75. function keyPressHandler(event) {
  76. if(event.keyCode!=65) { // a
  77. return;
  78. }
  79. top.location='http://www.darkthrone.com/overview';
  80. }
  81.  
  82. function appendAbortButton(){
  83. abortButton=document.createElement('button');
  84. abortButton.addEventListener("click", function(){ top.location='http://www.darkthrone.com/overview'; }, false);
  85. abortButton.appendChild(document.createTextNode("Abort Auto-Recruiting"));
  86. abortButton.appendChild(br());
  87. abortButton.appendChild(document.createTextNode("( or press [a] key )"));
  88. insertAfterRecruitLink(abortButton, recruitLink);
  89. }
  90.  
  91. function appendRadios(){
  92. var trainButtons = document.getElementsByClassName('submit_buttons')[0];
  93.  
  94. var divTag = document.createElement('div');
  95. divTag.className = "right";
  96.  
  97. var th = document.createElement('th');
  98. th.className = "center";
  99.  
  100. var font = document.createElement('font');
  101. font.setAttribute("color","#00ff00");
  102.  
  103. var tr = document.createElement('tr');
  104. var td = document.createElement('td');
  105.  
  106. trainButtons.appendChild(divTag);
  107. divTag.appendChild(th);
  108. th.appendChild(font);
  109. font.appendChild(document.createTextNode("Auto-Training in 20 seconds"));
  110. divTag.appendChild(tr);
  111. divTag.appendChild(td);
  112.  
  113.  
  114. var minerRadio = document.createElement('input');
  115. minerRadio.type = "radio";
  116. minerRadio.name = "radio";
  117. minerRadio.onclick = function() { defineCampos("qty_c2"); }
  118.  
  119. var soldierRadio = document.createElement('input');
  120. soldierRadio.type = "radio";
  121. soldierRadio.name = "radio";
  122. soldierRadio.onclick = function() { defineCampos("qty_c3"); }
  123.  
  124. var knightRadio = document.createElement('input');
  125. knightRadio.type = "radio";
  126. knightRadio.name = "radio";
  127. knightRadio.onclick = function() { defineCampos("qty_c7"); }
  128.  
  129. var guardRadio = document.createElement('input');
  130. guardRadio.type = "radio";
  131. guardRadio.name = "radio";
  132. guardRadio.onclick = function() { defineCampos("qty_c4"); }
  133.  
  134. var archerRadio = document.createElement('input');
  135. archerRadio.type = "radio";
  136. archerRadio.name = "radio";
  137. archerRadio.onclick = function() { defineCampos("qty_c8"); }
  138.  
  139. var spyRadio = document.createElement('input');
  140. spyRadio.type = "radio";
  141. spyRadio.name = "radio";
  142. spyRadio.onclick = function() { defineCampos("qty_c5"); }
  143.  
  144. var sentryRadio = document.createElement('input');
  145. sentryRadio.type = "radio";
  146. sentryRadio.name = "radio";
  147. sentryRadio.onclick = function() { defineCampos("qty_c6"); }
  148.  
  149. var disableRadio = document.createElement('input');
  150. disableRadio.type = "radio";
  151. disableRadio.name = "radio";
  152. disableRadio.onclick = function() { apagaCampos("Disabled"); }
  153.  
  154.  
  155. td.appendChild(minerRadio);
  156. td.appendChild(document.createTextNode("Worker | "));
  157. td.appendChild(soldierRadio);
  158. td.appendChild(document.createTextNode("Soldier | "));
  159. td.appendChild(knightRadio);
  160. td.appendChild(document.createTextNode("Knight | "));
  161. td.appendChild(guardRadio);
  162. td.appendChild(document.createTextNode("Guard | "));
  163. td.appendChild(archerRadio);
  164. td.appendChild(document.createTextNode("Archer | "));
  165. td.appendChild(spyRadio);
  166. td.appendChild(document.createTextNode("Spy | "));
  167. td.appendChild(sentryRadio);
  168. td.appendChild(document.createTextNode("Sentry | "));
  169. td.appendChild(disableRadio);
  170. td.appendChild(document.createTextNode("Disabled"));
  171.  
  172.  
  173. if(GM_getValue("campo") != null) {
  174. switch (GM_getValue("campo")) {
  175. case "qty_c2": minerRadio.checked = true;
  176. break;
  177. case "qty_c3": soldierRadio.checked = true;
  178. break;
  179. case "qty_c7": knightRadio.checked = true;
  180. break;
  181. case "qty_c4": guardRadio.checked = true;
  182. break;
  183. case "qty_c8": archerRadio.checked = true;
  184. break;
  185. case "qty_c5": spyRadio.checked = true;
  186. break;
  187. case "qty_c6": sentryRadio.checked = true;
  188. break;
  189. default : disableRadio.checked = true;
  190. }
  191. }
  192.  
  193. }
  194.  
  195. function insertAfterRecruitLink(elementToInsert){
  196. insertPoint=recruitLink.nextSibling;
  197. insertParent=recruitLink.parentNode;
  198. insertParent.insertBefore(br(),insertPoint);
  199. insertParent.insertBefore(br(),insertPoint);
  200. insertParent.insertBefore(elementToInsert,insertPoint);
  201. }
  202.  
  203. function br(){
  204. return document.createElement('br');
  205. }
  206.  
  207. function apagaCampos(field){
  208. document.getElementById("qty_c2").value = "";
  209. document.getElementById("qty_c3").value = "";
  210. document.getElementById("qty_c4").value = "";
  211. document.getElementById("qty_c5").value = "";
  212. document.getElementById("qty_c6").value = "";
  213. document.getElementById("qty_c7").value = "";
  214. document.getElementById("qty_c8").value = "";
  215. if (field == "Disabled"){
  216. GM_setValue('campo', "");
  217. } else {
  218. temCitizens();
  219. }
  220. }
  221.  
  222. function defineCampos(field) {
  223. GM_setValue('campo', field);
  224. apagaCampos(field);
  225. temCitizens();
  226. }
  227.  
  228. function temCitizens(field) {
  229. var citizens = document.getElementsByTagName("div")[12].innerHTML.split("Citizens: ")[1].slice(0,document.getElementsByTagName("div")[12].innerHTML.split("Citizens: ")[1].indexOf("<"));
  230. if(citizens > 0){
  231. document.getElementById(field).value = citizens;
  232. setTimeout('document.getElementsByName("train")[0].click()', 20000);
  233. }
  234. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement