puretppc
puretppc

Reputation: 3292

How do I make a loop off of this code for iMacros?

So this is my code right now and as you can see this clearly is possible using a loop. The number between the bracket is what I want to change.

How do I make a loop from here since I want to go to like 100 or higher instead of having to copy and paste and change the value?

EVENT TYPE=CLICK SELECTOR=#CP>OPTION:nth-of-type(1) MODIFIERS=shift
EVENT TYPE=CLICK SELECTOR=#CP>OPTION:nth-of-type(2) MODIFIERS=shift
EVENT TYPE=CLICK SELECTOR=#CP>OPTION:nth-of-type(3) MODIFIERS=shift
EVENT TYPE=CLICK SELECTOR=#CP>OPTION:nth-of-type(4) MODIFIERS=shift
EVENT TYPE=CLICK SELECTOR=#CP>OPTION:nth-of-type(5) MODIFIERS=shift

This is my new code I wrote for Javascript.

var test;

test ="CODE:";
test +="SET !ERRORIGNORE YES "+"\n";
test +="URL GOTO=http://tppcrpg.net/create_trade.php?id=1 "+"\n";
test +="EVENT TYPE=CLICK SELECTOR=#CP>OPTION:nth-of-type({{!loop}}) MODIFIERS=shift"

for (var i = 1; i < 10 ; i++)
{
test +="EVENT TYPE=CLICK SELECTOR=#CP>OPTION:nth-of-type" + ({{String(i)}}) + "MODIFIERS=shift"
}

iimPlay(test)
iimPlay("myMacro.iim")

Just wondering how to program it so that it can run with me going to the link and selecting from a list.

Upvotes: 1

Views: 1857

Answers (2)

edinvnode
edinvnode

Reputation: 3547

Try this out.

var test;

test ="CODE:";
test +="SET !ERRORIGNORE YES "+"\n";
test +="URL GOTO=http://tppcrpg.net/create_trade.php?id=1 "+"\n";
test +="EVENT TYPE=CLICK SELECTOR=#CP>OPTION:nth-of-type{{n}) MODIFIERS=shift"

for (var i = 1; i < 10 ; i++)
{

iimSet("n",i)
iimPlay(test)
iimPlay("myMacro.iim")

}

Upvotes: 1

Bestmacros
Bestmacros

Reputation: 1867

try this:

EVENT TYPE=CLICK SELECTOR=#CP>OPTION:nth-of-type({{!loop}}) MODIFIERS=shift

Upvotes: 2

Related Questions