Create offers script

  • Thread starter DeletedUser1327
  • Start date

DeletedUser1327

Guest
Hello,

I had this script:

Code:
javascript:var doc=document;if(window.frames.length>0)doc=window.main.document;  url=doc.URL;var start=url.indexOf("village");var end=url.indexOf('%26',start);  var id;if(end>0)id=url.substring(start,end);elseid=url.substring(start);  if(url.indexOf('screen=market')==-1||url.indexOf('mode=own_offer')==-1)location.search='?screen=market&mode=own_offer&'+id;  else {var wood=new Number(doc.getElementById('wood').innerHTML);var clay=new Number(doc.getElementById('stone').innerHTML);  var iron=new Number(doc.getElementById('iron').innerHTML);var forms=doc.getElementsByTagName('form');var table="";  for(i=0;i<forms.length&&table=="";i++){if(forms[i].action.indexOf('action=modify_offers')!=-1)  {table=forms[i].getElementsByTagName('table')[0];}}for(i=1;table!=""&&i<table.rows.length-1;i++)  {child=table.rows[i].cells[1].childNodes;res=child[0].title;num="";for(j=0;j<child.length;j++){value = child[j].nodeValue;  if(value != null)num+=value;}num=num.substring(0,num.length-1);num*=new Number(table.rows[i].cells[2].innerHTML);  if(res=='Wood')wood+=num;if(res=='Clay')clay+=num;if(res=='Iron')iron+=num;}  doc.getElementById('res_sell_wood').checked=wood>clay&&wood>iron;doc.getElementById('res_sell_stone').checked=clay>wood&&clay>iron;  doc.getElementById('res_sell_iron').checked=iron>clay&&iron>wood;doc.getElementById('res_buy_wood').checked=wood<clay&&wood<iron;  doc.getElementById('res_buy_stone').checked=clay<wood&&clay<iron;doc.getElementById('res_buy_iron').checked=iron<clay&&iron<wood;  wood=Math.round(wood/1000);clay=Math.round(clay/1000);iron=Math.round(iron/1000);  offers=Math.max(Math.max(wood,clay),iron)-Math.min(Math.min(wood,clay),iron);offers=Math.round(offers/2);  inputs=doc.getElementsByTagName('input');for(i=0;i<inputs.length;i++){if(inputs[i].value=='Create')inputs[i].focus();  }doc.getElementsByName('multi')[0].value=offers;doc.getElementsByName('max_time')[0].value=5;  doc.getElementsByName('sell')[0].value=1000;doc.getElementsByName('buy')[0].value=1000;}end();

That was creating offers in market automatically, according to the resources balance.

But now we have the premium trade and the resources are added here:

Screenshot_5.png
Screenshot_5.png
Screenshot_5.png

And they must be added here:

Screenshot_7.png
Screenshot_7.png
Screenshot_7.png

Can someone fix it or give me an other script that is working???
 
Last edited by a moderator:

DeletedUser3272

Guest
yes, pleas ei am having the same issue?

is there away to remove the payment offers from the view, like disable them or a re-written script to take them into account
 

DeletedUser

Guest
Give this a try:

Code:
javascript:
var doc=document;
if(window.frames.length>0)
    doc=window.main.document;
url=doc.URL;
var start=url.indexOf("village");
var end=url.indexOf('%26',start);
 var id;
 if(end>0)
    id=url.substring(start,end);
 else
    id=url.substring(start);
 if(url.indexOf('screen=market')==-1||url.indexOf('mode=own_offer')==-1)
    location.search='?screen=market&mode=own_offer&'+id;
    

 else {
    var wood=new Number(doc.getElementById('wood').innerHTML);
    var clay=new Number(doc.getElementById('stone').innerHTML);
    var iron=new Number(doc.getElementById('iron').innerHTML);
    var forms=doc.getElementsByTagName('form');
    var table="";
    for(i=0;i<forms.length&&table=="";i++)
    {
        if(forms[i].action.indexOf('action=modify_offers')!=-1)
        {
            table=forms[i].getElementsByTagName('table')[0];
        }
    }
    for(i=1;table!=""&&i<table.rows.length-1;i++)
    {
        child=table.rows[i].cells[1].childNodes;
        res=child[0].title;
        num="";
        for(j=0;j<child.length;j++)
        {
            value = child[j].nodeValue;
            if(value != null)num+=value;
        }
        num=num.substring(0,num.length-1);
        num*=new Number(table.rows[i].cells[2].innerHTML);
        if(res=='Wood')
            wood+=num;
        if(res=='Clay')
            clay+=num;
        if(res=='Iron')
            iron+=num;
    }
    var merchant_exists = document.forms.length - 1; /* 1 if village merchant exists, 0 if no merchant*/
    document.forms[merchant_exists].res_sell[0].checked=wood>clay&&wood>iron;
    document.forms[merchant_exists].res_sell[1].checked=clay>wood&&clay>iron;
    document.forms[merchant_exists].res_sell[2].checked=iron>clay&&iron>wood;
    document.forms[merchant_exists].res_buy[0].checked=wood<clay&&wood<iron;
    document.forms[merchant_exists].res_buy[1].checked=clay<wood&&clay<iron;
    document.forms[merchant_exists].res_buy[2].checked=iron<clay&&iron<wood;
    wood=Math.round(wood/1000);
    clay=Math.round(clay/1000);
    iron=Math.round(iron/1000);
    offers=Math.max(Math.max(wood,clay),iron)-Math.min(Math.min(wood,clay),iron);
    offers=Math.round(offers/2);
    inputs=doc.getElementsByTagName('input');
    for(i=0;i<inputs.length;i++)
    {
        if(inputs[i].value=='Create')
        inputs[i].focus();
    }
    doc.getElementsByName('multi')[0].value=offers;
    doc.getElementsByName('max_time')[0].value=5;
    doc.getElementsByName('sell')[1].value=1000;
    doc.getElementsByName('buy')[1].value=1000;
}
 void 0;
 

