'IF Statements and Conditions for iMacros Firefox

So I'm trying to make a macro to catch Pokemon from maps in this game but there if you encounter a Turf War it will show this image:

http://i.imgur.com/W6Tjd8l.jpg

As you can see the click button says "Lets Battle!" and it redirects you to a battle link.

However, I want to make an if statement that if I encounter this battle link I would refresh the page instead and let me go here.

Does anybody know how to code if statements for this?

So here's how I want it to work:

if (it encounters the Turf Battle)
   will click another link
else
   keep clicking the map to catch using the click x and y

EDIT: I tried this syntax:

if (TAG POS=1 TYPE=H2 ATTR=TXT:You<SP>Don't<SP>Belong<SP>Here!)
{ 
    REFRESH
}

but it won't work. Any help maybe? Giving me this error:

SyntaxError: unknown command: IF, line: 1 (Error code: -910)


Solution 1:[1]

You can try by *.js file (not *.iim file) :

  1. open notepad
  2. copy my code
  3. edit YOUR-URL to your url
  4. save this to your-file.js ( path= imacro path )
  5. open firefox & run your-file.js

good luck

CODE:

       iimPlay("Code:URL GOTO=YOUR-URL")
   var macro;                        
    macro+="SET !REPLAYSPEED FAST\n";
    macro+="TAG POS=1 TYPE=H2 ATTR=TXT:* EXTRACT=TXT\n";
    iimPlay(macro_var);
    var result=iimGetLastExtract();
    if(result=="You<SP>Don't<SP>Belong<SP>Here!")
    {
    iimDisplay("success");
    REFRESH
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alex Jolig