Resource Balancer Script

Discussion in 'Scripts & Independent Tools' started by ronpaul2008, Oct 17, 2009.

Share This Page

  1. *RiX*

    *RiX* Guest

    8 Days from our 6 year anniversary for this script. Did you ever expect this to live so long RonPaul2008? I sort of miss the days of BlackDawn and world 30, we were an epic tribe.
     
  2. golden one

    golden one New Member

    Joined:
    Sep 2, 2015
    Messages:
    2
    Likes Received:
    0
    *Rix* and RonPaul2008 thank you!!! This is an amazing script!
     
  3. MR.MR

    MR.MR Contributing Poster

    Joined:
    Feb 19, 2009
    Messages:
    1,711
    Likes Received:
    21
    Is anyone else having difficulties with this script? I tried using it for the first time in months (using the version hosted by tribalwars.co.uk staff)

    Code:
    javascript:$.getScript('https://media.innogamescdn.com/com_DS_UK/Scripts/ExtremeTw_ResourceBalancer_launcher.js');void 0;
    It takes you to the Extreme Page, plans out your sends, opens all tabs, but when you go to run the script from the marketplace, it does not input resources; rather, it opens a new tab that gives you the "session expired please login again" screen.

    Anyone have any similar issues?
     
  4. Titu

    Titu Non-stop Poster

    Joined:
    Feb 10, 2015
    Messages:
    152
    Likes Received:
    43
    That is not the full script. The hosted script gives exactly what you got - "It takes you to the Extreme Page, plans out your sends, opens all tabs" but the functions to enter the resources and further actions are not in hosted version. Hence you need to have them in your launcher script. (or another script to do that)

    Use the following script. Works perfectly for me.
    Code:
    javascript:function MarketMain(){var a=document;if(window.frames.length>0)a=window.main.document;var b=a.createElement('script');b.type='text/javascript';b.src='https://media.innogamescdn.com/com_DS_UK/Scripts/ExtremeTw_ResourceBalancer_launcher.js';a.getElementsByTagName('head')[0].appendChild(b)}function getGameDoc(winvar){getdoc=winvar.document;if(!getdoc.URL.match('game\.php')){for(var i=0;i<winvar.frames.length;i++){if(winvar.frames[i].document.URL.match('game\.php')){getdoc=winvar.frames[i].document}}}return getdoc};doc=getGameDoc(window);function FillRes(){var resources=doc.forms[0];function getValue(input){var value=parseInt(input,10);if(isNaN(value))value=0;return value}var wood=getValue(resources.wood.value);var clay=getValue(resources.stone.value);var iron=getValue(resources.iron.value);function OKClick(){var arrInputs=resources.getElementsByTagName('input');for(var idx1=0;idx1<arrInputs.length;idx1++){if(arrInputs[idx1].value.indexOf('OK')!=-1){arrInputs[idx1].click();break}}}function insertValues(){var URLargs=doc.URL.split("&");for(var i=0;i<URLargs.length;i++){var args=URLargs[i].split("=");if(args.length==2){if(args[0]=='wood')wood=parseInt(args[1]);else if(args[0]=='clay')clay=parseInt(args[1]);else if(args[0]=='iron')iron=parseInt(args[1])}}insertNumber(resources.wood,wood);insertNumber(resources.stone,clay);insertNumber(resources.iron,iron)}if(wood+clay+iron>0){OKClick()}else{insertValues()}}if(doc.URL.match(/clay=/)||doc.URL.match(/confirm_send/)){FillRes()}else{MarketMain()}
     
    Last edited: Jan 13, 2016
  5. LilGhost

    LilGhost Well-Known Member

    Joined:
    Jan 2, 2016
    Messages:
    87
    Likes Received:
    8
    Thanks for the share. Just tested that on World 84. It seems to work perfectly.
     
  6. calinirinel

    calinirinel Guest

    Didnt work

    Didnt work
     
  7. Portile iadului

    Portile iadului New Member

    Joined:
    Nov 2, 2010
    Messages:
    2
    Likes Received:
    0
    We have a problem on the romanian server with this script.
    Starting 2-3 days ago the script started to show the folowing error when you open the tabs that go tot the market:

    [​IMG]

    It says: Request has been blocked.
    The request has been blocked because you made to many requests to the server.
    Please make sure the scripts that you use don't do to many requests.

    I would much appreciate if someone could sort this error out.

    Thank you very much.
     
  8. otto44

    otto44 blocked

    Joined:
    Feb 6, 2016
    Messages:
    36
    Likes Received:
    30
    ^ having the same issue here.
     
  9. pokemonEX.co.uk

    pokemonEX.co.uk Still Going Strong

    Joined:
    May 30, 2011
    Messages:
    654
    Likes Received:
    33
  10. jishin

    jishin Non-stop Poster

    Joined:
    Oct 21, 2008
    Messages:
    147
    Likes Received:
    0
    I have had the same issue. It is a bit bothersome but I doubt that TW will change this.

    I suggest that you use the script: When all windows open, simply refresh the page (hit F5) and the Market page will. Click the Script link and proceed as before.

    You have a small step more, but it is worth it, even if you have many many villages.
     
  11. MR.MR

    MR.MR Contributing Poster

    Joined:
    Feb 19, 2009
    Messages:
    1,711
    Likes Received:
    21
    Ive found that if you use snaplinks to open just 5 markets at a time (instead of the bulk 25 using the links at the top of pages) it works fairly well
     
  12. LilGhost

    LilGhost Well-Known Member

    Joined:
    Jan 2, 2016
    Messages:
    87
    Likes Received:
    8
    Old, but for those who have been dealing with the "Request Blocking" (Request Limiting) when trying to open groups of 25 market tabs, I wrote the following script a few months ago:

    Code:
    // ==UserScript==
    // @name         Delayed Market Opener
    // @namespace    http://tampermonkey.net/
    // @version      0.3
    // @description  Adds a script to the page to open the market tabs slowly. (Prevents request blocking.)
    // @author       Ghost
    // @match        http://www.extremetw.com/cgi-bin/ResourceBalancerv4a.py*
    // @grant        none
    // ==/UserScript==
    /* jshint -W097 */
    var anchs = document.getElementsByTagName('a');
    var openerFunctionLinks = new Array();
    var ohHolyHell = 666;
    var twAnchors = new Array();
    for(i=0; i<anchs.length; i++){
        var anch = anchs[i];
        if(anch.getAttribute('onclick') !==null && anch.getAttribute('onclick').indexOf('openlinks') >= 0){
            // Match.
            openerFunctionLinks.push(anch);
        }else if(anch.href.indexOf(".tribalwars.net/game.php") >= 0){
            twAnchors.push(anch);
        }
    }
    
    var activeAnchors = new Array();
    
    function guid() {
      function s4() {
        return Math.floor((1 + Math.random()) * 0x10000)
          .toString(16)
          .substring(1);
      }
      return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
        s4() + '-' + s4() + s4() + s4();
    }
    
    var htmlButtons = [];
    
    for(i=0; i<openerFunctionLinks.length; i++){
        var link = openerFunctionLinks[i];
        var hookedAction = link.getAttribute("onclick");
        // console.log(link.textContent);
    
        var indices = /\[\s*(\d+)\s*-\s*(\d+)\]/g.exec(link.textContent);
        // console.log('Indices match: ' + indices);
        var boundRangeLow = indices[1];
        var boundRangeHigh = indices[2];
       
        // clear
        //link.setAttribute('onclick', "return false;");
       
        // var fuckMe_itsAGhost = eval("function(){ openMyLinksMatey(" + boundRangeLow + ", " + boundRangeHigh + "); }");
        var nB = document.createElement('button');
        var bT = "Delay Open Links " + link.textContent.trim();
        nB.innerHTML = bT;
        var subArr = new Array();
        // console.log('SubArr bounds: Low=' + boundRangeLow+'; High='+boundRangeHigh+';');
        // console.log('twAnchors=' + twAnchors);
        for(x=boundRangeLow;x<=boundRangeHigh;x++){ // indexing starts at 0, so we should make high bound inclusive.
            console.log('twAnchors[' + x + '] = ' + twAnchors[x]);
            if(typeof twAnchors[x] !== 'undefined')
                subArr.unshift(twAnchors[x]);
        }
        var subArrId = 'sa_'+guid().replace(/-/g, '_');
       
        var strSubArr = "var " + subArrId + " = ['";
        var virgin = true;
        for(x=0;x<subArr.length;x++){
            if(typeof subArr[x].href === 'undefined'){
                // console.log('Href undefined at twAnchors[' + x + ']: ' + subArr[x]);
            }
            if(virgin){
                strSubArr += subArr[x].href;
                virgin = false;
            }else
                strSubArr += "', '" + subArr[x].href;
        }
        strSubArr += "'];";
        var strFunct = "function open_"+subArrId+"(){window.setTimeout(function(){ if("+subArrId+".length>0){var subHref="+subArrId+".pop();window.open(subHref);open_"+subArrId+"();}}, " + ohHolyHell + ");}";
        var strOnclickCaller = "this.style='background-color:#7f7f7f';open_"+subArrId+"();return false;";
        var strEventHandler = strSubArr+strFunct+strOnclickCaller;
       
        // console.log(strEventHandler);
       
        nB.setAttribute('onclick', strEventHandler);
        htmlButtons.push(nB);
    }
    
    var main = document.getElementsByClassName("main");
    var mainHTML = main[0].innerHTML;
    var htmlToAdd = "<tr><td><div style='padding:0;margin-right:auto;margin-left:auto;text-align:center;'><h2><span style='color:green;'>Delayed Market Opener Script Is Loaded And Running</span></h2><h4>Written by Ghost</h4><div id='_RESERVED_OPENERS'></div></div><hr></td></tr>";
    main[0].innerHTML = htmlToAdd + mainHTML; // Add in the HTML!
    
    var reservedOpener = document.getElementById('_RESERVED_OPENERS');
    for(i=0;i<htmlButtons.length;i++)reservedOpener.appendChild(htmlButtons[i]);
    This script is intended to run through either TamperMonkey (for Chrome/Opera users) or GreaseMonkey (for FireFox users). (You should be able to find these add-ons/browser-extensions in your browser's relevant app store or repository.)

    GreaseMonkey and TamperMonkey scripts are forbidden by the InnoGames rules; however, this script is ONLY executed on the ExtremeTW.com result page, so this script does not violate any in-game rules. This script is perfectly legal, and it would only become illegal if it interacted directly with the Tribal Wars game. Additionally, because this script executes on a non-Tribal Wars page, it should not require approval.

    Note: I do not condone breaking the game rules, so if you install TamperMonkey or GreaseMonkey to use this script, please do not add any GreaseMonkey/TamperMonkey scripts that execute on a Tribal Wars game page.

    A screenshot of this script when it is running:
    [​IMG]
     
  13. finalbarrage

    finalbarrage Non-stop Poster

    Joined:
    Oct 21, 2017
    Messages:
    123
    Likes Received:
    58
    it does not put inn the resources in the market.

    everything works fine, until i click 0-24, then it just opens 1 window and thats it. it does not put inn the ress or anything.
     
  14. Ibra Gonza II

    Ibra Gonza II Non-stop Poster

    Joined:
    Dec 12, 2015
    Messages:
    251
    Likes Received:
    121
    You have to click it again to insert the resources
     
  15. 6LACK

    6LACK Member

    Joined:
    Jun 2, 2018
    Messages:
    15
    Likes Received:
    18
    Anyone have a working res balancer script?
     
  16. marclass

    marclass Well-Known Member

    Joined:
    Jun 13, 2010
    Messages:
    57
    Likes Received:
    0
  17. Veronika7747

    Veronika7747 Active Member

    Joined:
    Nov 20, 2013
    Messages:
    41
    Likes Received:
    9
    After the last update, I cannot get it working the same way; It no longer allows you to hit the script 2nd time; it requires to hit submit twice and than hit to move to the next tab; - much slower to accomplish the same with the same amount of keystokes.
    If anyone has it working for just "recycling" hitting script 4 times (as before) , please post it
     
  18. Saint Laurent

    Saint Laurent Well-Known Member

    Joined:
    Dec 4, 2018
    Messages:
    96
    Likes Received:
    57
    Same damn problem... so frustrating when your village count gets high
     
  19. Shenanigans

    Shenanigans New Member

    Joined:
    May 15, 2019
    Messages:
    3
    Likes Received:
    1
    Is this working for you?

    I'm unable to find a working resource balancing script :/
     
  20. Sadgasm

    Sadgasm New Member

    Joined:
    May 18, 2019
    Messages:
    1
    Likes Received:
    0
    dont working for me