DeletedUser1327

Guest
That works perfect!!! But how can I change the maximum duration into 12 hours?
 

DeletedUser

Guest
towards the bottom of the script

Code:
doc.getElementsByName('max_time')[0].value=5;

just change that 5 to a 12 :)
 

DeletedUser

Guest
how would you use this to make offers offering

1k iron for 2k wood?
 

DeletedUser1327

Guest
Just edit these values (the 1st is Offer, the 2nd is For)

Code:
doc.getElementsByName('sell')[1].value=1000;      doc.getElementsByName('buy')[1].value=2000;  }

or use this:

javascript: var doc=document; if(window.frames.length>0) doc=window.main.document; url=doc.URL; var start=url.indexOf("village"); var end=url.indexOf('%26',start); var id; if(end>0) id=url.substring(start,end); else id=url.substring(start); if(url.indexOf('screen=market')==-1||url.indexOf('mode=own_offer')==-1) location.search='?screen=market&mode=own_offer&'+id; else { var wood=new Number(doc.getElementById('wood').innerHTML); var clay=new Number(doc.getElementById('stone').innerHTML); var iron=new Number(doc.getElementById('iron').innerHTML); var forms=doc.getElementsByTagName('form'); var table=""; for(i=0;i<forms.length&&table=="";i++) { if(forms.action.indexOf('action=modify_offers')!=-1) { table=forms.getElementsByTagName('table')[0]; } } for(i=1;table!=""&&i<table.rows.length-1;i++) { child=table.rows.cells[1].childNodes; res=child[0].title; num=""; for(j=0;j<child.length;j++) { value = child[j].nodeValue; if(value != null)num+=value; } num=num.substring(0,num.length-1); num*=new Number(table.rows.cells[2].innerHTML); if(res=='Wood') wood+=num; if(res=='Clay') clay+=num; if(res=='Iron') iron+=num; } var merchant_exists = document.forms.length - 1; /* 1 if village merchant exists, 0 if no merchant*/ document.forms[merchant_exists].res_sell[0].checked=wood>clay&&wood>iron; document.forms[merchant_exists].res_sell[1].checked=clay>wood&&clay>iron; document.forms[merchant_exists].res_sell[2].checked=iron>clay&&iron>wood; document.forms[merchant_exists].res_buy[0].checked=wood<clay&&wood<iron; document.forms[merchant_exists].res_buy[1].checked=clay<wood&&clay<iron; document.forms[merchant_exists].res_buy[2].checked=iron<clay&&iron<wood; wood=Math.round(wood/1000); clay=Math.round(clay/1000); iron=Math.round(iron/1000); offers=Math.max(Math.max(wood,clay),iron)-Math.min(Math.min(wood,clay),iron); offers=Math.round(offers/2); inputs=doc.getElementsByTagName('input'); for(i=0;i<inputs.length;i++) { if(inputs.value=='Create') inputs.focus(); } doc.getElementsByName('multi')[0].value=offers; doc.getElementsByName('max_time')[0].value=5; doc.getElementsByName('sell')[1].value=1000; doc.getElementsByName('buy')[1].value=2000; } void 0;
 

DeletedUser3272

Guest
for some reason, when i have 110 market, it puts in 190 or so offers, why wont it read the available merchants?
 
Top