I am trying to use iMacros with Firefox to click an UnFollow button ONLY if this code exist on the page...
<small class="follow-status">follows you</small>
If the above does not exist in the page source then it would run this iMacros code...
TAG POS=1 TYPE=DIV ATTR=TXT:UnFollow
From what I have read, there is no if/else type syntax but you can run Javascript with
EVAL("Javascript code here")
If anyone knows how I could do this I could really use the help
You can trick Imacros to make an If statement, but first you have to SET !ERRORIGNORE YES
for this macro. Then:
SET EXTRACT NULL 'if this exist you extract the text(even if you know it) 'if doesn't exist should return error but we turned that off; Extract remains Null TAG POS=1 TYPE=SMALL ATTR=TXT:follows<SP>you EXTRACT=TXT SET !VAR1 EVAL("var text=\"{{!EXTRACT}}\"; if(text==\"follows you\") text = \"jibber\";else text = \"UnFollow\";text;") 'this one executes if the text is right, if not should give error but we turned that off TAG POS=1 TYPE=DIV ATTR=TXT:{{!VAR1}}
Use a javascript file for this
run(); function run() { var exists = doesElementExist(); alert('element exists? ' + exists); if (exists) { iimPlay('CODE: TAG POS=1 TYPE=DIV ATTR=TXT:UnFollow'); } else { // do something else here } } // test if element exists function doesElementExist() { iimDisplay('looking for small element with class "follow-status" on page'); var code = iimPlay('CODE: SET !TIMEOUT_TAG 1\n' + 'TAG POS=1 TYPE=SMALL ATTR=CLASS:follow-status EXTRACT=TXT'); if (code !==1) { return false; } var extract = iimGetLastExtract(); if (extract === '#EANF#') { return false; } return true; }