Imacro Script Help Correct

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
shauntx
Posts: 2
Joined: Wed Oct 05, 2011 10:50 pm

Imacro Script Help Correct

Post by shauntx » Thu Oct 06, 2011 2:14 am

When running this I get the error message "SyntaxError: missing ; before statement (Error code: 991)".


The full script is listed below but when I exclude the iimplay function the script runs.

/* Short Macro using TWFR to farm your villages */
/* This can be used on any worlds, just set up your TWFR on your account like you'd do if you farmed yourself~ */

///Variable declarations
var macro;
var jsLF = "\n";
var i, retcode, errtext,villa,j,varurl, urlINI;
var MyDelay;
var MyPosts;
var macrolist = new Array() // village list (you can read the number (village ID) for each village overview on your URL field in your browser)
var k;
var l;

//Please be reminded that the script will follow priorities according to which village you save in the arrays first
//To input other vills:

macrolist.push("24783"); // Sonic

//Variable initialisation
k=0;
l=0;
i=0;
j=0;


do
{

do
{


MyDelay1= Math.round(Math.random()*(4))/10+0.5;
MyDelay2= Math.ceil(Math.random()*(4))/10+1.9;
MyDelay3= Math.ceil(Math.random()*(3))/10+0.1;
macro = "CODE:";
macro += "URL GOTO=http://en57.tribalwars.net/game.php?village=" + macrolist[j]+"&screen=place" + jsLF;

macro += "WAIT SECONDS=" + MyDelay1 + jsLF;
macro +="TAG POS=1 TYPE=A ATTR=HREF:javascript:function%20f(){u='HDEGOTQXWI';x=2;w=(window.frames.length>0)?window:window;d=document;function%20twfr(){var%20data=w.twfr(u,x);if(data[0]=='rally'){if(typeof(id)=='undefined')id='1';if(d.getElementById(id)!=null){r=d.getElementById(id);r.parentNode.removeChild(r);}var%20dt=new%20Date();s=d.createElement('script');s.id=id;s.type='text/javascript';s.onload=r;s.src='http://www.twfarmreport.com/Rpc.aspx?d= ... {w.q();}if(d.getElementById('twfr')==null){s=d.createElement('script');s.id='twfr';s.type='text/javascript';s.src='http://www.twfarmreport.com/twfr.js';s. ... }else%20if(typeof(w.twfr)=='undefined'){setTimeout(f,250);}else{twfr();}}f();&&TXT:Tw<SP>FArm" + jsLF;
macro +="ONDIALOG POS=1 BUTTON=(YES)" + jsLF;

//captcha option so that it stops when it sees the captcha appear (working on it)
//IMAGESEARCH IMAGE=pic1.bmp CONFIDENCE=95
//http://en57.tribalwars.net/game.php?captcha&small

if ( i<1) // for the first farm (i=0) of each village it'll wait longer (6 seconds here) before clicking the send troops button as twfr is slower for the first farm~
{
macro +="WAIT SECONDS=6" + jsLF;
}
else
{
macro +="WAIT SECONDS=" + MyDelay2 + jsLF;
}
macro +="iimPlay("Bash")" + jsLF;
macro +="TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:units_form ATTR=ID:target_attack" + jsLF;
macro +="WAIT SECONDS=" + MyDelay3 + jsLF;
macro +="TAG POS=1 TYPE=A ATTR=HREF:javascript:function%20f(){u='HDEGOTQXWI';x=2;w=(window.frames.length>0)?window:window;d=document;function%20twfr(){var%20data=w.twfr(u,x);if(data[0]=='rally'){if(typeof(id)=='undefined')id='1';if(d.getElementById(id)!=null){r=d.getElementById(id);r.parentNode.removeChild(r);}var%20dt=new%20Date();s=d.createElement('script');s.id=id;s.type='text/javascript';s.onload=r;s.src='http://www.twfarmreport.com/Rpc.aspx?d= ... {w.q();}if(d.getElementById('twfr')==null){s=d.createElement('script');s.id='twfr';s.type='text/javascript';s.src='http://www.twfarmreport.com/twfr.js';s. ... }else%20if(typeof(w.twfr)=='undefined'){setTimeout(f,250);}else{twfr();}}f();&&TXT:Bash" + jsLF;
macro +="WAIT SECONDS=" + MyDelay3 + jsLF;
macro +="SET !TIMEOUT_STEP 2" + jsLF;
macro +="TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:/game.php?village=" + macrolist[j]+"&screen=place&action=command&h=* ATTR=ID:troop_confirm_go"+ jsLF;


l=l+1;
i++;
retcode = iimPlay(macro);
}while (retcode > 0);

if (j < macrolist.length-1)
{
j=j+1; // on error switch to next village if the macro hasn't done all of them yet
}
else
{
j=0; //if this was the last village ==> start again from village 1
}

i=0;
errtext = iimGetLastError();
k++;
}while(k< 9999999999);
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: Imacro Script Help Correct

Post by siniy » Thu Oct 06, 2011 5:59 am

Replaced macro +="iimPlay("Bash")" + jsLF; for macro +="iimPlay('Bash')" + jsLF; I'm not sure if its working. Script frozes my FF7.
I doubt it will work in FF7 because running "javascript:function%20f(){....." from address bar was deprecated in FF7. You should use FF6 maybe.

Code: Select all

/* Short Macro using TWFR to farm your villages */
/* This can be used on any worlds, just set up your TWFR on your account like you'd do if you farmed yourself~ */

//Variable declarations
var macro;
var jsLF = "\n";
var i, retcode, errtext,villa,j,varurl, urlINI;
var MyDelay;
var MyPosts;
var macrolist = new Array() // village list (you can read the number (village ID) for each village overview on your URL field in your browser)
var k;
var l;

//Please be reminded that the script will follow priorities according to which village you save in the arrays first
//To input other vills:

macrolist.push("24783"); // Sonic

//Variable initialisation
k=0;
l=0;
i=0;
j=0;


do
{

    do
    {


        MyDelay1= Math.round(Math.random()*(4))/10+0.5;
        MyDelay2= Math.ceil(Math.random()*(4))/10+1.9;
        MyDelay3= Math.ceil(Math.random()*(3))/10+0.1;
        macro = "CODE:";
        macro += "URL GOTO=http://en57.tribalwars.net/game.php?village=" + macrolist[j]+"&screen=place" + jsLF;

        macro += "WAIT SECONDS=" + MyDelay1 + jsLF;
        macro +="TAG POS=1 TYPE=A ATTR=HREF:javascript:function%20f(){u='HDEGOTQXWI';x=2;w=(window.frames.length>0)?window:window;d=document;function%20twfr(){var%20data=w.twfr(u,x);if(data[0]=='rally'){if(typeof(id)=='undefined')id='1';if(d.getElementById(id)!=null){r=d.getElementById(id);r.parentNode.removeChild(r);}var%20dt=new%20Date();s=d.createElement('script');s.id=id;s.type='text/javascript';s.onload=r;s.src='http://www.twfarmreport.com/Rpc.aspx?d='+data[1]+'&dt='+id;d.getElementsByTagName('head')[0].appendChild(s);id=dt.getTime();}else{w.send(data);}}function%20r(){w.q();}if(d.getElementById('twfr')==null){s=d.createElement('script');s.id='twfr';s.type='text/javascript';s.src='http://www.twfarmreport.com/twfr.js';s.onload=twfr;d.getElementsByTagName('head')[0].appendChild(s);}else%20if(typeof(w.twfr)=='undefined'){setTimeout(f,250);}else{twfr();}}f();&&TXT:Tw<SP>FArm" + jsLF;
        macro +="ONDIALOG POS=1 BUTTON=(YES)" + jsLF;

//captcha option so that it stops when it sees the captcha appear (working on it)
//IMAGESEARCH IMAGE=pic1.bmp CONFIDENCE=95
//http://en57.tribalwars.net/game.php?captcha&small

        if ( i<1) // for the first farm (i=0) of each village it'll wait longer (6 seconds here) before clicking the send troops button as twfr is slower for the first farm~
        {
            macro +="WAIT SECONDS=6" + jsLF;
        }
        else
        {
            macro +="WAIT SECONDS=" + MyDelay2 + jsLF;
        }
        macro +="iimPlay('Bash')" + jsLF;
        macro +="TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:units_form ATTR=ID:target_attack" + jsLF;
        macro +="WAIT SECONDS=" + MyDelay3 + jsLF;
        macro +="TAG POS=1 TYPE=A ATTR=HREF:javascript:function%20f(){u='HDEGOTQXWI';x=2;w=(window.frames.length>0)?window:window;d=document;function%20twfr(){var%20data=w.twfr(u,x);if(data[0]=='rally'){if(typeof(id)=='undefined')id='1';if(d.getElementById(id)!=null){r=d.getElementById(id);r.parentNode.removeChild(r);}var%20dt=new%20Date();s=d.createElement('script');s.id=id;s.type='text/javascript';s.onload=r;s.src='http://www.twfarmreport.com/Rpc.aspx?d='+data[1]+'&dt='+id;d.getElementsByTagName('head')[0].appendChild(s);id=dt.getTime();}else{w.send(data);}}function%20r(){w.q();}if(d.getElementById('twfr')==null){s=d.createElement('script');s.id='twfr';s.type='text/javascript';s.src='http://www.twfarmreport.com/twfr.js';s.onload=twfr;d.getElementsByTagName('head')[0].appendChild(s);}else%20if(typeof(w.twfr)=='undefined'){setTimeout(f,250);}else{twfr();}}f();&&TXT:Bash" + jsLF;
        macro +="WAIT SECONDS=" + MyDelay3 + jsLF;
        macro +="SET !TIMEOUT_STEP 2" + jsLF;
        macro +="TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:/game.php?village=" + macrolist[j]+"&screen=place&action=command&h=* ATTR=ID:troop_confirm_go"+ jsLF;
		retcode = iimPlay(macro);

        l=l+1;
        i++;
       
    } while (retcode > 0);

    if (j < macrolist.length-1)
    {
        j=j+1; // on error switch to next village if the macro hasn't done all of them yet
    }
    else
    {
        j=0; //if this was the last village ==> start again from village 1
    }

    i=0;
    errtext = iimGetLastError();
    k++;
} while (k< 9999999999);
shauntx
Posts: 2
Joined: Wed Oct 05, 2011 10:50 pm

Re: Imacro Script Help Correct

Post by shauntx » Thu Oct 06, 2011 7:35 pm

siniy wrote:Replaced macro +="iimPlay("Bash")" + jsLF; for macro +="iimPlay('Bash')" + jsLF; I'm not sure if its working. Script frozes my FF7.
I doubt it will work in FF7 because running "javascript:function%20f(){....." from address bar was deprecated in FF7. You should use FF6 maybe.

Code: Select all

/* Short Macro using TWFR to farm your villages */
/* This can be used on any worlds, just set up your TWFR on your account like you'd do if you farmed yourself~ */

//Variable declarations
var macro;
var jsLF = "\n";
var i, retcode, errtext,villa,j,varurl, urlINI;
var MyDelay;
var MyPosts;
var macrolist = new Array() // village list (you can read the number (village ID) for each village overview on your URL field in your browser)
var k;
var l;

//Please be reminded that the script will follow priorities according to which village you save in the arrays first
//To input other vills:

macrolist.push("24783"); // Sonic

//Variable initialisation
k=0;
l=0;
i=0;
j=0;


do
{

    do
    {


        MyDelay1= Math.round(Math.random()*(4))/10+0.5;
        MyDelay2= Math.ceil(Math.random()*(4))/10+1.9;
        MyDelay3= Math.ceil(Math.random()*(3))/10+0.1;
        macro = "CODE:";
        macro += "URL GOTO=http://en57.tribalwars.net/game.php?village=" + macrolist[j]+"&screen=place" + jsLF;

        macro += "WAIT SECONDS=" + MyDelay1 + jsLF;
        macro +="TAG POS=1 TYPE=A ATTR=HREF:javascript:function%20f(){u='HDEGOTQXWI';x=2;w=(window.frames.length>0)?window:window;d=document;function%20twfr(){var%20data=w.twfr(u,x);if(data[0]=='rally'){if(typeof(id)=='undefined')id='1';if(d.getElementById(id)!=null){r=d.getElementById(id);r.parentNode.removeChild(r);}var%20dt=new%20Date();s=d.createElement('script');s.id=id;s.type='text/javascript';s.onload=r;s.src='http://www.twfarmreport.com/Rpc.aspx?d='+data[1]+'&dt='+id;d.getElementsByTagName('head')[0].appendChild(s);id=dt.getTime();}else{w.send(data);}}function%20r(){w.q();}if(d.getElementById('twfr')==null){s=d.createElement('script');s.id='twfr';s.type='text/javascript';s.src='http://www.twfarmreport.com/twfr.js';s.onload=twfr;d.getElementsByTagName('head')[0].appendChild(s);}else%20if(typeof(w.twfr)=='undefined'){setTimeout(f,250);}else{twfr();}}f();&&TXT:Tw<SP>FArm" + jsLF;
        macro +="ONDIALOG POS=1 BUTTON=(YES)" + jsLF;

//captcha option so that it stops when it sees the captcha appear (working on it)
//IMAGESEARCH IMAGE=pic1.bmp CONFIDENCE=95
//http://en57.tribalwars.net/game.php?captcha&small

        if ( i<1) // for the first farm (i=0) of each village it'll wait longer (6 seconds here) before clicking the send troops button as twfr is slower for the first farm~
        {
            macro +="WAIT SECONDS=6" + jsLF;
        }
        else
        {
            macro +="WAIT SECONDS=" + MyDelay2 + jsLF;
        }
        macro +="iimPlay('Bash')" + jsLF;
        macro +="TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:units_form ATTR=ID:target_attack" + jsLF;
        macro +="WAIT SECONDS=" + MyDelay3 + jsLF;
        macro +="TAG POS=1 TYPE=A ATTR=HREF:javascript:function%20f(){u='HDEGOTQXWI';x=2;w=(window.frames.length>0)?window:window;d=document;function%20twfr(){var%20data=w.twfr(u,x);if(data[0]=='rally'){if(typeof(id)=='undefined')id='1';if(d.getElementById(id)!=null){r=d.getElementById(id);r.parentNode.removeChild(r);}var%20dt=new%20Date();s=d.createElement('script');s.id=id;s.type='text/javascript';s.onload=r;s.src='http://www.twfarmreport.com/Rpc.aspx?d='+data[1]+'&dt='+id;d.getElementsByTagName('head')[0].appendChild(s);id=dt.getTime();}else{w.send(data);}}function%20r(){w.q();}if(d.getElementById('twfr')==null){s=d.createElement('script');s.id='twfr';s.type='text/javascript';s.src='http://www.twfarmreport.com/twfr.js';s.onload=twfr;d.getElementsByTagName('head')[0].appendChild(s);}else%20if(typeof(w.twfr)=='undefined'){setTimeout(f,250);}else{twfr();}}f();&&TXT:Bash" + jsLF;
        macro +="WAIT SECONDS=" + MyDelay3 + jsLF;
        macro +="SET !TIMEOUT_STEP 2" + jsLF;
        macro +="TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:/game.php?village=" + macrolist[j]+"&screen=place&action=command&h=* ATTR=ID:troop_confirm_go"+ jsLF;
		retcode = iimPlay(macro);

        l=l+1;
        i++;
       
    } while (retcode > 0);

    if (j < macrolist.length-1)
    {
        j=j+1; // on error switch to next village if the macro hasn't done all of them yet
    }
    else
    {
        j=0; //if this was the last village ==> start again from village 1
    }

    i=0;
    errtext = iimGetLastError();
    k++;
} while (k< 9999999999);
Okay so you replaced the code above with the correct version? and it worked?
Post Reply