1

I am new to this site. I wrote a code in javascript for Imacros, but it is giving me errors.

Config Info :

Firefox Version 32.0 IMACROS VERSION BUILD=8810214 Windows XP SP 2

The situation :

I wanted to make a macro, which checks if there is a certain text on the screen, and if it is there, run another macro and continue, and if the text is not on screen, then just continue...

So, here is my code(wrote with help of others)

  for (i = 0; i < 50000; i++) {

    var macro;
    macro =  "CODE:";
    macro +=  "VERSION BUILD=8810214 RECORDER=FX" + "\n";
    macro +=  "TAB T=1" + "\n";
    macro +=  "SET !EXTRACT_TEST_POPUP NO" + "\n";
    macro +=  "SET !TIMEOUT_STEP 0" + "\n";
    iimPlay(macro)

    var verify;
    verify =  "CODE:";
    verify +=  "SET !EXTRACT_TEST_POPUP NO" + "\n";
    verify +=  "SET !TIMEOUT_STEP 0" + "\n";
    verify +=  "TAG POS=1 TYPE=DIV ATTR=TXT:Beat<SP>Me EXTRACT=TXT" + "\n";
    iimPlay(verify)



    var G_Extract= iimGetLastExtract(1);
    if (G_Extract!=="#EANF#")
    {
    var captchasolver;
    captchasolver =  "CODE:";
    captchasolver +=  "VERSION BUILD=8820413 RECORDER=FX" + "\n";
    captchasolver +=  "TAB T=1" + "\n";
    captchasolver +=  "SET !EXTRACT_TEST_POPUP NO" + "\n";
    captchasolver +=  "ONDOWNLOAD FOLDER=d:\ FILE=captcha.jpg" + "\n";
    captchasolver +=  "TAG POS=1 TYPE=IMG ATTR=HREF:*captcha* CONTENT=EVENT:SAVE_ELEMENT_SCREENSHOT" + "\n";
    captchasolver +=  "TAB OPEN" + "\n";
    captchasolver +=  "TAB T=2" + "\n";
    captchasolver +=  "URL GOTO=http://www.9kw.eu/grafik/form.html" + "\n";
    captchasolver +=  "TAG POS=1 TYPE=INPUT ATTR=NAME:apikey CONTENT=xxxxxxx" + "\n";
    captchasolver +=  "TAG POS=1 TYPE=INPUT ATTR=NAME:prio CONTENT=0" + "\n";
    captchasolver +=  "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:/index.cgi ATTR=NAME:selfsolve CONTENT=NO" + "\n";
    captchasolver +=  "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:/index.cgi ATTR=NAME:confirm CONTENT=NO" + "\n";
    captchasolver +=  "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:/index.cgi ATTR=NAME:case-sensitive CONTENT=NO" + "\n";
    captchasolver +=  "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:/index.cgi ATTR=NAME:selfsolve CONTENT=NO" + "\n";
    captchasolver +=  "TAG POS=1 TYPE=INPUT ATTR=NAME:source CONTENT=imacros" + "\n";
    captchasolver +=  "TAG POS=1 TYPE=INPUT ATTR=NAME:file-upload-01 CONTENT=D:\captcha.jpg" + "\n";
    captchasolver +=  "TAG POS=1 TYPE=INPUT ATTR=TYPE:submit" + "\n";
    captchasolver +=  "TAG POS=1 TYPE=* ATTR=* EXTRACT=TXT" + "\n";
    captchasolver +=  "TAB CLOSE" + "\n";
    captchasolver +=  "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:NoFormName ATTR=NAME:captcha CONTENT={{!EXTRACT}}" + "\n";
    captchasolver +=  "TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:NoFormName ATTR=NAME:button" + "\n";
    captchasolver +=  "TAG POS=1 TYPE=A ATTR=TXT:Continue<SP>Battle" + "\n";

    iimPlay(captchasolver)

    }
    else
    {var submit;
    submit =  "CODE:";
    submit +=  "SET !EXTRACT_TEST_POPUP NO" + "\n";
    submit +=  "SET !TIMEOUT_STEP 0" + "\n";
    submit +=  "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:submit.php* ATTR=NAME:submit" + "\n";
    iimPlay(submit)}

    //New Step

    iimPlay(verify)
    var G_Extract= iimGetLastExtract(1);
    if (G_Extract!=="#EANF#")
    {
    iimPlay(captchasolver)
    }
    else
    {iimPlay(submit)}

    //New Step


    iimPlay(verify);
    var G_Extract= iimGetLastExtract(1);
    if (G_Extract!=="#EANF#")
    {
    iimPlay(captchasolver)
    }


    }

As you can see, there is first, a simple for loop, then iimplan(macro) is just there for important things like no extract popup, and timeout step 0 and such...

iimplay(verify) extracts that certain text,then I check with if statement if the line existed G_Extract !== EANF, then run captchasolver, or else, continue...

The same thing goes on in the script.

The problem :

I brought the page with the text I didn't want, and the script worked, it ran the captchasolver script, but when I ran the main script when the undesired text was not on screen, and left, after returning back, I found out that even though that undesired text was on screen, the script was not running the captchasolver script...

So, my question is that what could be the reason for it, and how can I fix it? Please help..

And what can I do to test it offline?

bestisme
  • 11
  • 2

1 Answers1

0

Use imacros with javascript for if and else. Offline tests are not possible with online services and I think the best way is javascript with jquery for your problem.

See other threads for javascript, jquery and imacros How to make imacro to select/solve the captcha?(RecaptchaV2) and iMacros Http POST to API endpoint

Community
  • 1
  • 1
thecoder
  • 102
  • 8