Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name [CB] Dark Throne GOLD Recruiter
- // @description Dark Throne recruiter for gold (final) version (http://www.darkthrone.com/)
- // @description Updated to work with the HTML and JavaScript updates announced on Feb 7, 2009
- // @include http://www.darkthrone.com/recruiter*
- // @include http://www.darkthrone.com/training*
- // @include http://www.darkthrone.com/mercenaries*
- // @exclude http://www.darkthrone.com/recruiter/outside/*
- // @author CornelB
- // @author cornelb@gmail.com
- // @version 1.8
- // ==/UserScript==
- var recruitImg = document.getElementById("recruit_image");
- var comecar = document.getElementById("recruit_link");
- //var acabou = document.getElementsByClassName("center")[0].innerHTML;
- //if(acabou != null && acabou.indexOf("You") > -1) {
- // window.location.href = "http://www.darkthrone.com/training";
- //}
- if(comecar != null){
- recruitLink=comecar.parentNode;
- document.addEventListener('keydown', keyPressHandler, false);
- }
- //var recruitImg = null;
- var url = window.location.href;
- if(url.match("/recruiter")) {
- if(recruitImg != null){
- recruitLink=recruitImg.parentNode;
- appendAbortButton();
- document.addEventListener('keydown', keyPressHandler, false);
- window.setTimeout(function(){make_form()},Math.floor(Math.random() * (3300 - 2300 + 1)) + 2300);
- } else {
- window.location.replace("http://www.darkthrone.com/training");
- GM_openInTab("http://www.darkthrone.com/mercenaries");
- }
- } else if (url.match("/mercenaries")) {
- for(var i = 4; i < 14; i += 3){
- var mercenaries = document.getElementsByClassName("center")[i].innerHTML;
- if(mercenaries.trim() > 0) {
- document.getElementsByClassName("btn button_buy_all ")[0].click();
- break;
- }
- }
- } else {
- appendRadios();
- if(GM_getValue("campo") == ""){
- } else {
- temCitizens(GM_getValue("campo"));
- }
- }
- function make_form(){
- var f=document.createElement('form');
- f.style.display='none';
- recruitLink.parentNode.appendChild(f);
- f.method='POST';
- f.action=recruitLink.href;
- f.submit();
- }
- function keyPressHandler(event) {
- if(event.keyCode!=65) { // a
- return;
- }
- top.location='http://www.darkthrone.com/overview';
- }
- function appendAbortButton(){
- abortButton=document.createElement('button');
- abortButton.addEventListener("click", function(){ top.location='http://www.darkthrone.com/overview'; }, false);
- abortButton.appendChild(document.createTextNode("Abort Auto-Recruiting"));
- abortButton.appendChild(br());
- abortButton.appendChild(document.createTextNode("( or press [a] key )"));
- insertAfterRecruitLink(abortButton, recruitLink);
- }
- function appendRadios(){
- var trainButtons = document.getElementsByClassName('submit_buttons')[0];
- var divTag = document.createElement('div');
- divTag.className = "right";
- var th = document.createElement('th');
- th.className = "center";
- var font = document.createElement('font');
- font.setAttribute("color","#00ff00");
- var tr = document.createElement('tr');
- var td = document.createElement('td');
- trainButtons.appendChild(divTag);
- divTag.appendChild(th);
- th.appendChild(font);
- font.appendChild(document.createTextNode("Auto-Training in 20 seconds"));
- divTag.appendChild(tr);
- divTag.appendChild(td);
- var minerRadio = document.createElement('input');
- minerRadio.type = "radio";
- minerRadio.name = "radio";
- minerRadio.onclick = function() { defineCampos("qty_c2"); }
- var soldierRadio = document.createElement('input');
- soldierRadio.type = "radio";
- soldierRadio.name = "radio";
- soldierRadio.onclick = function() { defineCampos("qty_c3"); }
- var knightRadio = document.createElement('input');
- knightRadio.type = "radio";
- knightRadio.name = "radio";
- knightRadio.onclick = function() { defineCampos("qty_c7"); }
- var guardRadio = document.createElement('input');
- guardRadio.type = "radio";
- guardRadio.name = "radio";
- guardRadio.onclick = function() { defineCampos("qty_c4"); }
- var archerRadio = document.createElement('input');
- archerRadio.type = "radio";
- archerRadio.name = "radio";
- archerRadio.onclick = function() { defineCampos("qty_c8"); }
- var spyRadio = document.createElement('input');
- spyRadio.type = "radio";
- spyRadio.name = "radio";
- spyRadio.onclick = function() { defineCampos("qty_c5"); }
- var sentryRadio = document.createElement('input');
- sentryRadio.type = "radio";
- sentryRadio.name = "radio";
- sentryRadio.onclick = function() { defineCampos("qty_c6"); }
- var disableRadio = document.createElement('input');
- disableRadio.type = "radio";
- disableRadio.name = "radio";
- disableRadio.onclick = function() { apagaCampos("Disabled"); }
- td.appendChild(minerRadio);
- td.appendChild(document.createTextNode("Worker | "));
- td.appendChild(soldierRadio);
- td.appendChild(document.createTextNode("Soldier | "));
- td.appendChild(knightRadio);
- td.appendChild(document.createTextNode("Knight | "));
- td.appendChild(guardRadio);
- td.appendChild(document.createTextNode("Guard | "));
- td.appendChild(archerRadio);
- td.appendChild(document.createTextNode("Archer | "));
- td.appendChild(spyRadio);
- td.appendChild(document.createTextNode("Spy | "));
- td.appendChild(sentryRadio);
- td.appendChild(document.createTextNode("Sentry | "));
- td.appendChild(disableRadio);
- td.appendChild(document.createTextNode("Disabled"));
- if(GM_getValue("campo") != null) {
- switch (GM_getValue("campo")) {
- case "qty_c2": minerRadio.checked = true;
- break;
- case "qty_c3": soldierRadio.checked = true;
- break;
- case "qty_c7": knightRadio.checked = true;
- break;
- case "qty_c4": guardRadio.checked = true;
- break;
- case "qty_c8": archerRadio.checked = true;
- break;
- case "qty_c5": spyRadio.checked = true;
- break;
- case "qty_c6": sentryRadio.checked = true;
- break;
- default : disableRadio.checked = true;
- }
- }
- }
- function insertAfterRecruitLink(elementToInsert){
- insertPoint=recruitLink.nextSibling;
- insertParent=recruitLink.parentNode;
- insertParent.insertBefore(br(),insertPoint);
- insertParent.insertBefore(br(),insertPoint);
- insertParent.insertBefore(elementToInsert,insertPoint);
- }
- function br(){
- return document.createElement('br');
- }
- function apagaCampos(field){
- document.getElementById("qty_c2").value = "";
- document.getElementById("qty_c3").value = "";
- document.getElementById("qty_c4").value = "";
- document.getElementById("qty_c5").value = "";
- document.getElementById("qty_c6").value = "";
- document.getElementById("qty_c7").value = "";
- document.getElementById("qty_c8").value = "";
- if (field == "Disabled"){
- GM_setValue('campo', "");
- } else {
- temCitizens();
- }
- }
- function defineCampos(field) {
- GM_setValue('campo', field);
- apagaCampos(field);
- temCitizens();
- }
- function temCitizens(field) {
- var citizens = document.getElementsByTagName("div")[12].innerHTML.split("Citizens: ")[1].slice(0,document.getElementsByTagName("div")[12].innerHTML.split("Citizens: ")[1].indexOf("<"));
- if(citizens > 0){
- document.getElementById(field).value = citizens;
- setTimeout('document.getElementsByName("train")[0].click()', 20000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement